本文整理汇总了C++中rString::size方法的典型用法代码示例。如果您正苦于以下问题:C++ rString::size方法的具体用法?C++ rString::size怎么用?C++ rString::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rString
的用法示例。
在下文中一共展示了rString::size方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WrapText
void WrapText(Face* face, const rString& text, const rSize& size, std::function<void(Glyph**, size_t, int, int)> wordFunc){
std::vector<Font::Glyph*> wordGlyphs;
int xPos = 0;
int yPos = face->GetAscender();
int wordWidth = 0;
int spaceLeft = size.x;
int lineCount = 0;
for (size_t i = 0; i < text.size(); i++){
int c = text[i];
if (c == '\n'){
if (wordWidth > spaceLeft){ //current word will not fit on this line
yPos += face->GetLineHeight();
xPos = 0;
}
wordFunc(wordGlyphs.data(), wordGlyphs.size(), xPos, yPos);
wordGlyphs.clear();
yPos += face->GetLineHeight();
xPos = 0;
spaceLeft = size.x;
wordWidth = 0;
}
else{
Font::Glyph* glyph = face->GetGlyph(c);
if (c == ' '){
if (wordWidth + glyph->advance > spaceLeft){ //current word will not fit on this line
yPos += face->GetLineHeight();
xPos = 0;
spaceLeft = size.x;
}
wordFunc(wordGlyphs.data(), wordGlyphs.size(), xPos, yPos);
wordGlyphs.clear();
spaceLeft -= wordWidth + glyph->advance;
xPos += wordWidth + glyph->advance;
wordWidth = 0;
}
else{
wordWidth += glyph->advance;
wordGlyphs.push_back(glyph);
}
}
}
if (wordGlyphs.size() > 0){
wordFunc(wordGlyphs.data(), wordGlyphs.size(), xPos, yPos);
wordGlyphs.clear();
}
}
示例2: GetParseItemMethod
ruiOverlayLoader::ruiParseItemMethod ruiOverlayLoader::GetParseItemMethod (const rString& itemName){
rString item = itemName;
for (size_t i =0; i < itemName.size(); i++)
item[i] = tolower(itemName[i]);
if (s_parseItemMap.count(item))
return s_parseItemMap[item];
else
return NULL;
}
示例3:
rString gfx::MaterialBank::GetDir(rString& filename)
{
bool found = false;
for (int i = static_cast<int>(filename.size()); i > 0; i--)
{
if (filename.c_str()[i] == '/' || filename.c_str()[i] == '\\' )
found = true;
if (!found)
{
filename.erase(i);
}
}
return filename;
}
示例4:
rString gfx::ShaderProgram::GetDir ( rString filename )
{
bool found = false;
for ( int i = static_cast<int> ( filename.size() ); i > 0; i-- )
{
if ( filename.c_str() [i] == '/' )
{
found = true;
}
if ( !found )
{
filename.erase ( i );
}
}
return filename;
}
示例5:
rString gfx::TextureAtlas::GetDir ( rString str )
{
bool found = false;
for ( int i = static_cast<int> ( str.size() ); i > 0; i-- )
{
if ( str.c_str() [i] == '/' )
{
found = true;
}
if ( !found )
{
str.erase ( i );
}
}
return str;
}