本文整理汇总了C++中StringBuffer::Reserve方法的典型用法代码示例。如果您正苦于以下问题:C++ StringBuffer::Reserve方法的具体用法?C++ StringBuffer::Reserve怎么用?C++ StringBuffer::Reserve使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringBuffer
的用法示例。
在下文中一共展示了StringBuffer::Reserve方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadTopic0
Topic ReadTopic0(const char *text)
{
Topic topic;
CParser p(text);
try {
if(p.Id("topic")) {
topic.title = p.ReadString();
p.Char(';');
topic.text = p.GetPtr();
return topic;
}
while(!p.IsEof()) {
if(p.Id("TITLE")) {
p.PassChar('(');
topic.title = p.ReadString();
p.PassChar(')');
}
else
if(p.Id("REF")) {
p.PassChar('(');
p.ReadString();
p.PassChar(')');
}
else
if(p.Id("TOPIC_TEXT")) {
p.PassChar('(');
topic.text << p.ReadString();
p.PassChar(')');
}
else
if(p.Id("COMPRESSED")) {
StringBuffer b;
b.Reserve(1024);
while(p.IsInt()) {
b.Cat(p.ReadInt());
p.PassChar(',');
}
topic.text = b;
}
else {
topic.text << p.GetPtr();
break;
}
}
}
catch(CParser::Error e) {
topic.text = String::GetVoid();
topic.title = e;
}
return topic;
}
示例2: NaturalDeQtf
String NaturalDeQtf(const char *s) {
StringBuffer r;
r.Reserve(256);
bool cm = false;
while(*s) {
if(*s == ' ')
r.Cat(cm ? ' ' : '_');
else {
if((byte)*s > ' ' && !IsDigit(*s) && !IsAlpha(*s) && (byte)*s < 128)
r.Cat('`');
r.Cat(*s);
if(*s == ',')
cm = true;
else
cm = false;
}
s++;
}
return r;
}
示例3: UnpackParts
//.........这里部分代码省略.........
case CAPITALSS:
format.capitals = chrstyle.capitals;
break;
case DASHED0:
format.dashed = false;
break;
case DASHED1:
format.dashed = true;
break;
case DASHEDS:
format.dashed = chrstyle.dashed;
break;
case SSCRIPT:
format.sscript = in.Get();
if(format.sscript == 3)
format.sscript = chrstyle.sscript;
break;
case FACE:
c = in.Get16();
format.Face(c == 0xffff ? chrstyle.GetFace() : c);
break;
case HEIGHT:
c = in.Get16();
format.Height(c == 0xffff ? chrstyle.GetHeight() : c);
break;
case LINK:
in % format.link;
break;
case INDEXENTRY:
in % format.indexentry;
break;
case INK:
in % format.ink;
break;
case PAPER:
in % format.paper;
break;
case LANGUAGE:
format.language = in.Get32();
break;
case EXT:
switch(in.Get()) {
case NONAA0:
format.NonAntiAliased(false);
break;
case NONAA1:
format.NonAntiAliased(true);
break;
case NONAAS:
format.NonAntiAliased(chrstyle.IsNonAntiAliased());
break;
}
}
while((c = in.Term()) < 31 && c != 9 && c != FIELD && c >= 0);
if(part.Top().text.GetLength())
part.Add();
part.Top().format = format;
}
else
if(in.Term() == FIELD) {
RichPara::Format pformat = format;
if(part.Top().text.GetLength()) {
part.Add();
part.Top().format = pformat;
}
in.Get();
Part& p = part.Top();
String id;
in % id;
p.field = id;
in % p.fieldparam;
String s;
in % s;
StringStream sn(s);
UnpackParts(sn, chrstyle, p.fieldpart, obj, oi);
part.Add();
part.Top().format = format = pformat;
}
else
if(in.Term() == OBJECT) {
if(part.Top().text.GetLength()) {
part.Add();
part.Top().format = format;
}
part.Top().object = obj[oi++];
part.Top().format = format;
part.Add();
part.Top().format = format;
in.Get();
}
else {
StringBuffer b;
b.Reserve(512);
while(in.Term() >= 32 || in.Term() == 9)
b.Cat(in.Get());
part.Top().text.Cat(FromUtf8(~b));
}
if(part.Top().text.GetLength() == 0 && part.Top().IsText())
part.Drop();
}