本文整理汇总了C++中str::Str::Append方法的典型用法代码示例。如果您正苦于以下问题:C++ Str::Append方法的具体用法?C++ Str::Append怎么用?C++ Str::Append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类str::Str
的用法示例。
在下文中一共展示了Str::Append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AppendVal
static void AppendVal(const char *val, char escapeChar, bool compact, str::Str<char>& res)
{
const char *start = val;
const char *s = start;
char escaped = 0;
while (*s) {
char c = *s++;
if (escapeChar == c)
escaped = escapeChar;
else if (']' == c)
escaped = ']';
else if ('[' == c)
escaped = '[';
else if ('\n' == c)
escaped = 'n';
else if ('\r' == c)
escaped = 'r';
if (0 == escaped)
continue;
size_t len = s - start - 1;
res.Append(start, len);
res.Append(escapeChar);
res.Append(escaped);
start = s;
escaped = 0;
}
size_t len = s - start;
res.Append(start, len);
if (!compact)
res.Append(NL);
}
示例2: GetThreadCallstack
void GetThreadCallstack(str::Str<char>& s, DWORD threadId)
{
if (threadId == GetCurrentThreadId())
return;
s.AppendFmt("\r\nThread: %x\r\n", threadId);
DWORD access = THREAD_GET_CONTEXT | THREAD_QUERY_INFORMATION | THREAD_SUSPEND_RESUME;
HANDLE hThread = OpenThread(access, false, threadId);
if (!hThread) {
s.Append("Failed to OpenThread()\r\n");
return;
}
DWORD res = SuspendThread(hThread);
if (-1 == res) {
s.Append("Failed to SuspendThread()\r\n");
} else {
CONTEXT ctx = { 0 };
ctx.ContextFlags = CONTEXT_FULL;
BOOL ok = GetThreadContext(hThread, &ctx);
if (ok)
GetCallstack(s, ctx, hThread);
else
s.Append("Failed to GetThreadContext()\r\n");
ResumeThread(hThread);
}
CloseHandle(hThread);
}
示例3: PrettyPrintNode
static void PrettyPrintNode(TxtNode *curr, int nest, str::Str<char>& res)
{
if (TextNode == curr->type) {
PrettyPrintKeyVal(curr, nest, res);
return;
}
if (StructNode == curr->type) {
PrettyPrintKeyVal(curr, nest, res);
res.Append(" + [\n");
} else if (nest >= 0) {
CrashIf(ArrayNode != curr->type);
AppendNest(res, nest);
res.Append("[\n");
}
TxtNode *child;
for (size_t i = 0; i < curr->children->Count(); i++) {
child = curr->children->At(i);
PrettyPrintNode(child, nest + 1, res);
}
if (nest >= 0) {
AppendNest(res, nest);
res.Append("]\n");
}
}
示例4: GetInternedStringsReport
static void GetInternedStringsReport(str::Str<char>& resOut)
{
resOut.Append("Strings:\n");
int n = g_strInterner.StringsCount();
for (int i = 0; i < n; i++) {
resOut.AppendFmt("%d|%s\n", i, g_strInterner.GetByIndex(i));
}
resOut.Append("\n");
}
示例5: GetProgramInfo
void GetProgramInfo(str::Str<char>& s)
{
s.AppendFmt("Ver: %s", QM(CURR_VERSION));
#ifdef SVN_PRE_RELEASE_VER
s.AppendFmt(".%s pre-release", QM(SVN_PRE_RELEASE_VER));
#endif
#ifdef DEBUG
s.Append(" dbg");
#endif
s.Append("\r\n");
}
示例6: GetProgramInfo
void GetProgramInfo(str::Str<char>& s)
{
s.AppendFmt("Ver: %s", CURR_VERSION_STRA);
#ifdef SVN_PRE_RELEASE_VER
s.AppendFmt(" pre-release");
#endif
#ifdef DEBUG
if (!str::EndsWith(s.Get(), " (dbg)"))
s.Append(" (dbg)");
#endif
s.Append("\r\n");
}
示例7: PrettyPrintKeyVal
static void PrettyPrintKeyVal(TxtNode *curr, int nest, str::Str<char>& res)
{
AppendNest(res, nest);
if (curr->keyStart) {
AppendWsTrimEnd(res, curr->keyStart, curr->keyEnd);
if (StructNode != curr->type)
res.Append(" + ");
}
AppendWsTrimEnd(res, curr->valStart, curr->valEnd);
if (StructNode != curr->type)
res.Append("\n");
}
示例8: GetStackFrameInfo
static bool GetStackFrameInfo(str::Str<char>& s, STACKFRAME64 *stackFrame,
CONTEXT *ctx, HANDLE hThread)
{
#if defined(_WIN64)
int machineType = IMAGE_FILE_MACHINE_AMD64;
#else
int machineType = IMAGE_FILE_MACHINE_I386;
#endif
BOOL ok = _StackWalk64(machineType, GetCurrentProcess(), hThread,
stackFrame, ctx, NULL, _SymFunctionTableAccess64,
_SymGetModuleBase64, NULL);
if (!ok)
return false;
DWORD64 addr = stackFrame->AddrPC.Offset;
if (0 == addr)
return true;
if (addr == stackFrame->AddrReturn.Offset) {
s.Append("GetStackFrameInfo(): addr == stackFrame->AddrReturn.Offset");
return false;
}
GetAddressInfo(s, addr);
return true;
}
示例9: AppendNest
static void AppendNest(str::Str<char>& s, int nest)
{
while (nest > 0) {
s.Append(" ");
--nest;
}
}
示例10: DumpTypes
static void DumpTypes(IDiaSession *session)
{
IDiaSymbol * globalScope = NULL;
IDiaEnumSymbols * enumSymbols = NULL;
IDiaSymbol * symbol = NULL;
HRESULT hr = session->get_globalScope(&globalScope);
if (FAILED(hr))
return;
AddReportSepLine();
g_report.Append("Types:\n");
DWORD flags = nsfCaseInsensitive|nsfUndecoratedName; // nsNone ?
hr = globalScope->findChildren(SymTagUDT, 0, flags, &enumSymbols);
if (FAILED(hr))
goto Exit;
ULONG celt = 0;
for (;;)
{
hr = enumSymbols->Next(1, &symbol, &celt);
if (FAILED(hr) || (celt != 1))
break;
DumpType(symbol, 0);
symbol->Release();
}
Exit:
UnkReleaseSafe(enumSymbols);
UnkReleaseSafe(globalScope);
}
示例11: AppendEntry
static bool AppendEntry(str::Str<char>& data, str::Str<char>& content, const WCHAR *filePath, const char *inArchiveName, lzma::FileInfo *fi=NULL)
{
size_t nameLen = str::Len(inArchiveName);
CrashIf(nameLen > UINT32_MAX - 25);
uint32_t headerSize = 25 + (uint32_t)nameLen;
FILETIME ft = file::GetModificationTime(filePath);
if (fi && FileTimeEq(ft, fi->ftModified)) {
ReusePrevious:
ByteWriterLE meta(data.AppendBlanks(24), 24);
meta.Write32(headerSize);
meta.Write32(fi->compressedSize);
meta.Write32(fi->uncompressedSize);
meta.Write32(fi->uncompressedCrc32);
meta.Write32(ft.dwLowDateTime);
meta.Write32(ft.dwHighDateTime);
data.Append(inArchiveName, nameLen + 1);
return content.AppendChecked(fi->compressedData, fi->compressedSize);
}
size_t fileDataLen;
ScopedMem<char> fileData(file::ReadAll(filePath, &fileDataLen));
if (!fileData || fileDataLen >= UINT32_MAX) {
fprintf(stderr, "Failed to read \"%S\" for compression\n", filePath);
return false;
}
uint32_t fileDataCrc = crc32(0, (const uint8_t *)fileData.Get(), (uint32_t)fileDataLen);
if (fi && fi->uncompressedCrc32 == fileDataCrc && fi->uncompressedSize == fileDataLen)
goto ReusePrevious;
size_t compressedSize = fileDataLen + 1;
ScopedMem<char> compressed((char *)malloc(compressedSize));
if (!compressed)
return false;
if (!Compress(fileData, fileDataLen, compressed, &compressedSize))
return false;
ByteWriterLE meta(data.AppendBlanks(24), 24);
meta.Write32(headerSize);
meta.Write32((uint32_t)compressedSize);
meta.Write32((uint32_t)fileDataLen);
meta.Write32(fileDataCrc);
meta.Write32(ft.dwLowDateTime);
meta.Write32(ft.dwHighDateTime);
data.Append(inArchiveName, nameLen + 1);
return content.AppendChecked(compressed, compressedSize);
}
示例12: AppendNewline
static void AppendNewline(str::Str<WCHAR>& extracted, Vec<RectI>& coords, const WCHAR *lineSep)
{
if (extracted.Count() > 0 && ' ' == extracted.Last()) {
extracted.Pop();
coords.Pop();
}
extracted.Append(lineSep);
coords.AppendBlanks(str::Len(lineSep));
}
示例13: GetProgramInfo
void GetProgramInfo(str::Str<char>& s) {
s.AppendFmt("Ver: %s", CURR_VERSION_STRA);
#ifdef SVN_PRE_RELEASE_VER
s.AppendFmt(" pre-release");
#endif
if (IsProcess64()) {
s.Append(" 64-bit");
}
#ifdef DEBUG
if (!str::Find(s.Get(), " (dbg)"))
s.Append(" (dbg)");
#endif
s.Append("\r\n");
#if defined(GIT_COMMIT_ID)
const char* gitSha1 = QM(GIT_COMMIT_ID);
s.AppendFmt("Git: %s (https://github.com/sumatrapdfreader/sumatrapdf/tree/%s)\r\n", gitSha1, gitSha1);
#endif
}
示例14: BStrToString
void BStrToString(str::Str<char>& strInOut, BSTR str, char *defString, bool stripWhitespace)
{
strInOut.Reset();
if (!str) {
strInOut.Append(defString);
return;
}
OLECHAR c;
int len = SysStringLen(str);
for (int i=0; i<len; i++)
{
c = str[i];
if (stripWhitespace && isspace(c))
continue;
if (c < 32 || c >= 128)
c = '?';
strInOut.Append((char)c);
}
}
示例15: GetCallstack
static bool GetCallstack(str::Str<char>& s, CONTEXT& ctx, HANDLE hThread)
{
if (!CanStackWalk()) {
s.Append("GetCallstack(): CanStackWalk() returned false");
return false;
}
STACKFRAME64 stackFrame;
memset(&stackFrame, 0, sizeof(stackFrame));
#ifdef _WIN64
stackFrame.AddrPC.Offset = ctx.Rip;
stackFrame.AddrFrame.Offset = ctx.Rbp;
stackFrame.AddrStack.Offset = ctx.Rsp;
#else
stackFrame.AddrPC.Offset = ctx.Eip;
stackFrame.AddrFrame.Offset = ctx.Ebp;
stackFrame.AddrStack.Offset = ctx.Esp;
#endif
stackFrame.AddrPC.Mode = AddrModeFlat;
stackFrame.AddrFrame.Mode = AddrModeFlat;
stackFrame.AddrStack.Mode = AddrModeFlat;
int framesCount = 0;
static const int maxFrames = 32;
while (framesCount < maxFrames)
{
if (!GetStackFrameInfo(s, &stackFrame, &ctx, hThread))
break;
framesCount++;
}
if (0 == framesCount) {
s.Append("StackWalk64() couldn't get even the first stack frame info");
return false;
}
return true;
}