static AString GetIDString(const char *s, unsigned &finishPos) { AString result; for (finishPos = 0; ; finishPos++) { char c = s[finishPos]; if (IsDelimitChar(c) || c == '=') break; result += c; } return result; }
static bool SkipSpaces(const AString &s, unsigned &pos) { for (; pos < s.Len(); pos++) { char c = s[pos]; if (!IsDelimitChar(c)) { if (c != ';') return true; if (!WaitNextLine(s, pos)) return false; } } return false; }
//=============================================================================== // Get any pitch, volume, start, end params into voxword // and null out trailing format characters // Format: // someword(v100 p110 s10 e20) // // v is volume, 0% to n% // p is pitch shift up 0% to n% // s is start wave offset % // e is end wave offset % // t is timecompression % // // pass fFirst == 1 if this is the first string in sentence // returns 1 if valid string, 0 if parameter block only. // // If a ( xxx ) parameter block does not directly follow a word, // then that 'default' parameter block will be used as the default value // for all following words. Default parameter values are reset // by another 'default' parameter block. Default parameter values // for a single word are overridden for that word if it has a parameter block. // //=============================================================================== int VOX_ParseWordParams( char *psz, voxword_t *pvoxword, int fFirst ) { char *pszsave = psz; char c, ct, sznum[8]; static voxword_t voxwordDefault; int i; // init to defaults if this is the first word in string. if( fFirst ) { voxwordDefault.pitch = -1; voxwordDefault.volume = 100; voxwordDefault.start = 0; voxwordDefault.end = 100; voxwordDefault.fKeepCached = 0; voxwordDefault.timecompress = 0; } *pvoxword = voxwordDefault; // look at next to last char to see if we have a // valid format: c = *( psz + Q_strlen( psz ) - 1 ); // no formatting, return if( c != ')' ) return 1; // scan forward to first '(' c = *psz; while( !IsDelimitChar( c )) c = *(++psz); // bogus formatting if( c == ')' ) return 0; // null terminate *psz = 0; ct = *(++psz); while( 1 ) { // scan until we hit a character in the commandSet while( ct && !IsCommandChar( ct )) ct = *(++psz); if( ct == ')' ) break; Q_memset( sznum, 0, sizeof( sznum )); i = 0; c = *(++psz); if( !isdigit( c )) break; // read number while( isdigit( c ) && i < sizeof( sznum ) - 1 ) { sznum[i++] = c; c = *(++psz); } // get value of number i = Q_atoi( sznum ); switch( ct ) { case 'v': pvoxword->volume = i; break; case 'p': pvoxword->pitch = i; break; case 's': pvoxword->start = i; break; case 'e': pvoxword->end = i; break; case 't': pvoxword->timecompress = i; break; } ct = c; } // if the string has zero length, this was an isolated // parameter block. Set default voxword to these // values if( Q_strlen( pszsave ) == 0 ) { voxwordDefault = *pvoxword; return 0; } return 1; }