本文整理汇总了C++中PropertyBase::add方法的典型用法代码示例。如果您正苦于以下问题:C++ PropertyBase::add方法的具体用法?C++ PropertyBase::add怎么用?C++ PropertyBase::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropertyBase
的用法示例。
在下文中一共展示了PropertyBase::add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testAdd
void PropertyExerciser::testAdd(PropertyBase & property,
Element::Type element_type)
{
Anonymous add_target;
MapType add_target2;
std::vector<StringType>::const_iterator I = string_values.begin();
std::vector<StringType>::const_iterator Iend = string_values.end();
for (; I != Iend; ++I) {
property.add(*I, add_target);
property.add(*I, add_target2);
}
}
示例2: main
int main()
{
{
// Test constructor
PropertyBase * pb = new EntityProperty();
delete pb;
}
{
// Check constructor has set flags correctly to zero
PropertyBase * pb = new EntityProperty;
assert(pb->flags().m_flags == 0);
delete pb;
}
{
// Check getting the value fails when property is unassigned
Element val;
PropertyBase * pb = new EntityProperty;
assert(pb->get(val) == -1);
delete pb;
}
{
// Check that setting the value to a pointer works
Entity ent("1", 1);
PropertyBase * pb = new EntityProperty;
pb->set(Atlas::Message::Element(&ent));
delete pb;
}
{
// Check that setting the value to a pointer works can get retrieved
Entity ent("1", 1);
Element val;
PropertyBase * pb = new EntityProperty;
pb->set(Atlas::Message::Element(&ent));
assert(pb->get(val) == 0);
assert(val.isMap());
assert(val.asMap().find("$eid")->second == ent.getId());
delete pb;
}
{
// Check that adding the uninitialised value to a message works.
MapType map;
static const std::string key = "foo";
PropertyBase * pb = new EntityProperty;
MapType::const_iterator I = map.find(key);
assert(I == map.end());
pb->add(key, map);
I = map.find(key);
assert(I != map.end());
assert(I->second.isString());
assert(I->second.String().empty());
delete pb;
}
{
// Check that adding the uninitialised value to an argument works.
Anonymous arg;
static const std::string key = "foo";
Element val;
PropertyBase * pb = new EntityProperty;
assert(!arg->hasAttr(key));
assert(arg->copyAttr(key, val) != 0);
pb->add(key, arg);
assert(arg->hasAttr(key));
assert(arg->copyAttr(key, val) == 0);
assert(val.isString());
assert(val.String().empty());
delete pb;
}
{
// Check that adding the uninitialised value to an argument as a hard
// attribute works
Anonymous arg;
static const std::string key = "id";
Element val;
PropertyBase * pb = new EntityProperty;
assert(!arg->hasAttr(key));
// Hard coded attribute ID has not been set, so returns false, but
// copying it gives us the default
assert(arg->copyAttr(key, val) == 0);
assert(val.isString());
//.........这里部分代码省略.........