本文整理汇总了C++中gd::String::substr方法的典型用法代码示例。如果您正苦于以下问题:C++ String::substr方法的具体用法?C++ String::substr怎么用?C++ String::substr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gd::String
的用法示例。
在下文中一共展示了String::substr方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ChangeProperty
bool RuntimeLightObject::ChangeProperty(std::size_t propertyNb, gd::String newValue)
{
if ( propertyNb == 0 )
{
gd::String r, gb, g, b;
{
size_t separationPos = newValue.find(";");
if ( separationPos > newValue.length())
return false;
r = newValue.substr(0, separationPos);
gb = newValue.substr(separationPos+1, newValue.length());
}
{
size_t separationPos = gb.find(";");
if ( separationPos > gb.length())
return false;
g = gb.substr(0, separationPos);
b = gb.substr(separationPos+1, gb.length());
}
SetColor(sf::Color(r.To<int>(), g.To<int>(), b.To<int>()));
}
else if ( propertyNb == 1 ) { SetIntensity(newValue.To<float>()); }
else if ( propertyNb == 2 ) { SetRadius(newValue.To<float>()); }
else if ( propertyNb == 3 ) { SetQuality(newValue.To<int>()); }
return true;
}
示例2: ChangeProperty
bool RuntimeTextObject::ChangeProperty(std::size_t propertyNb, gd::String newValue)
{
if ( propertyNb == 0 ) { SetString(newValue); return true; }
else if ( propertyNb == 1 ) { ChangeFont(newValue); }
else if ( propertyNb == 2 ) { SetCharacterSize(newValue.To<int>()); }
else if ( propertyNb == 3 )
{
gd::String r, gb, g, b;
{
size_t separationPos = newValue.find(";");
if ( separationPos > newValue.length())
return false;
r = newValue.substr(0, separationPos);
gb = newValue.substr(separationPos+1, newValue.length());
}
{
size_t separationPos = gb.find(";");
if ( separationPos > gb.length())
return false;
g = gb.substr(0, separationPos);
b = gb.substr(separationPos+1, gb.length());
}
SetColor(r.To<int>(), g.To<int>(), b.To<int>());
}
else if ( propertyNb == 4 ) { SetOpacity(newValue.To<float>()); }
else if ( propertyNb == 5 ) { SetSmooth(!(newValue == _("No"))); }
return true;
}
示例3: ChangeProperty
bool RuntimeObject::ChangeProperty(std::size_t propertyNb, gd::String newValue)
{
if ( propertyNb == 0 )
{
size_t separationPos = newValue.find(";");
if ( separationPos > newValue.length())
return false;
gd::String xValue = newValue.substr(0, separationPos);
gd::String yValue = newValue.substr(separationPos+1, newValue.length());
SetX(xValue.To<float>());
SetY(yValue.To<float>());
}
else if ( propertyNb == 1 ) {return SetAngle(newValue.To<float>());}
else if ( propertyNb == 2 ) {return false;}
else if ( propertyNb == 3 )
{
if ( newValue == _("Hidden") )
{
SetHidden();
}
else
SetHidden(false);
}
else if ( propertyNb == 4 ) { layer = newValue; }
else if ( propertyNb == 5 ) {SetZOrder(newValue.To<int>());}
else if ( propertyNb == 6 ) {return false;}
else if ( propertyNb == 7 ) {return false;}
else if ( propertyNb == 8 ) {return false;}
else if ( propertyNb == 9 ) {return false;}
return true;
}
示例4: StrAt
/**
* Expression function for getting a character from a string
*/
gd::String GD_API StrAt(const gd::String & str, size_t pos )
{
if ( pos < str.size() )
return str.substr(pos, 1);
return "";
}
示例5: SubStr
/**
* Expression function for getting a substring from a string
*/
gd::String GD_API SubStr(const gd::String & str, size_t start, size_t length )
{
if ( start < str.size() )
return str.substr(start, length);
return "";
}
示例6: GetNameWithoutPrefix
gd::String PathBehaviorEditor::GetNameWithoutPrefix(gd::String name)
{
gd::String result;
if(name.substr(0, 8) != "global: ")
{
return result = name;
}
else
{
gd::String::iterator namePlusEightIt = name.begin();
std::advance(namePlusEightIt, 8);
std::copy(namePlusEightIt, name.end(), std::back_inserter(result));
return result;
}
}
示例7: GetPropertyForDebugger
void GetPropertyForDebugger(RuntimeScene & scene, std::size_t propertyNb, gd::String & name, gd::String & value) const
{
std::size_t i = 0;
std::map < gd::String, ManualTimer >::const_iterator end = TimedEventsManager::managers[&scene].timedEvents.end();
for (std::map < gd::String, ManualTimer >::iterator iter = TimedEventsManager::managers[&scene].timedEvents.begin();iter != end;++iter)
{
if ( propertyNb == i )
{
name = iter->first;
//Unmangle name
if ( name.find("GDNamedTimedEvent_") == 0 && name.length() > 18 )
name = name.substr(18, name.length());
else
name = _("No name");
value = gd::String::From(static_cast<double>(iter->second.GetTime())/1000000.0)+"s";
return;
}
++i;
}
}