From 5a90d2b671f01f29043ab82f909440de0abfa362 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Mon, 13 Jan 2003 04:46:50 +0000 Subject: otk using ustring for shit that draws. expended its inferface yet some more. --- otk/ustring.hh | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) (limited to 'otk/ustring.hh') diff --git a/otk/ustring.hh b/otk/ustring.hh index 02111a33..ef94440c 100644 --- a/otk/ustring.hh +++ b/otk/ustring.hh @@ -7,6 +7,7 @@ */ extern "C" { +/* #ifdef HAVE_STDINT_H # include #else @@ -14,17 +15,20 @@ extern "C" { # include # endif #endif +*/ } #include namespace otk { +/* #ifdef HAVE_STDINT_H typedef uint32_t unichar; #else typedef u_int32_t unichar; #endif +*/ #ifndef DOXYGEN_IGNORE @@ -40,6 +44,8 @@ const char g_utf8_skip[256] = { 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,6,6,1,1 }; +#endif // DOXYGEN_IGNORE + //! The iterator type for ustring /*! Note this is not a random access iterator but a bidirectional one, since all @@ -51,20 +57,22 @@ const char g_utf8_skip[256] = { write operation would invalidate all other iterators pointing into the same string. */ +/* template class ustring_Iterator { public: typedef std::bidirectional_iterator_tag iterator_category; - typedef unichar value_type; + //typedef unichar value_type; typedef std::string::difference_type difference_type; - typedef value_type reference; + //typedef value_type reference; typedef void pointer; inline ustring_Iterator() {} inline ustring_Iterator(const ustring_Iterator& other) : _pos(other.base()) {} + inline value_type operator*() const { // get a unicode character from the iterator's position @@ -88,6 +96,7 @@ public: return result; } + inline ustring_Iterator & operator++() { pos_ += g_utf8_skip[static_cast(*pos_)]; return *this; @@ -103,8 +112,7 @@ public: private: T _pos; }; - -#endif // DOXYGEN_IGNORE +*/ //! This class provides a simple wrapper to a std::string that can be encoded //! as UTF-8. The ustring::utf() member specifies if the given string is UTF-8 @@ -127,12 +135,12 @@ public: typedef std::string::size_type size_type; typedef std::string::difference_type difference_type; - typedef unichar value_type; - typedef unichar & reference; - typedef const unichar & const_reference; + //typedef unichar value_type; + //typedef unichar & reference; + //typedef const unichar & const_reference; - typedef ustring_Iterator iterator; - typedef ustring_Iterator const_iterator; + //typedef ustring_Iterator iterator; + //typedef ustring_Iterator const_iterator; static const size_type npos = std::string::npos; @@ -159,6 +167,15 @@ public: ustring::size_type capacity() const; ustring::size_type max_size() const; + // erase substrings + + void clear(); + ustring& erase(size_type i, size_type n=npos); + + // change the string's size + + void resize(size_type n, char c='\0'); + // internal data const char* data() const; -- cgit v1.2.3