CEGUI Render string parser question

Forum for general chit-chat or off-topic discussion.

Moderators: CEGUI MVP, CEGUI Team

znikang
Just popping in
Just popping in
Posts: 4
Joined: Wed Jan 26, 2011 06:34

CEGUI Render string parser question

Postby znikang » 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);

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: CEGUI Render string parser question

Postby CrazyEddie » Wed Jan 26, 2011 09:40

Your thread does not contain sufficient information and/or does not follow the forum guidelines. Please edit your post to suit the mentioned requirements so we can help you, thanks!


Return to “Offtopic Discussion”

Who is online

Users browsing this forum: No registered users and 2 guests