diff --git a/doc/TODO b/doc/TODO index 41c60a5..59c04d2 100644 --- a/doc/TODO +++ b/doc/TODO @@ -10,7 +10,6 @@ matrix: 2:capability query 2:revision query 1:ability to select specification revision - 1:change password 1:register account 1:device management client: diff --git a/include/raii/string_base.hpp b/include/raii/string_base.hpp index e842dfa..d6728ef 100644 --- a/include/raii/string_base.hpp +++ b/include/raii/string_base.hpp @@ -26,45 +26,6 @@ namespace raii{ class string_expr{}; - class string_base; - - namespace detail{ - std::true_type is_string_helper(string_expr); - std::false_type is_string_helper(...); - template - struct is_string{ - static constexpr bool value = std::is_same()))>::value; - }; - std::true_type is_string_base(string_base*); - std::false_type is_string_base(...); - template - struct is_concrete_string{ - static constexpr bool value = std::is_same::type*>()))>::value; - }; - template - std::true_type is_tuple_helper(std::tuple); - std::false_type is_tuple_helper(...); - template - struct is_tuple{ - static constexpr bool value = std::is_same()))>::value; - }; - - //check for member function 'length' - template - struct has_len{ - template - struct check; - - template - static std::true_type test(check*); - template - static std::false_type test(...); - - static constexpr bool value = std::is_same(0))>::value; - }; - } - - //Base of all RAII strings. Its use is allowing passing of raii strings to functions without knowing the exact type class string_base : public string_expr @@ -166,19 +127,6 @@ namespace raii{ constexpr const Right& right(void)const; }; - template - struct appender - { - private: - Targ& m_targ; - size_t m_pos = 0; - public: - appender(Targ& t); - template - void operator()(const string_cat_expr& str); - void operator()(const string_base& str); - }; - class static_string : public string_base { public: @@ -196,6 +144,54 @@ namespace raii{ static_string& operator=(static_string&&) = delete; }; + + namespace detail{ + std::true_type is_string_helper(string_expr); + std::false_type is_string_helper(...); + template + struct is_string{ + static constexpr bool value = std::is_same()))>::value; + }; + std::true_type is_string_base(string_base*); + std::false_type is_string_base(...); + template + struct is_concrete_string{ + static constexpr bool value = std::is_same::type*>()))>::value; + }; + template + std::true_type is_tuple_helper(std::tuple); + std::false_type is_tuple_helper(...); + template + struct is_tuple{ + static constexpr bool value = std::is_same()))>::value; + }; + + //check for member function 'length' + template + struct has_len{ + template + struct check; + + template + static std::true_type test(check*); + template + static std::false_type test(...); + + static constexpr bool value = std::is_same(0))>::value; + }; + template + struct appender + { + private: + Targ& m_targ; + size_t m_pos = 0; + public: + appender(Targ& t); + template + void operator()(const string_cat_expr& str); + void operator()(const string_base& str); + }; + } } #include "raii/string_base.tpp" diff --git a/include/raii/string_base.tpp b/include/raii/string_base.tpp index 674d20c..1279c60 100644 --- a/include/raii/string_base.tpp +++ b/include/raii/string_base.tpp @@ -177,7 +177,7 @@ namespace raii{ string_intermediary ret(length()); for(size_t i = 0;i < length();++i) ret[i] = 'n'; - appender> append(ret); + detail::appender> append(ret); append(*this); return ret; } @@ -191,20 +191,6 @@ namespace raii{ } - template - appender::appender(Targ& t): m_targ(t){} - template - template - void appender::operator()(const string_cat_expr& str){ - (*this)(str.left()); - (*this)(str.right()); - } - template - void appender::operator()(const string_base& str){ - memcpy(m_targ.get()+m_pos, str.get(), str.length()); - m_pos += str.length(); - } - template constexpr static_string::static_string(const char(&str)[N]): string_base(const_cast(str), N){} @@ -215,6 +201,22 @@ namespace raii{ constexpr static_string::static_string(static_string&& s): string_base(s.m_data, s.m_length){} + namespace detail{ + template + appender::appender(Targ& t): m_targ(t){} + template + template + void appender::operator()(const string_cat_expr& str){ + (*this)(str.left()); + (*this)(str.right()); + } + template + void appender::operator()(const string_base& str){ + memcpy(m_targ.get()+m_pos, str.get(), str.length()); + m_pos += str.length(); + } + } + } //namespace raii #endif