本文整理汇总了C++中ObjectOutputStream::writeUTFString方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectOutputStream::writeUTFString方法的具体用法?C++ ObjectOutputStream::writeUTFString怎么用?C++ ObjectOutputStream::writeUTFString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectOutputStream
的用法示例。
在下文中一共展示了ObjectOutputStream::writeUTFString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: write
void LocationInfo::write(ObjectOutputStream& os, Pool& p) const {
if (lineNumber == -1 && fileName == NA && methodName == NA_METHOD) {
os.writeNull(p);
} else {
unsigned char prolog[] = {
0x72,
0x00,
0x21, 0x6F, 0x72, 0x67, 0x2E, 0x61, 0x70, 0x61, 0x63, 0x68, 0x65, 0x2E,
0x6C, 0x6F, 0x67, 0x34, 0x6A, 0x2E, 0x73, 0x70, 0x69, 0x2E, 0x4C, 0x6F,
0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x49, 0x6E, 0x66, 0x6F, 0xED, 0x99,
0xBB, 0xE1, 0x4A, 0x91, 0xA5, 0x7C, 0x02,
0x00,
0x01, 0x4C,
0x00,
0x08, 0x66, 0x75, 0x6C, 0x6C, 0x49, 0x6E, 0x66, 0x6F, 0x74,
0x00,
0x12, 0x4C, 0x6A, 0x61, 0x76, 0x61, 0x2F, 0x6C, 0x61, 0x6E, 0x67, 0x2F,
0x53, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x3B, 0x78, 0x70
};
os.writeProlog("org.apache.log4j.spi.LocationInfo", 2, (char*) prolog, sizeof(prolog), p);
char* line = p.itoa(lineNumber);
//
// construct Java-like fullInfo (replace "::" with ".")
//
std::string fullInfo(methodName);
size_t openParen = fullInfo.find('(');
if (openParen != std::string::npos) {
size_t space = fullInfo.find(' ');
if (space != std::string::npos && space < openParen) {
fullInfo.erase(0, space + 1);
}
}
openParen = fullInfo.find('(');
if (openParen != std::string::npos) {
size_t classSep = fullInfo.rfind("::", openParen);
if (classSep != std::string::npos) {
fullInfo.replace(classSep, 2, ".");
} else {
fullInfo.insert(0, ".");
}
}
fullInfo.append(1, '(');
fullInfo.append(fileName);
fullInfo.append(1, ':');
fullInfo.append(line);
fullInfo.append(1, ')');
os.writeUTFString(fullInfo, p);
}
}