diff --git a/libutils/String16.cpp b/libutils/String16.cpp index 68642d84f..38d483e94 100644 --- a/libutils/String16.cpp +++ b/libutils/String16.cpp @@ -26,7 +26,7 @@ namespace android { static const StaticString16 emptyString(u""); static inline char16_t* getEmptyString() { - return const_cast(emptyString.string()); + return const_cast(emptyString.c_str()); } // --------------------------------------------------------------------------- @@ -112,10 +112,7 @@ String16::String16(const char16_t* o) : mString(allocFromUTF16(o, strlen16(o))) String16::String16(const char16_t* o, size_t len) : mString(allocFromUTF16(o, len)) {} -String16::String16(const String8& o) - : mString(allocFromUTF8(o.string(), o.size())) -{ -} +String16::String16(const String8& o) : mString(allocFromUTF8(o.c_str(), o.size())) {} String16::String16(const char* o) : mString(allocFromUTF8(o, strlen(o))) @@ -173,7 +170,7 @@ status_t String16::setTo(const String16& other, size_t len, size_t begin) LOG_ALWAYS_FATAL("Not implemented"); } - return setTo(other.string()+begin, len); + return setTo(other.c_str() + begin, len); } status_t String16::setTo(const char16_t* other) @@ -200,7 +197,7 @@ status_t String16::setTo(const char16_t* other, size_t len) } status_t String16::append(const String16& other) { - return append(other.string(), other.size()); + return append(other.c_str(), other.size()); } status_t String16::append(const char16_t* chrs, size_t otherLen) { @@ -286,7 +283,7 @@ bool String16::startsWith(const String16& prefix) const { const size_t ps = prefix.size(); if (ps > size()) return false; - return strzcmp16(mString, ps, prefix.string(), ps) == 0; + return strzcmp16(mString, ps, prefix.c_str(), ps) == 0; } bool String16::startsWith(const char16_t* prefix) const diff --git a/libutils/String8.cpp b/libutils/String8.cpp index 8d312b57c..79b7edfe9 100644 --- a/libutils/String8.cpp +++ b/libutils/String8.cpp @@ -150,10 +150,7 @@ String8::String8(const char* o, size_t len) } } -String8::String8(const String16& o) - : mString(allocFromUTF16(o.string(), o.size())) -{ -} +String8::String8(const String16& o) : mString(allocFromUTF16(o.c_str(), o.size())) {} String8::String8(const char16_t* o) : mString(allocFromUTF16(o, strlen16(o))) @@ -267,7 +264,7 @@ status_t String8::append(const String8& other) return OK; } - return real_append(other.string(), otherLen); + return real_append(other.c_str(), otherLen); } status_t String8::append(const char* other) diff --git a/libutils/include/utils/String16.h b/libutils/include/utils/String16.h index 3ef56a3cf..d719aeaaa 100644 --- a/libutils/include/utils/String16.h +++ b/libutils/include/utils/String16.h @@ -53,6 +53,7 @@ public: ~String16(); + inline const char16_t* c_str() const; inline const char16_t* string() const; private: @@ -234,6 +235,11 @@ inline int strictly_order_type(const String16& lhs, const String16& rhs) return compare_type(lhs, rhs) < 0; } +inline const char16_t* String16::c_str() const +{ + return mString; +} + inline const char16_t* String16::string() const { return mString; @@ -241,7 +247,7 @@ inline const char16_t* String16::string() const inline std::string String16::std_string(const String16& str) { - return std::string(String8(str).string()); + return std::string(String8(str).c_str()); } inline String16& String16::operator=(const String16& other) diff --git a/libutils/include/utils/String8.h b/libutils/include/utils/String8.h index 8b2dcf9a0..e58f1a5d1 100644 --- a/libutils/include/utils/String8.h +++ b/libutils/include/utils/String8.h @@ -193,14 +193,14 @@ public: * replaces whatever was there before. */ String8& appendPath(const char* leaf); - String8& appendPath(const String8& leaf) { return appendPath(leaf.string()); } + String8& appendPath(const String8& leaf) { return appendPath(leaf.c_str()); } /* * Like appendPath(), but does not affect this string. Returns a new one instead. */ String8 appendPathCopy(const char* leaf) const { String8 p(*this); p.appendPath(leaf); return p; } - String8 appendPathCopy(const String8& leaf) const { return appendPathCopy(leaf.string()); } + String8 appendPathCopy(const String8& leaf) const { return appendPathCopy(leaf.c_str()); } /* * Converts all separators in this string to /, the default path separator. @@ -255,7 +255,7 @@ inline const char* String8::string() const inline std::string String8::std_string(const String8& str) { - return std::string(str.string()); + return std::string(str.c_str()); } inline size_t String8::size() const