CEGUI Render string parser question
Posted: Wed Jan 26, 2011 06:42
hello i have some quest
this function
Basic
//----------------------------------------------------------------------------//
RenderedString BasicRenderedStringParser::parse(const String& input_string,
Font* initial_font,
const ColourRect* initial_colours)
{
// first-time initialisation (due to issues with static creation order)
if (!d_initialised)
initialiseTagHandlers();
initialiseDefaultState();
// maybe override initial font.
if (initial_font)
d_fontName = initial_font->getName();
// maybe override initial colours.
if (initial_colours)
d_colours = *initial_colours;
RenderedString rs;
String curr_section;
size_t curr_pos = 0;
while (curr_pos < input_string.length())
{
size_t cstart_pos = input_string.find_first_of('[', curr_pos);
// if no control sequence start char, add remaining text verbatim.
if (String::npos == cstart_pos)
{
curr_section += input_string.substr(curr_pos);
curr_pos = input_string.length();
}
else if (cstart_pos == curr_pos || input_string[cstart_pos - 1] != '\\')
{
// append everything up to the control start to curr_section.
curr_section += input_string.substr(curr_pos, cstart_pos - curr_pos);
// scan forward for end of control sequence
size_t cend_pos = input_string.find_first_of(']', cstart_pos);
// if not found, treat as plain text
if (String::npos == cend_pos)
{
curr_section += input_string.substr(curr_pos);
curr_pos = input_string.length();
}
// extract control string
else
{
appendRenderedText(rs, curr_section);
curr_section.clear();
String ctrl_string(
input_string.substr(cstart_pos + 1,
cend_pos - cstart_pos - 1));
curr_pos = cend_pos + 1;
processControlString(rs, ctrl_string);
continue;
}
}
else
{
curr_section += input_string.substr(curr_pos,
cstart_pos - curr_pos - 1);
curr_section += '[';
curr_pos = cstart_pos + 1;
continue;
}
appendRenderedText(rs, curr_section);
curr_section.clear();
}
return rs;
}
that 's Error ?
curr_section += input_string.substr(cstart_pos);
this function
Basic
//----------------------------------------------------------------------------//
RenderedString BasicRenderedStringParser::parse(const String& input_string,
Font* initial_font,
const ColourRect* initial_colours)
{
// first-time initialisation (due to issues with static creation order)
if (!d_initialised)
initialiseTagHandlers();
initialiseDefaultState();
// maybe override initial font.
if (initial_font)
d_fontName = initial_font->getName();
// maybe override initial colours.
if (initial_colours)
d_colours = *initial_colours;
RenderedString rs;
String curr_section;
size_t curr_pos = 0;
while (curr_pos < input_string.length())
{
size_t cstart_pos = input_string.find_first_of('[', curr_pos);
// if no control sequence start char, add remaining text verbatim.
if (String::npos == cstart_pos)
{
curr_section += input_string.substr(curr_pos);
curr_pos = input_string.length();
}
else if (cstart_pos == curr_pos || input_string[cstart_pos - 1] != '\\')
{
// append everything up to the control start to curr_section.
curr_section += input_string.substr(curr_pos, cstart_pos - curr_pos);
// scan forward for end of control sequence
size_t cend_pos = input_string.find_first_of(']', cstart_pos);
// if not found, treat as plain text
if (String::npos == cend_pos)
{
curr_section += input_string.substr(curr_pos);
curr_pos = input_string.length();
}
// extract control string
else
{
appendRenderedText(rs, curr_section);
curr_section.clear();
String ctrl_string(
input_string.substr(cstart_pos + 1,
cend_pos - cstart_pos - 1));
curr_pos = cend_pos + 1;
processControlString(rs, ctrl_string);
continue;
}
}
else
{
curr_section += input_string.substr(curr_pos,
cstart_pos - curr_pos - 1);
curr_section += '[';
curr_pos = cstart_pos + 1;
continue;
}
appendRenderedText(rs, curr_section);
curr_section.clear();
}
return rs;
}
that 's Error ?
curr_section += input_string.substr(cstart_pos);