本文整理汇总了C++中String::CString方法的典型用法代码示例。如果您正苦于以下问题:C++ String::CString方法的具体用法?C++ String::CString怎么用?C++ String::CString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类String
的用法示例。
在下文中一共展示了String::CString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ToVectorVariant
Variant ToVectorVariant(const String& source)
{
return ToVectorVariant(source.CString());
}
示例2:
Vector4 ToVector4(const String& source, bool allowMissingCoords)
{
return ToVector4(source.CString(), allowMissingCoords);
}
示例3: SetVariable
bool XPathQuery::SetVariable(const String& name, const String& value)
{
return SetVariable(name.CString(), value.CString());
}
示例4: RemoveAttribute
bool XMLElement::RemoveAttribute(const String& name)
{
return RemoveAttribute(name.CString());
}
示例5: StringToBuffer
void StringToBuffer(PODVector<unsigned char>& dest, const String& source)
{
StringToBuffer(dest, source.CString());
}
示例6: ToBool
bool ToBool(const String& source)
{
return ToBool(source.CString());
}
示例7: ToFloat
float ToFloat(const String& source)
{
return ToFloat(source.CString());
}
示例8: ToDouble
double ToDouble(const String& source)
{
return ToDouble(source.CString());
}
示例9: ToInt
int ToInt(const String& source, int base)
{
return ToInt(source.CString(), base);
}
示例10: ToUInt
unsigned ToUInt(const String& source, int base)
{
return ToUInt(source.CString(), base);
}
示例11: 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:
tolua_pushusertype(luaState_, (void*)&(src.GetVector2()), "Vector2");
break;
case VAR_VECTOR3:
tolua_pushusertype(luaState_, (void*)&(src.GetVector3()), "Vector3");
break;
case VAR_VECTOR4:
tolua_pushusertype(luaState_, (void*)&(src.GetVector4()), "Vector4");
break;
case VAR_QUATERNION:
tolua_pushusertype(luaState_, (void*)&(src.GetQuaternion()), "Quaternion");
break;
case VAR_COLOR:
tolua_pushusertype(luaState_, (void*)&(src.GetColor()), "Color");
break;
case VAR_INTRECT:
tolua_pushusertype(luaState_, (void*)&(src.GetIntRect()), "IntRect");
break;
case VAR_INTVECTOR2:
tolua_pushusertype(luaState_, (void*)&(src.GetIntVector2()), "IntVector2");
break;
default:
LOGERROR("Unsupported data type");
lua_settop(luaState_, top);
return;
}
lua_settable(luaState_, -3);
}
lua_settop(luaState_, top);
}
示例12: 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);
}
示例13: ToColor
Color ToColor(const String& source)
{
return ToColor(source.CString());
}
示例14: ToRect
Rect ToRect(const String& source)
{
return ToRect(source.CString());
}
示例15: GetStringListIndex
unsigned GetStringListIndex(const String& value, const String* strings, unsigned defaultIndex, bool caseSensitive)
{
return GetStringListIndex(value.CString(), strings, defaultIndex, caseSensitive);
}