utf8rewind
 All Classes Namespaces Files Functions Typedefs Friends Macros Pages
utf8string.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vector>
4 #include <utf8rewind.h>
5 
6 namespace utf8rewind {
7 
9  class Utf8String
10  {
11 
12  public:
13 
15  class iterator
16  {
17 
18  friend class Utf8String;
19 
20  public:
21 
23  unicode_t operator * () const;
24 
25  private:
26 
27  iterator(const char* start, char* value);
28 
29  private:
30 
31  const char* _start;
32  char* _value;
33 
34  };
35 
36  public:
37 
38  Utf8String();
39  Utf8String(const Utf8String& other);
40  Utf8String(const char* text);
41  Utf8String(const wchar_t* text);
42 
43  Utf8String& operator = (const Utf8String& other);
44  Utf8String& operator = (const char* text);
45  Utf8String& operator = (const wchar_t* text);
46 
48 
56  iterator begin();
57 
59 
67  iterator end();
68 
70 
76  size_t length() const;
77 
79  size_t size() const;
80 
82 
87  void clear();
88 
90  bool empty() const;
91 
93  const char* c_str() const;
94 
95  private:
96 
97  std::vector<char> _buffer;
98  size_t _length;
99 
100  };
101 
102 };
unsigned int unicode_t
Definition: utf8rewind.h:27
Read-only class for stepping through a Utf8String instance.
Definition: utf8string.hpp:15
size_t size() const
Get the size in bytes of the container.
bool empty() const
Check if the string is empty.
unicode_t operator*() const
Get the codepoint the iterator is currently pointing at.
Functions for working with UTF-8 encoded text.
void clear()
Clear the string.
iterator end()
Get an iterator for the end of the string.
Utf8String & operator=(const Utf8String &other)
const char * c_str() const
Get a pointer to the string&#39;s data.
iterator begin()
Get an iterator for the start of the string.
size_t length() const
Get the length in codepoints.
Class for managing UTF-8 encoded text.
Definition: utf8string.hpp:9