本文整理汇总了C++中PropertyList::add方法的典型用法代码示例。如果您正苦于以下问题:C++ PropertyList::add方法的具体用法?C++ PropertyList::add怎么用?C++ PropertyList::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropertyList
的用法示例。
在下文中一共展示了PropertyList::add方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST(tabledesc, test) {
TableDescBuilder tableBuilder;
tableBuilder.setTableId(0x11);
tableBuilder.setConfig(kFakeFlags);
TableModPropertyEviction eviction;
eviction.setFlags(0x31323334);
TableModPropertyVacancy vacancy;
vacancy.setVacancyDown(0x41);
vacancy.setVacancyUp(0x51);
vacancy.setVacancy(0x61);
PropertyList properties;
properties.add(eviction);
properties.add(vacancy);
tableBuilder.setProperties(properties);
MemoryChannel channel{OFP_VERSION_5};
tableBuilder.write(&channel);
channel.flush();
EXPECT_HEX("001811002122232400020008313233340003000841516100", channel.data(),
channel.size());
}
示例2:
TEST(setasync, builder) {
PropertyList props;
props.add(AsyncConfigPropertyPacketInSlave{kPacketInFlags});
props.add(AsyncConfigPropertyPacketInMaster{kPacketInFlags});
props.add(AsyncConfigPropertyPortStatusSlave{kPortStatusFlags});
props.add(AsyncConfigPropertyPortStatusMaster{kPortStatusFlags});
props.add(AsyncConfigPropertyFlowRemovedSlave{kFlowRemovedFlags});
props.add(AsyncConfigPropertyFlowRemovedMaster{kFlowRemovedFlags});
SetAsyncBuilder builder;
builder.setProperties(props);
{
MemoryChannel channel{OFP_VERSION_5};
builder.send(&channel);
EXPECT_HEX(
"051C003800000001000000081111111200010008111111120002000822222221000300"
"082222222100040008333333310005000833333331",
channel.data(), channel.size());
}
{
MemoryChannel channel{OFP_VERSION_4};
builder.send(&channel);
EXPECT_HEX(
"041C002000000001111111121111111222222221222222213333333133333331",
channel.data(), channel.size());
}
}
示例3: parseCommandUrl
// Example: /category/command?arg1=value&arg2=value
bool IseServerInspector::parseCommandUrl(const HttpRequest& request,
string& category, string& command, PropertyList& argList)
{
bool result = false;
string url = request.getUrl();
string argStr;
StrList strList;
if (!url.empty() && url[0] == '/')
url.erase(0, 1);
// find the splitter char ('?')
string::size_type argPos = url.find('?');
bool hasArgs = (argPos != string::npos);
if (hasArgs)
{
argStr = url.substr(argPos + 1);
url.erase(argPos);
}
// parse the string before the '?'
splitString(url, '/', strList, true);
if (strList.getCount() >= 2)
{
category = strList[0];
command = strList[1];
result = true;
}
// parse the args
if (result)
{
argList.clear();
splitString(argStr, '&', strList, true);
for (int i = 0; i < strList.getCount(); ++i)
{
StrList parts;
splitString(strList[i], '=', parts, true);
if (parts.getCount() == 2 && !parts[0].empty())
{
argList.add(parts[0], parts[1]);
}
}
}
return result;
}
示例4:
TEST(rolestatus, builder) {
RoleStatusBuilder msg;
msg.setRole(OFPCR_ROLE_MASTER);
msg.setReason(kFakeReason);
msg.setGenerationId(0x2222222222222222);
PropertyList props;
props.add(RoleStatusPropertyExperimenter{0x12345678, 0xABACABAC, {"foo", 3}});
msg.setProperties(props);
MemoryChannel channel{OFP_VERSION_5};
(void)msg.send(&channel);
EXPECT_EQ(40, channel.size());
EXPECT_HEX(
"051E00280000000100000002110000002222222222222222FFFF000F12345678ABACABAC"
"666F6F00",
channel.data(), channel.size());
Message message{channel.data(), channel.size()};
message.normalize();
const RoleStatus *m = RoleStatus::cast(&message);
EXPECT_TRUE(m);
EXPECT_EQ(OFPCR_ROLE_MASTER, m->role());
EXPECT_EQ(kFakeReason, m->reason());
EXPECT_EQ(0x2222222222222222, m->generationId());
EXPECT_EQ(1, m->properties().itemCount());
for (auto &iter : m->properties()) {
EXPECT_EQ(RoleStatusPropertyExperimenter::type(), iter.type());
auto &expProp = iter.property<RoleStatusPropertyExperimenter>();
EXPECT_EQ(0x12345678, expProp.experimenter());
EXPECT_EQ(0xABACABAC, expProp.expType());
EXPECT_EQ(ByteRange("foo", 3), expProp.expData());
}
}