| 34 | } |
| 35 | |
| 36 | void GFXVideoMode::parseFromString( const char *str ) |
| 37 | { |
| 38 | if(!str) |
| 39 | return; |
| 40 | |
| 41 | // Copy the string, as dStrtok is destructive |
| 42 | dsize_t tempBufLen = dStrlen(str) + 1; |
| 43 | char *tempBuf = new char[tempBufLen]; |
| 44 | dStrcpy( tempBuf, str, tempBufLen ); |
| 45 | |
| 46 | #define PARSE_ELEM(type, var, func, tokParam, sep) \ |
| 47 | if(const char *ptr = dStrtok( tokParam, sep)) \ |
| 48 | { type tmp = func(ptr); if(tmp > 0) var = tmp; } |
| 49 | |
| 50 | PARSE_ELEM(S32, resolution.x, dAtoi, tempBuf, " x\0") |
| 51 | PARSE_ELEM(S32, resolution.y, dAtoi, NULL, " x\0") |
| 52 | const char *boolptr = dStrtok(NULL, " \0"); |
| 53 | if (boolptr) |
| 54 | fullScreen = dAtob(boolptr); |
| 55 | PARSE_ELEM(S32, bitDepth, dAtoi, NULL, " \0") |
| 56 | PARSE_ELEM(S32, refreshRate, dAtoi, NULL, " \0") |
| 57 | PARSE_ELEM(S32, antialiasLevel, dAtoi, NULL, " \0") |
| 58 | |
| 59 | #undef PARSE_ELEM |
| 60 | |
| 61 | delete [] tempBuf; |
| 62 | } |
| 63 | |
| 64 | const String GFXVideoMode::toString() const |
| 65 | { |
no test coverage detected