diff options
| author | git perforce import user <a@b> | 2016-10-25 12:29:14 -0600 |
|---|---|---|
| committer | Sheikh Dawood Abdul Ajees <Sheikh Dawood Abdul Ajees> | 2016-10-25 18:56:37 -0500 |
| commit | 3dfe2108cfab31ba3ee5527e217d0d8e99a51162 (patch) | |
| tree | fa6485c169e50d7415a651bf838f5bcd0fd3bfbd /APEX_1.4/shared/general/RenderDebug/include/GetArgs.h | |
| download | physx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.tar.xz physx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.zip | |
Initial commit:
PhysX 3.4.0 Update @ 21294896
APEX 1.4.0 Update @ 21275617
[CL 21300167]
Diffstat (limited to 'APEX_1.4/shared/general/RenderDebug/include/GetArgs.h')
| -rw-r--r-- | APEX_1.4/shared/general/RenderDebug/include/GetArgs.h | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/APEX_1.4/shared/general/RenderDebug/include/GetArgs.h b/APEX_1.4/shared/general/RenderDebug/include/GetArgs.h new file mode 100644 index 00000000..e177314b --- /dev/null +++ b/APEX_1.4/shared/general/RenderDebug/include/GetArgs.h @@ -0,0 +1,88 @@ +#ifndef GET_ARGS_H + +#define GET_ARGS_H + +#define MAX_ARGS 4096 +#define MAX_ARG_STRING 16384 + +class GetArgs +{ +public: + + const char **getArgs(const char *str,uint32_t &argc) + { + argc = 0; + + str = skipSpaces(str); // skip any leading spaces + char *dest = mArgString; + char *stop = &mArgString[MAX_ARG_STRING-1]; + + while ( str && *str && dest < stop ) // if we have a valid string then we have at least one argument.. + { + if ( *str == 34 ) // if it is a quoted string... + { + str++; // Skip the opening quote + if ( *str == 34 ) // double quotes I guess we treat as an empty string + { + mArgv[argc] = ""; + argc++; + } + else + { + mArgv[argc] = dest; // store the beginning of the argument + argc++; + while ( *str && *str != 34 && dest < stop ) + { + *dest++ = *str++; + } + *dest = 0; // null terminate the quoted argument. + dest++; + } + if ( *str == 34 ) // skip closing quote + { + str++; + } + str = skipSpaces(str); + } + else + { + mArgv[argc] = dest; + argc++; + while ( *str && !isWhiteSpace(*str) && dest < stop ) + { + *dest++ = *str++; + } + *dest = 0; + dest++; + str = skipSpaces(str); + } + } + + return mArgv; + } + +private: + PX_INLINE bool isWhiteSpace(char c) const + { + if ( c == 32 || c == 9 ) return true; + return false; + } + + PX_INLINE const char *skipSpaces(const char *str) const + { + if ( str ) + { + while ( *str == 32 || *str == 9 ) + { + str++; + } + } + return str; + } + + const char *mArgv[MAX_ARGS]; + char mArgString[MAX_ARG_STRING]; + +}; + +#endif |