本文整理汇总了C++中common::String::firstChar方法的典型用法代码示例。如果您正苦于以下问题:C++ String::firstChar方法的具体用法?C++ String::firstChar怎么用?C++ String::firstChar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::String
的用法示例。
在下文中一共展示了String::firstChar方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
Stxt::Stxt(Common::SeekableSubReadStreamEndian &textStream) {
// TODO: Side effects on textStream make this a little hard to understand in context?
uint32 unk1 = textStream.readUint32();
uint32 strLen = textStream.readUint32();
uint32 dataLen = textStream.readUint32();
Common::String text;
for (uint32 i = 0; i < strLen; i++) {
byte ch = textStream.readByte();
if (ch == 0x0d) {
ch = '\n';
}
text += ch;
}
debugC(3, kDebugText, "Stxt init: unk1: %d strLen: %d dataLen: %d textlen: %u", unk1, strLen, dataLen, text.size());
if (strLen < 200)
debugC(3, kDebugText, "text: '%s'", text.c_str());
uint16 formattingCount = textStream.readUint16();
uint32 prevPos = 0;
while (formattingCount) {
uint32 formatStartOffset = textStream.readUint32();
uint16 unk1f = textStream.readUint16();
uint16 unk2f = textStream.readUint16();
_fontId = textStream.readUint16();
_textSlant = textStream.readByte();
byte unk3f = textStream.readByte();
_fontSize = textStream.readUint16();
_palinfo1 = textStream.readUint16();
_palinfo2 = textStream.readUint16();
_palinfo3 = textStream.readUint16();
debugC(3, kDebugText, "Stxt init: formattingCount: %u, formatStartOffset: %d, unk1: %d unk2: %d, fontId: %d, textSlant: %d",
formattingCount, formatStartOffset, unk1f, unk2f, _fontId, _textSlant);
debugC(3, kDebugText, " unk3: %d, fontSize: %d, p0: %x p1: %x p2: %x", unk3f, _fontSize, _palinfo1, _palinfo2, _palinfo3);
assert(prevPos <= formatStartOffset); // If this is triggered, we have to implement sorting
while (prevPos != formatStartOffset) {
char f = text.firstChar();
_ftext += text.firstChar();
text.deleteChar(0);
if (f == '\001') // Insert two \001s as a replacement
_ftext += '\001';
prevPos++;
debugCN(4, kDebugText, "%c", f);
}
debugCN(4, kDebugText, "*");
_ftext += Common::String::format("\001\015%c%c%c%c%c%c%c%c%c%c%c%c",
(_fontId >> 8) & 0xff, _fontId & 0xff,
_textSlant & 0xff, unk3f & 0xff,
(_fontSize >> 8) & 0xff, _fontSize & 0xff,
(_palinfo1 >> 8) & 0xff, _palinfo1 & 0xff,
(_palinfo2 >> 8) & 0xff, _palinfo2 & 0xff,
(_palinfo3 >> 8) & 0xff, _palinfo3 & 0xff);
formattingCount--;
}
debugC(4, kDebugText, "%s", text.c_str());
_ftext += text;
}