Sync AMTL.
This commit is contained in:
@@ -56,7 +56,7 @@ class AString
|
||||
if (other.length_)
|
||||
set(other.chars_, other.length_);
|
||||
else
|
||||
length_ = 0;
|
||||
length_ = 0;
|
||||
}
|
||||
AString(Moveable<AString> other)
|
||||
: chars_(other->chars_.take()),
|
||||
@@ -106,17 +106,29 @@ class AString
|
||||
return chars()[index];
|
||||
}
|
||||
|
||||
void setVoid() {
|
||||
chars_ = NULL;
|
||||
length_ = kInvalidLength;
|
||||
}
|
||||
|
||||
bool isVoid() const {
|
||||
return length_ == kInvalidLength;
|
||||
}
|
||||
|
||||
size_t length() const {
|
||||
assert(!isVoid());
|
||||
return length_;
|
||||
}
|
||||
|
||||
const char *chars() const {
|
||||
if (!chars_)
|
||||
return "";
|
||||
return isVoid() ? NULL : "";
|
||||
return chars_;
|
||||
}
|
||||
|
||||
private:
|
||||
static const size_t kInvalidLength = (size_t)-1;
|
||||
|
||||
void set(const char *str, size_t length) {
|
||||
chars_ = new char[length + 1];
|
||||
length_ = length;
|
||||
|
||||
Reference in New Issue
Block a user