本文整理汇总了C++中Strings::setDim方法的典型用法代码示例。如果您正苦于以下问题:C++ Strings::setDim方法的具体用法?C++ Strings::setDim怎么用?C++ Strings::setDim使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Strings
的用法示例。
在下文中一共展示了Strings::setDim方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getenv_setargv
void getenv_setargv(const char *envvar, int *pargc, char** *pargv)
{
char *p;
int instring;
int slash;
char c;
char *env = getenv(envvar);
if (!env)
return;
env = mem.strdup(env); // create our own writable copy
int argc = *pargc;
Strings *argv = new Strings();
argv->setDim(argc);
int argc_left = 0;
for (int i = 0; i < argc; i++) {
if (!strcmp((*pargv)[i], "-run") || !strcmp((*pargv)[i], "--run")) {
// HACK: set flag to indicate we saw '-run' here
global.params.run = true;
// Don't eat -run yet so the program arguments don't get changed
argc_left = argc - i;
argc = i;
*pargv = &(*pargv)[i];
argv->setDim(i);
break;
} else {
}
}
// HACK to stop required values from command line being drawn from DFLAGS
argv->push((char*)"");
argc++;
size_t j = 1; // leave argv[0] alone
while (1)
{
int wildcard = 1; // do wildcard expansion
switch (*env)
{
case ' ':
case '\t':
env++;
break;
case 0:
goto Ldone;
case '"':
wildcard = 0;
default:
argv->push(env); // append
//argv->insert(j, env); // insert at position j
j++;
argc++;
p = env;
slash = 0;
instring = 0;
c = 0;
while (1)
{
c = *env++;
switch (c)
{
case '"':
p -= (slash >> 1);
if (slash & 1)
{ p--;
goto Laddc;
}
instring ^= 1;
slash = 0;
continue;
case ' ':
case '\t':
if (instring)
goto Laddc;
*p = 0;
//if (wildcard)
//wildcardexpand(); // not implemented
break;
case '\\':
slash++;
*p++ = c;
continue;
case 0:
*p = 0;
//if (wildcard)
//wildcardexpand(); // not implemented
goto Ldone;
default:
Laddc:
slash = 0;
//.........这里部分代码省略.........