本文整理汇总了C++中StringData::mutableSlice方法的典型用法代码示例。如果您正苦于以下问题:C++ StringData::mutableSlice方法的具体用法?C++ StringData::mutableSlice怎么用?C++ StringData::mutableSlice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringData
的用法示例。
在下文中一共展示了StringData::mutableSlice方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: unserialize
void String::unserialize(VariableUnserializer *uns,
char delimiter0 /* = '"' */,
char delimiter1 /* = '"' */) {
int64_t size = uns->readInt();
if (size >= RuntimeOption::MaxSerializedStringSize) {
throw Exception("Size of serialized string (%d) exceeds max", int(size));
}
if (size < 0) {
throw Exception("Size of serialized string (%d) must not be negative",
int(size));
}
char ch = uns->readChar();
if (ch != ':') {
throw Exception("Expected ':' but got '%c'", ch);
}
ch = uns->readChar();
if (ch != delimiter0) {
throw Exception("Expected '%c' but got '%c'", delimiter0, ch);
}
StringData *px = NEW(StringData)(int(size));
MutableSlice buf = px->mutableSlice();
assert(size <= buf.len);
uns->read(buf.ptr, size);
px->setSize(size);
if (m_px) decRefStr(m_px);
m_px = px;
px->setRefCount(1);
ch = uns->readChar();
if (ch != delimiter1) {
throw Exception("Expected '%c' but got '%c'", delimiter1, ch);
}
}