MCPcopy Create free account
hub / github.com/baldurk/renderdoc / ParseArgsList

Function ParseArgsList

qrenderdoc/Code/QRDUtils.cpp:3217–3312  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3215}
3216
3217QStringList ParseArgsList(const QString &args)
3218{
3219 QStringList ret;
3220
3221 if(args.isEmpty())
3222 return ret;
3223
3224// on windows just use the function provided by the system
3225#if defined(Q_OS_WIN32)
3226 std::wstring wargs = args.toStdWString();
3227
3228 int argc = 0;
3229 wchar_t **argv = CommandLineToArgvW(wargs.c_str(), &argc);
3230
3231 for(int i = 0; i < argc; i++)
3232 ret << QString::fromWCharArray(argv[i]);
3233
3234 LocalFree(argv);
3235#else
3236 rdcstr argString = args;
3237
3238 // perform some kind of sane parsing
3239 bool dquot = false, squot = false; // are we inside ''s or ""s
3240
3241 // current character
3242 char *c = &argString[0];
3243
3244 // current argument we're building
3245 rdcstr a;
3246
3247 while(*c)
3248 {
3249 if(!dquot && !squot && (*c == ' ' || *c == '\t'))
3250 {
3251 if(!a.empty())
3252 ret << QString(a);
3253
3254 a = "";
3255 }
3256 else if(!dquot && *c == '"')
3257 {
3258 dquot = true;
3259 }
3260 else if(!squot && *c == '\'')
3261 {
3262 squot = true;
3263 }
3264 else if(dquot && *c == '"')
3265 {
3266 dquot = false;
3267 }
3268 else if(squot && *c == '\'')
3269 {
3270 squot = false;
3271 }
3272 else if(squot)
3273 {
3274 // single quotes don't escape, just copy literally until we leave single quote mode

Callers 2

DisassembleShaderMethod · 0.85
CompileShaderMethod · 0.85

Calls 6

toStdWStringMethod · 0.80
QStringFunction · 0.50
isEmptyMethod · 0.45
c_strMethod · 0.45
emptyMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected