| 176 | |
| 177 | template< typename String > |
| 178 | class basic_custom_string |
| 179 | { |
| 180 | public: |
| 181 | typedef String string_type; |
| 182 | typedef typename string_type::size_type size_type; |
| 183 | typedef typename string_type::difference_type difference_type; |
| 184 | typedef typename string_type::value_type value_type; |
| 185 | typedef typename string_type::reference reference; |
| 186 | typedef typename string_type::const_reference const_reference; |
| 187 | typedef typename string_type::pointer pointer; |
| 188 | typedef typename string_type::const_pointer const_pointer; |
| 189 | typedef typename string_type::iterator iterator; |
| 190 | typedef typename string_type::const_iterator const_iterator; |
| 191 | |
| 192 | private: |
| 193 | string_type m_str; |
| 194 | |
| 195 | public: |
| 196 | basic_custom_string() {} |
| 197 | explicit basic_custom_string(const_pointer str) : m_str(str) {} |
| 198 | explicit basic_custom_string(string_type const& str) : m_str(str) {} |
| 199 | template< typename OtherChar > |
| 200 | explicit basic_custom_string(const OtherChar* str) |
| 201 | { |
| 202 | // Do a simple character code conversion; only valid for ASCII characters |
| 203 | while (*str != static_cast< OtherChar >(0)) |
| 204 | { |
| 205 | m_str.push_back(static_cast< value_type >(*str)); |
| 206 | ++str; |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | bool empty() const { return m_str.empty(); } |
| 211 | size_type size() const { return m_str.size(); } |
| 212 | |
| 213 | const_pointer data() const { return m_str.data(); } |
| 214 | const_pointer c_str() const { return m_str.c_str(); } |
| 215 | |
| 216 | iterator begin() { return m_str.begin(); } |
| 217 | const_iterator begin() const { return m_str.begin(); } |
| 218 | iterator end() { return m_str.end(); } |
| 219 | const_iterator end() const { return m_str.end(); } |
| 220 | |
| 221 | operator string_type() const { return m_str; } |
| 222 | }; |
| 223 | |
| 224 | typedef basic_custom_string< std::string > custom_string; |
| 225 | typedef basic_custom_string< std::wstring > wcustom_string; |
nothing calls this directly
no outgoing calls
no test coverage detected