aboutsummaryrefslogtreecommitdiff
path: root/build/path-map
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-06-18 14:41:45 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-06-18 14:41:45 +0200
commit63e7a4a77cb8ceed7b42561fe3202b0b48d86db6 (patch)
treebde5a79522225f32ec188ba46d0834486c30f00f /build/path-map
parent28c82c861e38fe05a25e916563e0551ed8fce91e (diff)
Move path and filesystem from build2 to libbutl
Diffstat (limited to 'build/path-map')
-rw-r--r--build/path-map88
1 files changed, 0 insertions, 88 deletions
diff --git a/build/path-map b/build/path-map
deleted file mode 100644
index 8355ccc..0000000
--- a/build/path-map
+++ /dev/null
@@ -1,88 +0,0 @@
-// file : build/path-map -*- C++ -*-
-// copyright : Copyright (c) 2014-2015 Code Synthesis Ltd
-// license : MIT; see accompanying LICENSE file
-
-#ifndef BUILD_PATH_MAP
-#define BUILD_PATH_MAP
-
-#include <butl/prefix-map>
-
-#include <build/path>
-
-namespace butl
-{
-
- // @@ Remove butl:: when move to libbutl.
-
- // prefix_map for paths
- //
- // The paths should be normalized.
- //
- // Note that the path's representation of POSIX root ('/') is
- // inconsistent in that we have a trailing delimiter at the end of
- // the path (its "proper" representation would have been an empty
- // string but that would have clashed with empty paths). To work
- // around this snag, this implementation, during key comparison,
- // detects '/' and treats it as empty. Note that the map will
- // still store the key as you have first inserted it. So if you
- // want a particular representation, pre-populate the map with
- // it.
- //
- template <typename C, typename K>
- struct compare_prefix<build::basic_path<C, K>>: compare_prefix<std::basic_string<C>>
- {
- typedef build::basic_path<C, K> key_type;
-
- typedef C delimiter_type;
- typedef std::basic_string<C> string_type;
- typedef compare_prefix<std::basic_string<C>> base;
-
- explicit
- compare_prefix (delimiter_type d): base (d) {}
-
- bool
- operator() (const key_type& x, const key_type& y) const
- {
- const auto& xs (x.string ());
- const auto& ys (y.string ());
-
-#ifdef _WIN32
- return base::compare (xs.c_str (),
- xs.size (),
- ys.c_str (),
- ys.size ()) < 0;
-#else
- return base::compare (xs.c_str (),
- x.root () ? 0 : xs.size (),
- ys.c_str (),
- y.root () ? 0 : ys.size ()) < 0;
-#endif
- }
-
- bool
- prefix (const key_type& p, const key_type& k) const
- {
- const auto& ps (p.string ());
- const auto& ks (k.string ());
-
-#ifdef _WIN32
- return base::prefix (ps, ks);
-#else
- return base::prefix (p.root () ? string_type () : ps,
- k.root () ? string_type () : ks);
-#endif
- }
- };
-}
-
-namespace build
-{
- template <typename T>
- using path_map = butl::prefix_map<path, T, path::traits::directory_separator>;
-
- template <typename T>
- using dir_path_map =
- butl::prefix_map<dir_path, T, dir_path::traits::directory_separator>;
-}
-
-#endif // BUILD_PATH_MAP