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); } }