tgl_structure_parser : write_output |
Write to the output stream the string, handling wrapping, commenting and uppercase flags.
Any other method of any other object can call this method. This is called 'public' access.
The data-type returned is "booltype"; Not sure.
This method is contained in the object "tgl_structure_parser".
The method takes the following arguments:
s : stringtype
The string to output.
Process the structure text. We loop through the text searching for commands (which start with "\"), and when we find them we despatch.
std::string::const_iterator i=s.begin(); while (i != s.end()) { while (i != s.end() && *i == '\\\\') { i++; // skip over the command specifier. // allow command escaping. if (*i == '\\\\') break; std::string::const_iterator start; _command = ""; if (*i == '(') { i++; start = i; while (i != s.end() && *i != ')') i++; _command = std::string(start, i); i++; } else { start = i; i = find_command_end(i, s.end()); _command = std::string(start, i); } // if the command has an "=" in it, then it means that it's a // variable setting. int equal = _command.find('='); if (equal >= 0) { // set the variable and value. set_variable(_command.substr(0, equal), _command.substr(equal+1)); } else { if (_command == "n") write_output('\\n'); else if (_command == "t") write_output('\\t'); else { if (!do_block(_command)) return false; } } if (i != s.end() && *i == '\\n') i++; } if (i != s.end()) { write_output(*i); i++; } } return true;