本文整理汇总了C++中String::Back方法的典型用法代码示例。如果您正苦于以下问题:C++ String::Back方法的具体用法?C++ String::Back怎么用?C++ String::Back使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类String
的用法示例。
在下文中一共展示了String::Back方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RemoveTrailingSlash
String RemoveTrailingSlash(const String& pathName)
{
String ret = pathName.Trimmed();
ret.Replace('\\', '/');
if (!ret.Empty() && ret.Back() == '/')
ret.Resize(ret.Length() - 1);
return ret;
}
示例2: AddTrailingSlash
String AddTrailingSlash(const String& pathName)
{
String ret = pathName.Trimmed();
ret.Replace('\\', '/');
if (!ret.Empty() && ret.Back() != '/')
ret += '/';
return ret;
}
示例3: OnSetAttribute
void LuaScriptInstance::OnSetAttribute(const AttributeInfo& attr, const Variant& src)
{
if (attr.ptr_ != (void*)0xffffffff)
{
Serializable::OnSetAttribute(attr, src);
return;
}
if (scriptObjectRef_ == LUA_REFNIL)
return;
String name = attr.name_;
unsigned length = name.Length();
if (name.Back() == '_')
length -= 1;
int top = lua_gettop(luaState_);
String functionName = String("Set") + name.Substring(0, 1).ToUpper() + name.Substring(1, length - 1);
WeakPtr<LuaFunction> function = GetScriptObjectFunction(functionName);
// If set function exist
if (function)
{
if (function->BeginCall(this))
{
function->PushVariant(src);
function->EndCall();
}
}
else
{
lua_rawgeti(luaState_, LUA_REGISTRYINDEX, scriptObjectRef_);
lua_pushstring(luaState_, name.CString());
switch (attr.type_)
{
case VAR_BOOL:
lua_pushboolean(luaState_, src.GetBool());
break;
case VAR_FLOAT:
lua_pushnumber(luaState_, src.GetFloat());
break;
case VAR_STRING:
tolua_pushurho3dstring(luaState_, src.GetString());
break;
case VAR_VECTOR2:
{
Vector2* value = new Vector2(src.GetVector2());
tolua_pushusertype(luaState_, value, "Vector2");
tolua_register_gc(luaState_, lua_gettop(luaState_));
}
break;
case VAR_VECTOR3:
{
Vector3* value = new Vector3(src.GetVector3());
tolua_pushusertype(luaState_, value, "Vector3");
tolua_register_gc(luaState_, lua_gettop(luaState_));
}
break;
case VAR_VECTOR4:
{
Vector4* value = new Vector4(src.GetVector4());
tolua_pushusertype(luaState_, value, "Vector4");
tolua_register_gc(luaState_, lua_gettop(luaState_));
}
break;
case VAR_QUATERNION:
{
Quaternion* value = new Quaternion(src.GetQuaternion());
tolua_pushusertype(luaState_, value, "Quaternion");
tolua_register_gc(luaState_, lua_gettop(luaState_));
}
break;
case VAR_COLOR:
{
Color* value = new Color(src.GetColor());
tolua_pushusertype(luaState_, value, "Color");
tolua_register_gc(luaState_, lua_gettop(luaState_));
}
break;
case VAR_INTRECT:
{
IntRect* value = new IntRect(src.GetIntRect());
tolua_pushusertype(luaState_, value, "IntRect");
tolua_register_gc(luaState_, lua_gettop(luaState_));
}
break;
case VAR_INTVECTOR2:
{
IntVector2* value = new IntVector2(src.GetIntVector2());
tolua_pushusertype(luaState_, value, "IntVector2");
tolua_register_gc(luaState_, lua_gettop(luaState_));
}
break;
default:
LOGERROR("Unsupported data type");
lua_settop(luaState_, top);
return;
}
//.........这里部分代码省略.........
示例4: OnGetAttribute
void LuaScriptInstance::OnGetAttribute(const AttributeInfo& attr, Variant& dest) const
{
if (attr.ptr_ != (void*)0xffffffff)
{
Serializable::OnGetAttribute(attr, dest);
return;
}
if (scriptObjectRef_ == LUA_REFNIL)
return;
String name = attr.name_;
unsigned length = name.Length();
if (name.Back() == '_')
length -= 1;
int top = lua_gettop(luaState_);
String functionName = String("Get") + name.Substring(0, 1).ToUpper() + name.Substring(1, length - 1);
WeakPtr<LuaFunction> function = GetScriptObjectFunction(functionName);
// If get function exist
if (function)
{
if (function->BeginCall(this))
function->EndCall(1);
}
else
{
lua_rawgeti(luaState_, LUA_REGISTRYINDEX, scriptObjectRef_);
lua_pushstring(luaState_, name.CString());
lua_gettable(luaState_, -2);
}
switch (attr.type_)
{
case VAR_BOOL:
dest = lua_toboolean(luaState_, -1) != 0;
break;
case VAR_FLOAT:
dest = (float)lua_tonumber(luaState_, -1);
break;
case VAR_STRING:
dest = tolua_tourho3dstring(luaState_, -1, "");
break;
case VAR_VECTOR2:
dest = *((Vector2*)tolua_tousertype(luaState_, -1, 0));
break;
case VAR_VECTOR3:
dest = *((Vector3*)tolua_tousertype(luaState_, -1, 0));
break;
case VAR_VECTOR4:
dest = *((Vector4*)tolua_tousertype(luaState_, -1, 0));
break;
case VAR_QUATERNION:
dest = *((Quaternion*)tolua_tousertype(luaState_, -1, 0));
break;
case VAR_COLOR:
dest = *((Color*)tolua_tousertype(luaState_, -1, 0));
break;
case VAR_INTRECT:
dest = *((IntRect*)tolua_tousertype(luaState_, -1, 0));
break;
case VAR_INTVECTOR2:
dest = *((IntVector2*)tolua_tousertype(luaState_, -1, 0));
break;
default:
LOGERROR("Unsupported data type");
return;
}
lua_settop(luaState_, top);
}
示例5: OVRRemoveTrailingNewlines
static void OVRRemoveTrailingNewlines(String& s)
{
while(!s.IsEmpty() && ((s.Back() == '\n') || (s.Back() == '\r')))
s.PopBack();
}