本文整理汇总了C++中vecText::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ vecText::push_back方法的具体用法?C++ vecText::push_back怎么用?C++ vecText::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vecText
的用法示例。
在下文中一共展示了vecText::push_back方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void CGUITextLayout::AppendToUTF32(const CStdStringW &utf16, character_t colStyle, vecText &utf32)
{
// NOTE: Assumes a single line of text
utf32.reserve(utf32.size() + utf16.size());
for (unsigned int i = 0; i < utf16.size(); i++)
utf32.push_back(utf16[i] | colStyle);
}
示例2: getFeed
void CRssReader::getFeed(vecText &text)
{
text.clear();
// double the spaces at the start of the set
for (int j = 0; j < m_spacesBetweenFeeds; j++)
text.push_back(L' ');
for (unsigned int i = 0; i < m_strFeed.size(); i++)
{
for (int j = 0; j < m_spacesBetweenFeeds; j++)
text.push_back(L' ');
for (unsigned int j = 0; j < m_strFeed[i].size(); j++)
{
character_t letter = m_strFeed[i][j] | ((m_strColors[i][j] - 48) << 16);
text.push_back(letter);
}
}
}
示例3: ParseText
void CGUITextLayout::ParseText(const CStdStringW &text, uint32_t defaultStyle, color_t defaultColor, vecColors &colors, vecText &parsedText)
{
// run through the string, searching for:
// [B] or [/B] -> toggle bold on and off
// [I] or [/I] -> toggle italics on and off
// [COLOR ffab007f] or [/COLOR] -> toggle color on and off
// [CAPS <option>] or [/CAPS] -> toggle capatilization on and off
uint32_t currentStyle = defaultStyle; // start with the default font's style
color_t currentColor = 0;
colors.push_back(defaultColor);
stack<color_t> colorStack;
colorStack.push(0);
// these aren't independent, but that's probably not too much of an issue
// eg [UPPERCASE]Glah[LOWERCASE]FReD[/LOWERCASE]Georeg[/UPPERCASE] will work (lower case >> upper case)
// but [LOWERCASE]Glah[UPPERCASE]FReD[/UPPERCASE]Georeg[/LOWERCASE] won't
int startPos = 0;
size_t pos = text.Find(L'[');
while (pos != CStdString::npos && pos + 1 < text.size())
{
uint32_t newStyle = 0;
color_t newColor = currentColor;
bool colorTagChange = false;
bool newLine = false;
// have a [ - check if it's an ON or OFF switch
bool on(true);
int endPos = pos++; // finish of string
if (text[pos] == L'/')
{
on = false;
pos++;
}
// check for each type
if (text.Mid(pos,2) == L"B]")
{ // bold - finish the current text block and assign the bold state
pos += 2;
if ((on && text.Find(L"[/B]",pos) >= 0) || // check for a matching end point
(!on && (currentStyle & FONT_STYLE_BOLD))) // or matching start point
newStyle = FONT_STYLE_BOLD;
}
else if (text.Mid(pos,2) == L"I]")
{ // italics
pos += 2;
if ((on && text.Find(L"[/I]",pos) >= 0) || // check for a matching end point
(!on && (currentStyle & FONT_STYLE_ITALICS))) // or matching start point
newStyle = FONT_STYLE_ITALICS;
}
else if (text.Mid(pos,10) == L"UPPERCASE]")
{
pos += 10;
if ((on && text.Find(L"[/UPPERCASE]",pos) >= 0) || // check for a matching end point
(!on && (currentStyle & FONT_STYLE_UPPERCASE))) // or matching start point
newStyle = FONT_STYLE_UPPERCASE;
}
else if (text.Mid(pos,10) == L"LOWERCASE]")
{
pos += 10;
if ((on && text.Find(L"[/LOWERCASE]",pos) >= 0) || // check for a matching end point
(!on && (currentStyle & FONT_STYLE_LOWERCASE))) // or matching start point
newStyle = FONT_STYLE_LOWERCASE;
}
else if (text.Mid(pos,3) == L"CR]" && on)
{
newLine = true;
pos += 3;
}
else if (text.Mid(pos,5) == L"COLOR")
{ // color
size_t finish = text.Find(L']', pos + 5);
if (on && finish != CStdString::npos && (size_t)text.Find(L"[/COLOR]",finish) != CStdString::npos)
{
color_t color = g_colorManager.GetColor(text.Mid(pos + 5, finish - pos - 5));
vecColors::const_iterator it = std::find(colors.begin(), colors.end(), color);
if (it == colors.end())
{ // create new color
if (colors.size() <= 0xFF)
{
newColor = colors.size();
colors.push_back(color);
}
else // we have only 8 bits for color index, fallback to first color if reach max.
newColor = 0;
}
else
// reuse existing color
newColor = it - colors.begin();
colorStack.push(newColor);
colorTagChange = true;
}
else if (!on && finish == pos + 5 && colorStack.size() > 1)
{ // revert to previous color
colorStack.pop();
newColor = colorStack.top();
colorTagChange = true;
}
if (finish != CStdString::npos)
pos = finish + 1;
//.........这里部分代码省略.........
示例4: ParseText
//.........这里部分代码省略.........
AppendToUTF32(subText, ((style & 3) << 24) | (color << 16), parsedText);
startPos = pos;
}
// have a [ - check if it's an ON or OFF switch
bool ignoreTag = false;
++pos;
bool on = true;
if (text[pos] == L'/')
{
on = false;
pos++;
}
// check for each type
if (text.Mid(pos,2) == L"B]")
{ // bold - finish the current text block and assign the bold state
pos += 2;
on ? ++boldCounter : --boldCounter;
}
else if (text.Mid(pos,2) == L"I]")
{ // italics
pos += 2;
on ? ++italicsCoutner : --italicsCoutner;
}
else if (text.Mid(pos,10) == L"UPPERCASE]")
{
pos += 10;
on ? ++upperCounter : --upperCounter;
}
else if (text.Mid(pos,10) == L"LOWERCASE]")
{
pos += 10;
on ? ++lowerCounter : --lowerCounter;
}
else if (text.Mid(pos,3) == L"CR]" && on)
{
pos += 3;
parsedText.push_back(L'\n');
}
else if (text.Mid(pos,5) == L"COLOR")
{ // color
size_t finish = text.Find(L']', pos + 5);
if (on && finish != CStdString::npos && (size_t) text.Find(L"[/COLOR]",finish) != CStdString::npos)
{ // create new color
color = colors.size();
colors.push_back(g_colorManager.GetColor(text.Mid(pos + 5, finish - pos - 5)));
colorStack.push(color);
}
else if (!on && finish == pos + 5 && colorStack.size() > 1)
{ // revert to previous color
colorStack.pop();
color = colorStack.top();
}
pos = finish + 1;
}
else
{
ignoreTag = true;
}
if (!ignoreTag)
{
startPos = pos;
}
pos = text.Find(L'[',pos);
}
// now grab the remainder of the string
CStdStringW subText = text.Mid(startPos, text.GetLength() - startPos);
int style = 0;
if (upperCounter)
{
#if defined(_LINUX) && !defined(__APPLE__)
std::transform(subText.begin(), subText.end(), subText.begin(),
(gunichar(*)(gunichar)) g_unichar_toupper);
#else
subText.ToUpper();
#endif
}
if (lowerCounter)
{
#if defined(_LINUX) && !defined(__APPLE__)
std::transform(subText.begin(), subText.end(), subText.begin(),
(gunichar(*)(gunichar)) g_unichar_tolower);
#else
subText.ToLower();
#endif
}
if (boldCounter)
style |= FONT_STYLE_BOLD;
if (italicsCoutner)
style |= FONT_STYLE_ITALICS;
AppendToUTF32(subText, ((style & 3) << 24) | (color << 16), parsedText);
}