This is a string holding UTF-8 characters. Does not allow the value more than 0x10FFFF, which is not valid unicode codepoint.
| 37 | //! This is a string holding UTF-8 characters. Does not allow the value more |
| 38 | // than 0x10FFFF, which is not valid unicode codepoint. |
| 39 | class String8 |
| 40 | { |
| 41 | public: |
| 42 | /* use String8(StaticLinkage) if you're statically linking against |
| 43 | * libutils and declaring an empty static String8, e.g.: |
| 44 | * |
| 45 | * static String8 sAStaticEmptyString(String8::kEmptyString); |
| 46 | * static String8 sAnotherStaticEmptyString(sAStaticEmptyString); |
| 47 | */ |
| 48 | enum StaticLinkage { kEmptyString }; |
| 49 | |
| 50 | String8(); |
| 51 | explicit String8(StaticLinkage); |
| 52 | String8(const String8& o); |
| 53 | explicit String8(const char* o); |
| 54 | explicit String8(const char* o, size_t numChars); |
| 55 | |
| 56 | explicit String8(const String16& o); |
| 57 | explicit String8(const char16_t* o); |
| 58 | explicit String8(const char16_t* o, size_t numChars); |
| 59 | explicit String8(const char32_t* o); |
| 60 | explicit String8(const char32_t* o, size_t numChars); |
| 61 | ~String8(); |
| 62 | |
| 63 | static inline const String8 empty(); |
| 64 | |
| 65 | static String8 format(const char* fmt, ...) __attribute__((format (printf, 1, 2))); |
| 66 | static String8 formatV(const char* fmt, va_list args); |
| 67 | |
| 68 | inline const char* c_str() const; |
| 69 | inline const char* string() const; |
| 70 | |
| 71 | private: |
| 72 | static inline std::string std_string(const String8& str); |
| 73 | public: |
| 74 | |
| 75 | inline size_t size() const; |
| 76 | inline size_t bytes() const; |
| 77 | inline bool isEmpty() const; |
| 78 | |
| 79 | size_t length() const; |
| 80 | |
| 81 | void clear(); |
| 82 | |
| 83 | void setTo(const String8& other); |
| 84 | status_t setTo(const char* other); |
| 85 | status_t setTo(const char* other, size_t numChars); |
| 86 | status_t setTo(const char16_t* other, size_t numChars); |
| 87 | status_t setTo(const char32_t* other, |
| 88 | size_t length); |
| 89 | |
| 90 | status_t append(const String8& other); |
| 91 | status_t append(const char* other); |
| 92 | status_t append(const char* other, size_t numChars); |
| 93 | |
| 94 | status_t appendFormat(const char* fmt, ...) |
| 95 | __attribute__((format (printf, 2, 3))); |
| 96 | status_t appendFormatV(const char* fmt, va_list args); |