From dea0d0913711f23fff3b902e3aa6006c6b54905a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 23 Feb 2015 16:16:23 +0200 Subject: Clean up file names --- build/key-set | 2 +- build/prefix-map | 140 +++++++++++++++++++++++++++++++++++++++++++++++++++ build/prefix-map.txx | 42 ++++++++++++++++ build/prefix_map | 140 --------------------------------------------------- build/prefix_map.txx | 42 ---------------- build/rule | 2 +- 6 files changed, 184 insertions(+), 184 deletions(-) create mode 100644 build/prefix-map create mode 100644 build/prefix-map.txx delete mode 100644 build/prefix_map delete mode 100644 build/prefix_map.txx (limited to 'build') diff --git a/build/key-set b/build/key-set index 9cb7d6c..8c197b8 100644 --- a/build/key-set +++ b/build/key-set @@ -1,4 +1,4 @@ -// file : build/key_set -*- C++ -*- +// file : build/key-set -*- C++ -*- // copyright : Copyright (c) 2014-2015 Code Synthesis Tools CC // license : MIT; see accompanying LICENSE file diff --git a/build/prefix-map b/build/prefix-map new file mode 100644 index 0000000..d2ca9be --- /dev/null +++ b/build/prefix-map @@ -0,0 +1,140 @@ +// file : build/prefix-map -*- C++ -*- +// copyright : Copyright (c) 2014-2015 Code Synthesis Tools CC +// license : MIT; see accompanying LICENSE file + +#ifndef BUILD_PREFIX_MAP +#define BUILD_PREFIX_MAP + +#include +#include +#include // move() +#include // min() + +namespace build +{ + template + struct compare_prefix; + + template + struct compare_prefix> + { + typedef std::basic_string K; + + typedef C char_type; + typedef typename K::size_type size_type; + typedef typename K::traits_type traits_type; + + explicit + compare_prefix (C d): d_ (d) {} + + bool + operator() (const K& x, const K& y) const + { + return compare (x.c_str (), x.size (), y.c_str (), y.size ()) < 0; + } + + // Note: doesn't check for k.size () being at least p.size (). + // + bool + prefix (const K& p, const K& k) const + { + size_type pn (p.size ()); + return compare ( + p.c_str (), pn, k.c_str (), pn == k.size () ? pn : pn + 1) == 0; + } + + int + compare (const C* x, size_type xn, + const C* y, size_type yn) const + { + size_type n (std::min (xn, yn)); + int r (traits_type::compare (x, y, n)); + + if (r == 0) + { + // Pretend there is the delimiter characters at the end of the + // shorter string. + // + char xc (xn > n ? x[n] : (xn++, d_)); + char yc (yn > n ? y[n] : (yn++, d_)); + r = traits_type::compare (&xc, &yc, 1); + + // If we are still equal, then compare the lengths. + // + if (r == 0) + r = (xn == yn ? 0 : (xn < yn ? -1 : 1)); + } + + return r; + } + + private: + C d_; + }; + + // A map of hierarchical "paths", e.g., 'foo.bar' or 'foo/bar' with + // the ability to retrieve a range of entries that have a specific + // prefix. The '.' and '/' above are the delimiter characters. + // + // Implementation-wise, the idea is to pretend that each key ends + // with the delimiter. This way we automatically avoid matching + // 'foobar' as having a prefix 'foo'. + // + template + struct prefix_map_common: M + { + typedef M map_type; + typedef typename map_type::key_type key_type; + typedef typename map_type::value_type value_type; + typedef typename map_type::key_compare compare_type; + typedef typename compare_type::char_type char_type; + + typedef typename map_type::iterator iterator; + typedef typename map_type::const_iterator const_iterator; + + explicit + prefix_map_common (char_type delimiter) + : map_type (compare_type (delimiter)) {} + + prefix_map_common (std::initializer_list init, + char_type delimiter) + : map_type (std::move (init), compare_type (delimiter)) {} + + std::pair + find (const key_type&); + + std::pair + find (const key_type&) const; + }; + + template ::char_type D = 0> + struct prefix_map_impl: prefix_map_common + { + typedef typename prefix_map_common::value_type value_type; + + prefix_map_impl (): prefix_map_common (D) {} + prefix_map_impl (std::initializer_list init) + : prefix_map_common (std::move (init), D) {} + }; + + template + struct prefix_map_impl: prefix_map_common + { + using prefix_map_common::prefix_map_common; + }; + + template ::char_type D = 0> + using prefix_map = prefix_map_impl>, D>; + + template ::char_type D = 0> + using prefix_multimap = + prefix_map_impl>, D>; +} + +#include + +#endif // BUILD_PREFIX_MAP diff --git a/build/prefix-map.txx b/build/prefix-map.txx new file mode 100644 index 0000000..0da911d --- /dev/null +++ b/build/prefix-map.txx @@ -0,0 +1,42 @@ +// file : build/prefix-map.txx -*- C++ -*- +// copyright : Copyright (c) 2014-2015 Code Synthesis Tools CC +// license : MIT; see accompanying LICENSE file + +namespace build +{ + template + auto prefix_map_common:: + find (const key_type& k) -> std::pair + { + std::pair r; + r.first = this->lower_bound (k); + + for (r.second = r.first; + r.second != this->end (); + ++r.second) + { + if (!this->key_comp ().prefix (k, r.second->first)) + break; + } + + return r; + } + + template + auto prefix_map_common:: + find (const key_type& k) const -> std::pair + { + std::pair r; + r.first = this->lower_bound (k); + + for (r.second = r.first; + r.second != this->end (); + ++r.second) + { + if (!this->key_comp ().prefix (k, r.second->first)) + break; + } + + return r; + } +} diff --git a/build/prefix_map b/build/prefix_map deleted file mode 100644 index f911d26..0000000 --- a/build/prefix_map +++ /dev/null @@ -1,140 +0,0 @@ -// file : build/prefix_map -*- C++ -*- -// copyright : Copyright (c) 2014-2015 Code Synthesis Tools CC -// license : MIT; see accompanying LICENSE file - -#ifndef BUILD_PREFIX_MAP -#define BUILD_PREFIX_MAP - -#include -#include -#include // move() -#include // min() - -namespace build -{ - template - struct compare_prefix; - - template - struct compare_prefix> - { - typedef std::basic_string K; - - typedef C char_type; - typedef typename K::size_type size_type; - typedef typename K::traits_type traits_type; - - explicit - compare_prefix (C d): d_ (d) {} - - bool - operator() (const K& x, const K& y) const - { - return compare (x.c_str (), x.size (), y.c_str (), y.size ()) < 0; - } - - // Note: doesn't check for k.size () being at least p.size (). - // - bool - prefix (const K& p, const K& k) const - { - size_type pn (p.size ()); - return compare ( - p.c_str (), pn, k.c_str (), pn == k.size () ? pn : pn + 1) == 0; - } - - int - compare (const C* x, size_type xn, - const C* y, size_type yn) const - { - size_type n (std::min (xn, yn)); - int r (traits_type::compare (x, y, n)); - - if (r == 0) - { - // Pretend there is the delimiter characters at the end of the - // shorter string. - // - char xc (xn > n ? x[n] : (xn++, d_)); - char yc (yn > n ? y[n] : (yn++, d_)); - r = traits_type::compare (&xc, &yc, 1); - - // If we are still equal, then compare the lengths. - // - if (r == 0) - r = (xn == yn ? 0 : (xn < yn ? -1 : 1)); - } - - return r; - } - - private: - C d_; - }; - - // A map of hierarchical "paths", e.g., 'foo.bar' or 'foo/bar' with - // the ability to retrieve a range of entries that have a specific - // prefix. The '.' and '/' above are the delimiter characters. - // - // Implementation-wise, the idea is to pretend that each key ends - // with the delimiter. This way we automatically avoid matching - // 'foobar' as having a prefix 'foo'. - // - template - struct prefix_map_common: M - { - typedef M map_type; - typedef typename map_type::key_type key_type; - typedef typename map_type::value_type value_type; - typedef typename map_type::key_compare compare_type; - typedef typename compare_type::char_type char_type; - - typedef typename map_type::iterator iterator; - typedef typename map_type::const_iterator const_iterator; - - explicit - prefix_map_common (char_type delimiter) - : map_type (compare_type (delimiter)) {} - - prefix_map_common (std::initializer_list init, - char_type delimiter) - : map_type (std::move (init), compare_type (delimiter)) {} - - std::pair - find (const key_type&); - - std::pair - find (const key_type&) const; - }; - - template ::char_type D = 0> - struct prefix_map_impl: prefix_map_common - { - typedef typename prefix_map_common::value_type value_type; - - prefix_map_impl (): prefix_map_common (D) {} - prefix_map_impl (std::initializer_list init) - : prefix_map_common (std::move (init), D) {} - }; - - template - struct prefix_map_impl: prefix_map_common - { - using prefix_map_common::prefix_map_common; - }; - - template ::char_type D = 0> - using prefix_map = prefix_map_impl>, D>; - - template ::char_type D = 0> - using prefix_multimap = - prefix_map_impl>, D>; -} - -#include - -#endif // BUILD_PREFIX_MAP diff --git a/build/prefix_map.txx b/build/prefix_map.txx deleted file mode 100644 index 91f8e0a..0000000 --- a/build/prefix_map.txx +++ /dev/null @@ -1,42 +0,0 @@ -// file : build/prefix_map.txx -*- C++ -*- -// copyright : Copyright (c) 2014-2015 Code Synthesis Tools CC -// license : MIT; see accompanying LICENSE file - -namespace build -{ - template - auto prefix_map_common:: - find (const key_type& k) -> std::pair - { - std::pair r; - r.first = this->lower_bound (k); - - for (r.second = r.first; - r.second != this->end (); - ++r.second) - { - if (!this->key_comp ().prefix (k, r.second->first)) - break; - } - - return r; - } - - template - auto prefix_map_common:: - find (const key_type& k) const -> std::pair - { - std::pair r; - r.first = this->lower_bound (k); - - for (r.second = r.first; - r.second != this->end (); - ++r.second) - { - if (!this->key_comp ().prefix (k, r.second->first)) - break; - } - - return r; - } -} diff --git a/build/rule b/build/rule index 889c94c..cbaac04 100644 --- a/build/rule +++ b/build/rule @@ -11,7 +11,7 @@ #include #include -#include +#include namespace build { -- cgit v1.1