本文整理汇总了C++中atlas::message::Element::Int方法的典型用法代码示例。如果您正苦于以下问题:C++ Element::Int方法的具体用法?C++ Element::Int怎么用?C++ Element::Int使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类atlas::message::Element
的用法示例。
在下文中一共展示了Element::Int方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_EntityProperty
void ProvidersTest::test_EntityProperty()
{
Atlas::Message::Element value;
auto provider = CreateProvider( { "entity" });
provider->value(value, QueryContext { *m_b1 });
assert(value.Ptr() == m_b1);
//entity.type
provider = CreateProvider( { "entity", "type" });
provider->value(value, QueryContext { *m_b1 });
assert(value.Ptr() == m_barrelType);
//entity.id
provider = CreateProvider( { "entity", "id" });
provider->value(value, QueryContext { *m_b1 });
assert(value.Int() == 1);
//entity.mass
provider = CreateProvider( { "entity", "mass" });
provider->value(value, QueryContext { *m_b1 });
assert(value.Int() == 30);
//entity.burn_speed
provider = CreateProvider( { "entity", "burn_speed" });
provider->value(value, QueryContext { *m_b1 });
assert(value.Float() == 0.3);
}
示例2: processServer
void ServerInfo::processServer(const RootEntity &svr)
{
Atlas::Message::Element element;
if (!svr->copyAttr("ruleset", element) && element.isString()) {
_ruleset = element.String();
} else {
return;
}
_name = svr->getName();
if (!svr->copyAttr("clients", element) && element.isInt()) {
_clients = (int)element.Int();
} else {
return;
}
if (!svr->copyAttr("server", element) && element.isString()) {
_server = element.String();
} else {
return;
}
if (!svr->copyAttr("uptime", element) && element.isFloat()) {
_uptime = element.Float();
} else {
return;
}
m_status = VALID;
if (!svr->copyAttr("entities", element) && element.isInt()) {
_entities = element.Int();
}
if (!svr->copyAttr("version", element) && element.isString()) {
m_version = element.String();
}
if (!svr->copyAttr("builddate", element) && element.isString()) {
m_buildDate = element.String();
}
if (!svr->copyAttr("assets", element) && element.isList()) {
for (auto& url : element.List()) {
if (url.isString()) {
m_assets.emplace_back(url.String());
}
}
}
}
示例3: wrap
Py::Object CyPy_Element::wrap(Atlas::Message::Element value)
{
if (value.isNone()) {
return Py::None();
} else if (value.isString()) {
return Py::String(value.String());
} else if (value.isInt()) {
return Py::Long(value.Int());
} else if (value.isFloat()) {
return Py::Float(value.Float());
} else if (value.isList()) {
return CyPy_ElementList::wrap(value.List());
} else {
return CyPy_ElementMap::wrap(value.Map());
}
}
示例4: asPyObject
Py::Object CyPy_Element::asPyObject(const Atlas::Message::Element& obj, bool useNativePythonType)
{
switch (obj.getType()) {
case Element::TYPE_INT:
return Py::Long(obj.Int());
case Element::TYPE_FLOAT:
return Py::Float(obj.Float());
case Element::TYPE_STRING:
return Py::String(obj.String());
case Element::TYPE_MAP:
return mapAsPyObject(obj.Map(), useNativePythonType);
case Element::TYPE_LIST:
return listAsPyObject(obj.List(), useNativePythonType);
default:
break;
}
return Py::None();
}