本文整理汇总了C++中WStrVec::InsertAt方法的典型用法代码示例。如果您正苦于以下问题:C++ WStrVec::InsertAt方法的具体用法?C++ WStrVec::InsertAt怎么用?C++ WStrVec::InsertAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WStrVec
的用法示例。
在下文中一共展示了WStrVec::InsertAt方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WinMain
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLineA, int nCmdShow)
{
WStrVec argList;
ParseCmdLine(GetCommandLine(), argList);
if (argList.Count() == 1) {
ScopedMem<WCHAR> msg(str::Format(L"Syntax: %s [<SumatraPDF.exe>] [<URL>] <filename.ext>", path::GetBaseName(argList.At(0))));
MessageBox(NULL, msg, PLUGIN_TEST_NAME, MB_OK | MB_ICONINFORMATION);
return 1;
}
if (argList.Count() == 2 || !str::EndsWithI(argList.At(1), L".exe")) {
argList.InsertAt(1, GetSumatraExePath());
}
if (argList.Count() == 3) {
argList.InsertAt(2, NULL);
}
WNDCLASS wc = { 0 };
wc.lpfnWndProc = PluginParentWndProc;
wc.hInstance = hInstance;
wc.lpszClassName = PLUGIN_TEST_NAME;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
RegisterClass(&wc);
PluginStartData data = { argList.At(1), argList.At(3), argList.At(2) };
HWND hwnd = CreateWindow(PLUGIN_TEST_NAME, PLUGIN_TEST_NAME,
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0,
NULL, NULL, hInstance,
&data);
ShowWindow(hwnd, nCmdShow);
MSG msg;
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
示例2: Insert
void Insert(int index, const WCHAR *t) {
text.InsertAt(index, str::Dup(t));
}
示例3: DeserializeAdvancedSettings
static void DeserializeAdvancedSettings(const WCHAR *filepath, SettingInfo *info, size_t count, void *structBase)
{
char *base = (char *)structBase;
const WCHAR *section = NULL;
INT intValue, intValueDef;
ScopedMem<WCHAR> strValue;
for (size_t i = 0; i < count; i++) {
SettingInfo& meta = info[i];
CrashIf(meta.type != SType_Section && !section);
switch (meta.type) {
case SType_Section:
section = meta.name;
break;
case SType_Bool:
intValueDef = *(bool *)(base + meta.offset) ? 1 : 0;
intValue = GetPrivateProfileInt(section, meta.name, intValueDef, filepath);
*(bool *)(base + meta.offset) = intValue != 0;
break;
case SType_Color:
strValue.Set(ReadIniString(filepath, section, meta.name));
if (str::Parse(strValue, L"#%6x", &intValue))
*(COLORREF *)(base + meta.offset) = (COLORREF)intValue;
break;
case SType_Int:
intValueDef = *(int *)(base + meta.offset);
intValue = GetPrivateProfileInt(section, meta.name, intValueDef, filepath);
*(int *)(base + meta.offset) = intValue;
break;
case SType_String:
strValue.Set(ReadIniString(filepath, section, meta.name, L"\n"));
if (!str::Eq(strValue, L"\n"))
((ScopedMem<WCHAR> *)(base + meta.offset))->Set(strValue.StealData());
break;
case SType_BoolVec:
case SType_ColorVec:
case SType_IntVec:
case SType_StringVec:
ScopedMem<WCHAR> sections(ReadIniString(filepath, section, NULL));
for (const WCHAR *name = sections; *name; name += str::Len(name) + 1) {
UINT idx;
if (str::Eq(str::Parse(name, L"%u.", &idx), meta.name)) {
if (SType_BoolVec == meta.type) {
bool value = GetPrivateProfileInt(section, name, 0, filepath) != 0;
((Vec<bool> *)(base + meta.offset))->InsertAt(idx, value);
}
else if (SType_ColorVec == meta.type) {
strValue.Set(ReadIniString(filepath, section, name));
if (str::Parse(strValue, L"#%6x", &intValue)) {
COLORREF value = (COLORREF)intValue;
((Vec<COLORREF> *)(base + meta.offset))->InsertAt(idx, value);
}
}
else if (SType_IntVec == meta.type) {
intValue = GetPrivateProfileInt(section, name, 0, filepath);
((Vec<int> *)(base + meta.offset))->InsertAt(idx, intValue);
}
else {
strValue.Set(ReadIniString(filepath, section, name));
WStrVec *strVec = (WStrVec *)(base + meta.offset);
// TODO: shouldn't InsertAt free the previous string?
if (idx < strVec->Count())
free(strVec->At(idx));
strVec->InsertAt(idx, strValue.StealData());
}
}
}
break;
}
}
}