本文整理汇总了C++中str::Str类的典型用法代码示例。如果您正苦于以下问题:C++ Str类的具体用法?C++ Str怎么用?C++ Str使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Str类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DumpType
static void DumpType(IDiaSymbol *symbol, int deep)
{
IDiaEnumSymbols * enumChilds = NULL;
HRESULT hr;
const char * nameStr = NULL;
const char * type;
LONG offset;
ULONGLONG length;
ULONG celt = 0;
ULONG symtag;
DWORD locType;
bool typeSeen;
#if 0
if (deep > 2)
return;
#endif
if (symbol->get_symTag(&symtag) != S_OK)
return;
nameStr = GetTypeName(symbol);
g_typesSeen.Intern(nameStr, &typeSeen);
if (typeSeen)
return;
symbol->get_length(&length);
symbol->get_offset(&offset);
if (SymTagData == symtag) {
if (symbol->get_locationType(&locType) != S_OK)
return; // must be a symbol in optimized code
// TODO: use get_offsetInUdt (http://msdn.microsoft.com/en-us/library/dd997149.aspx) ?
// TODO: use get_type (http://msdn.microsoft.com/en-US/library/cwx3656b(v=vs.80).aspx) ?
// TODO: see what else we can get http://msdn.microsoft.com/en-US/library/w8ae4k32(v=vs.80).aspx
if (LocIsThisRel == locType) {
g_report.AppendFmt("%s%s|%d\n", spaces(deep), nameStr, (int)offset);
}
} else if (SymTagUDT == symtag) {
// TODO: why is it always "struct" even for classes?
type = GetUdtType(symbol);
g_report.AppendFmt("%s%s|%s|%d\n", spaces(deep), type, nameStr, (int)length);
hr = symbol->findChildren(SymTagNull, NULL, nsNone, &enumChilds);
if (!SUCCEEDED(hr))
return;
IDiaSymbol* child;
while (SUCCEEDED(enumChilds->Next(1, &child, &celt)) && (celt == 1))
{
DumpType(child, deep+1);
child->Release();
}
enumChilds->Release();
} else {
if (symbol->get_locationType(&locType) != S_OK)
return; // must be a symbol in optimized code
// TODO: assert?
}
}
示例2: GetGraphicsDriverInfo
static void GetGraphicsDriverInfo(str::Str<char>& s)
{
// the info is in registry in:
// HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}\0000\
// Device Description REG_SZ (same as DriverDesc, so we don't read it)
// DriverDesc REG_SZ
// DriverVersion REG_SZ
// UserModeDriverName REG_MULTI_SZ
//
// There can be more than one driver, they are in 0000, 0001 etc.
for (int i=0; ; i++)
{
ScopedMem<WCHAR> key(str::Format(GFX_DRIVER_KEY_FMT, i));
ScopedMem<WCHAR> v1(ReadRegStr(HKEY_LOCAL_MACHINE, key, L"DriverDesc"));
// I assume that if I can't read the value, there are no more drivers
if (!v1)
break;
ScopedMem<char> v1a(str::conv::ToUtf8(v1));
s.AppendFmt("Graphics driver %d\r\n", i);
s.AppendFmt(" DriverDesc: %s\r\n", v1.Get());
v1.Set(ReadRegStr(HKEY_LOCAL_MACHINE, key, L"DriverVersion"));
if (v1) {
v1a.Set(str::conv::ToUtf8(v1));
s.AppendFmt(" DriverVersion: %s\r\n", v1a.Get());
}
v1.Set(ReadRegStr(HKEY_LOCAL_MACHINE, key, L"UserModeDriverName"));
if (v1) {
v1a.Set(str::conv::ToUtf8(v1));
s.AppendFmt(" UserModeDriverName: %s\r\n", v1a.Get());
}
}
}
示例3: 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);
}
示例4: 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);
}
示例5: DumpSection
static void DumpSection(IDiaSectionContrib *item)
{
DWORD sectionNo;
DWORD offset;
DWORD length;
item->get_addressSection(§ionNo);
item->get_addressOffset(&offset);
item->get_length(&length);
//DWORD compilandId;
//item->get_compilandId(&compilandId);
const char *sectionType = GetSectionType(item);
const char *objFileName = GetObjFileName(item);
if (g_compact) {
// type | sectionNo | length | offset | objFileId
int objFileId = InternString(objFileName);
g_report.AppendFmt("%s|%d|%d|%d|%d\n", sectionType, sectionNo, length, offset, objFileId);
} else {
// type | sectionNo | length | offset | objFile
g_report.AppendFmt("%s|%d|%d|%d|%s\n", sectionType, sectionNo, length, offset, objFileName);
}
}
示例6: GetOsVersion
static void GetOsVersion(str::Str<char>& s)
{
OSVERSIONINFOEX ver;
ZeroMemory(&ver, sizeof(ver));
ver.dwOSVersionInfoSize = sizeof(ver);
#pragma warning(push)
#pragma warning(disable: 4996) // 'GetVersionEx': was declared deprecated
// starting with Windows 8.1, GetVersionEx will report a wrong version number
// unless the OS's GUID has been explicitly added to the compatibility manifest
BOOL ok = GetVersionEx((OSVERSIONINFO*)&ver);
#pragma warning(pop)
if (!ok)
return;
const char *os = OsNameFromVer(ver);
int servicePackMajor = ver.wServicePackMajor;
int servicePackMinor = ver.wServicePackMinor;
int buildNumber = ver.dwBuildNumber & 0xFFFF;
#ifdef _WIN64
const char *arch = "64-bit";
#else
const char *arch = IsRunningInWow64() ? "Wow64" : "32-bit";
#endif
if (0 == servicePackMajor)
s.AppendFmt("OS: Windows %s build %d %s\r\n", os, buildNumber, arch);
else if (0 == servicePackMinor)
s.AppendFmt("OS: Windows %s SP%d build %d %s\r\n", os, servicePackMajor, buildNumber, arch);
else
s.AppendFmt("OS: Windows %s %d.%d build %d %s\r\n", os, servicePackMajor, servicePackMinor, buildNumber, arch);
}
示例7: 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");
}
}
示例8: AppendAddress
static void AppendAddress(str::Str<char>& s, DWORD64 addr)
{
#ifdef _WIN64
s.AppendFmt("%016I64X", addr);
#else
s.AppendFmt("%08X", (DWORD)addr);
#endif
}
示例9: BStrToString
// the result doesn't have to be free()d but is only valid until the next call to this function
static const char *GetTypeName(IDiaSymbol *symbol)
{
static str::Str<char> strTmp;
BSTR name = NULL;
symbol->get_name(&name);
BStrToString(strTmp, name, "<noname>", true);
SysFreeStringSafe(name);
return strTmp.Get();
}
示例10: 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));
}
示例11: 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");
}
示例12: 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");
}
示例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
#ifdef DEBUG
if (!str::EndsWith(s.Get(), " (dbg)"))
s.Append(" (dbg)");
#endif
s.Append("\r\n");
}
示例14: 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");
}
示例15: DumpSymbol
static void DumpSymbol(IDiaSymbol *symbol)
{
DWORD section, offset, rva;
DWORD dwTag;
enum SymTagEnum tag;
ULONGLONG length = 0;
const char * typeName = NULL;
char * dataTypeName = NULL;
const char * thunkTypeName = NULL;
symbol->get_symTag(&dwTag);
tag = (enum SymTagEnum)dwTag;
typeName = GetSymTypeName(tag);
symbol->get_relativeVirtualAddress(&rva);
symbol->get_addressSection(§ion);
symbol->get_addressOffset(&offset);
// for data, get length from type
if (SymTagData == tag)
{
IDiaSymbol *type = NULL;
if (symbol->get_type(&type) == S_OK) // no SUCCEEDED test as may return S_FALSE!
{
type->get_length(&length);
const char *s = GetUndecoratedSymbolName(type, "");
if (s && *s)
dataTypeName = str::Dup(s);
type->Release();
}
} if (SymTagThunk == tag) {
DWORD dwThunkKind;
if (S_OK == symbol->get_thunkOrdinal(&dwThunkKind))
thunkTypeName = GetThunkTypeName(dwThunkKind);
} else {
symbol->get_length(&length);
}
const char *nameStr = GetUndecoratedSymbolName(symbol);
if (SymTagData == tag) {
// type | section | length | offset | rva | name | dataTypeName
char *tmp = dataTypeName ? dataTypeName : "";
g_report.AppendFmt("%s|%d|%d|%d|%d|%s|%s\n", typeName, (int)section, (int)length, (int)offset, (int)rva, nameStr, tmp);
free(dataTypeName);
} else if (SymTagThunk == tag) {
const char *tmp = thunkTypeName ? thunkTypeName : "";
// type | section | length | offset | rva | name | thunkTypeName
g_report.AppendFmt("%s|%d|%d|%d|%d|%s|%s\n", typeName, (int)section, (int)length, (int)offset, (int)rva, nameStr, tmp);
} else {
// type | section | length | offset | rva | name
g_report.AppendFmt("%s|%d|%d|%d|%d|%s\n", typeName, (int)section, (int)length, (int)offset, (int)rva, nameStr);
}
}