lean cpp library
A lean C++ library providing efficient utility classes for high-performance C++ applications.
string_traits.h
00001 /*****************************************************/
00002 /* lean Strings                 (c) Tobias Zirr 2011 */
00003 /*****************************************************/
00004 
00005 #ifndef LEAN_STRINGS_STRING_TRAITS
00006 #define LEAN_STRINGS_STRING_TRAITS
00007 
00008 #include "../lean.h"
00009 
00010 namespace lean
00011 {
00012 namespace strings
00013 {
00014 
00016 template <class String>
00017 struct string_traits
00018 {
00020     typedef String string_type;
00022     typedef typename string_type::value_type value_type;
00024     typedef typename string_type::iterator iterator;
00026     typedef typename string_type::const_iterator const_iterator;
00028     typedef typename string_type::size_type size_type;
00029     
00031     template <class Iterator>
00032     static LEAN_INLINE string_type construct(Iterator begin, Iterator end)
00033     {
00034         return string_type(begin, end);
00035     }
00037     template <class Iterator>
00038     static LEAN_INLINE void assign(string_type &str, Iterator begin, Iterator end)
00039     {
00040         str.assign(begin, end);
00041     }
00042 
00044     static LEAN_INLINE void resize(string_type &str, size_type size)
00045     {
00046         str.resize(size);
00047     }
00049     static LEAN_INLINE void reserve(string_type &str, size_type size)
00050     {
00051         str.reserve(size);
00052     }
00053 
00055     static LEAN_INLINE void erase(string_type &str, iterator begin, iterator end)
00056     {
00057         str.erase(begin, end);
00058     }
00059 
00061     static LEAN_INLINE bool empty(const string_type &str)
00062     {
00063         return str.empty();
00064     }
00066     static LEAN_INLINE size_type size(const string_type &str)
00067     {
00068         return str.size();
00069     }
00070 
00072     static LEAN_INLINE iterator begin(string_type &str)
00073     {
00074         return str.begin();
00075     }
00077     static LEAN_INLINE const_iterator begin(const string_type &str)
00078     {
00079         return str.begin();
00080     }
00082     static LEAN_INLINE iterator end(string_type &str)
00083     {
00084         return str.end();
00085     }
00087     static LEAN_INLINE const_iterator end(const string_type &str)
00088     {
00089         return str.end();
00090     }
00091 };
00092 
00093 } // namespace
00094 
00095 using strings::string_traits;
00096 
00097 } // namespace
00098 
00099 #endif