本文整理汇总了C++中UTF8::ptr方法的典型用法代码示例。如果您正苦于以下问题:C++ UTF8::ptr方法的具体用法?C++ UTF8::ptr怎么用?C++ UTF8::ptr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UTF8
的用法示例。
在下文中一共展示了UTF8::ptr方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: generateJSONString
static void generateJSONString(Error& error, const HOutputStream& out, const UTF8& s)
{
UTF16Buffer sb(2 + s.length() + 1);
sb << '"';
if (error)
return;
for (const Chr8* p = s.ptr(); (*p) != '\0'; p++)
{
Chr8 c = *p;
switch (c)
{
case '\"' : sb << '\\' << '\"'; break;
case '\\' : sb << '\\' << '\\'; break;
case '/' : sb << '\\' << '/'; break;
case '\b' : sb << '\\' << 'b'; break;
case '\f' : sb << '\\' << 'f'; break;
case '\n' : sb << '\\' << 'n'; break;
case '\r' : sb << '\\' << 'r'; break;
case '\t' : sb << '\\' << 't'; break;
default:
if (c >= 0x20)
{
sb << c;
}
else
{
sb << UTF8("\\u00") << UTF8::format("%.2X",UInt32(c));
}
break;
}
}
sb << '"';
out->twrite(error, UTF8(sb));
};
示例2: wmain
int wmain(int argc, Chr16** argv)
{
Lock::setupGlobalLock();
Error error;
LogStdout log;
class Fatal {};
try
{
loginfo("Tomazos Resource Compiler 1.0 (c) Andrew Tomazos 2009");
if (argc != 3)
{
error.what(L"Usage: ResourceCompiler <ResourceDir> <Out.cpp>");
throw Fatal();
}
UTF16 sSourceDirPath = argv[1];
UTF16 sOutPath = argv[2];
Path sourceDir(error, sSourceDirPath);
if (error)
throw Fatal();
UTF16 sFullSourceDirPath = UTF16(sourceDir);
if (!sFullSourceDirPath.endsWith(L"\\"))
sFullSourceDirPath = sFullSourceDirPath + L"\\";
UTF16List fps;
sourceDir.walk(ResourceCompilerWalker(fps));
loginfo("Found %d files", fps.size());
TreeMap<UTF16, Blob> data;
{
UTF16List::Iterator it(fps);
UTF16 sFullFilePath;
while (it(sFullFilePath))
{
if (!sFullFilePath.startsWith(sFullSourceDirPath))
{
Check();
throw Fatal();
}
UTF16 sRelFilePath = sFullFilePath.suffix(sFullFilePath.length() - sFullSourceDirPath.length());
Path file(error, sFullFilePath);
if (error)
throw Fatal();
HInputStream fis;
file.readFile(error, fis);
if (error)
throw Fatal();
Blob sFileContent = fis->slurp(error);
if (error)
throw Fatal();
loginfo("Found %s (%d bytes)", sRelFilePath.ptr(), sFileContent.length());
data.add(sRelFilePath, sFileContent);
}
}
Path outPath(error, sOutPath);
if (error)
throw Fatal();
HOutputStream hOut;
outPath.overwriteFile(error, hOut);
if (error)
throw Fatal();
#define ResLine(x) { hOut->twrite(error, UTF8(x)); if (error) throw Fatal(); hOut->twrite(error, UTF8("\r\n")); if (error) throw Fatal(); }
#define ResLineF(...) { ResLine(UTF8::format(__VA_ARGS__)); }
ResLine("#include \"Runtime.h\"");
ResLine("");
ResLine("void ResourceManager::setup()");
ResLine("{");
{
TreeMap<UTF16, Blob>::Iterator it(data);
UTF16 sPath;
Blob bData;
int iCount = 0;
//.........这里部分代码省略.........