本文整理汇总了C++中gd::Variable::GetString方法的典型用法代码示例。如果您正苦于以下问题:C++ Variable::GetString方法的具体用法?C++ Variable::GetString怎么用?C++ Variable::GetString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gd::Variable
的用法示例。
在下文中一共展示了Variable::GetString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ToString
std::string GD_API VariableStructureToJSON(const gd::Variable & variable)
{
if ( !variable.IsStructure() ) {
if ( variable.IsNumber() )
return ToString(variable.GetValue());
else
return StringToQuotedJSONString(variable.GetString().c_str());
}
std::string str = "{";
bool firstChild = true;
for(std::map<std::string, gd::Variable>::const_iterator i = variable.GetAllChildren().begin();
i != variable.GetAllChildren().end();++i)
{
if ( !firstChild ) str += ",";
str += StringToQuotedJSONString(i->first.c_str())+": "+VariableStructureToJSON(i->second);
firstChild = false;
}
str += "}";
return str;
}
示例2: GetVariableString
const std::string& GD_API GetVariableString(const gd::Variable & variable)
{
return variable.GetString();
};
示例3: SECTION
#include <map>
#include "GDCore/CommonTools.h"
#include "GDCore/Project/VariablesContainer.h"
TEST_CASE("Variable", "[common][variables]") {
SECTION("Basics") {
gd::Variable variable;
variable.SetValue(50);
REQUIRE(variable.GetValue() == 50);
REQUIRE(variable == 50);
REQUIRE(variable.IsNumber() == true);
REQUIRE(variable.IsStructure() == false);
variable.SetString("MyString");
REQUIRE(variable.GetString() == "MyString");
REQUIRE(variable == "MyString");
REQUIRE(variable.IsNumber() == false);
REQUIRE(variable.IsStructure() == false);
}
SECTION("Conversions") {
gd::Variable variable;
variable.SetValue(50);
REQUIRE(variable.GetString() == "50"); // Used as a string...
REQUIRE(variable.IsNumber() == false); //...so consider as a string
variable.SetString("MyString");
REQUIRE(variable.GetValue() == 0); // Used as a number...
REQUIRE(variable.IsNumber() == true); //...so consider as a number
}
SECTION("Use with int and string like semantics") {