зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1294940 - Part 1: Add ConstUTF8CharsZ class for const UTF8 string. r=jwalden
--HG-- extra : rebase_source : 6f8b433038c1db36902aaeba1c7f5694bf5900a5
This commit is contained in:
Родитель
a60af5b6e9
Коммит
fc1c230284
|
@ -109,6 +109,33 @@ class UTF8CharsZ : public mozilla::RangedPtr<unsigned char>
|
|||
char* c_str() { return reinterpret_cast<char*>(get()); }
|
||||
};
|
||||
|
||||
/*
|
||||
* A wrapper for a "const char*" that is encoded using UTF-8.
|
||||
* This class does not manage ownership of the data; that is left
|
||||
* to others. This differs from UTF8CharsZ in that the chars are
|
||||
* const and it allows assignment.
|
||||
*/
|
||||
class ConstUTF8CharsZ
|
||||
{
|
||||
const char* data_;
|
||||
|
||||
public:
|
||||
ConstUTF8CharsZ() : data_(nullptr)
|
||||
{}
|
||||
|
||||
ConstUTF8CharsZ(const char* aBytes, size_t aLength)
|
||||
: data_(aBytes)
|
||||
{
|
||||
MOZ_ASSERT(aBytes[aLength] == '\0');
|
||||
}
|
||||
|
||||
const void* get() const { return data_; }
|
||||
|
||||
const char* c_str() const { return data_; }
|
||||
|
||||
explicit operator bool() const { return data_ != nullptr; }
|
||||
};
|
||||
|
||||
/*
|
||||
* SpiderMonkey uses a 2-byte character representation: it is a
|
||||
* 2-byte-at-a-time view of a UTF-16 byte stream. This is similar to UCS-2,
|
||||
|
|
Загрузка…
Ссылка в новой задаче