Sync AMTL.

This commit is contained in:
Arkshine
2014-07-03 11:26:50 +02:00
parent 006e6e967a
commit de73007922
10 changed files with 403 additions and 71 deletions

View File

@@ -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;