本文整理汇总了C++中Switch::parse方法的典型用法代码示例。如果您正苦于以下问题:C++ Switch::parse方法的具体用法?C++ Switch::parse怎么用?C++ Switch::parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Switch
的用法示例。
在下文中一共展示了Switch::parse方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: reset
int Program::reset() {
try {
discover([this](Packet a) {
datasets d =a.getPayload();
Switch sw = Switch();
sw.parse(d);
cout <<sw.settings.hostname<<"\t";
datasets t = { {SND_PING, 0, {}}};
get(a, t, [this](Packet a) {
datasets d =a.getPayload();
Switch sw = Switch();
sw.parse(d);
datasets t = { {RESET, 0, {}}};
set(a,t,[this](Packet a) {
if( a.getOpCode()==Packet::CONFIRM)
cout<< "reseting config.\n";
return 0;
});
return 0;
});
return 0;
});
} catch (exception& e) {
cerr << "Exception: " << e.what() << "\n";
}
return 0;
}
示例2: getProperty
int Program::getProperty(vector<string> prop) {
try {
datasets data = { };
for (string s : prop) {
dataset d;
d.type = snd_lookup.type(s);
data.push_back(d);
}
cout << "List:\n";
discover([this,data](Packet a) {
datasets d =a.getPayload();
Switch sw = Switch();
sw.parse(d);
sw.print();
get(a, data, [this](Packet a) {
cout << a.opCodeToString() << "\n";
printHeader(a);
printPacket(a);
return 0;
});
return 0;
});
} catch (exception& e) {
cerr << "Exception: " << e.what() << "\n";
}
return 0;
}
示例3: restore
int Program::restore() {
File f;
Switch sw;
sw.parse(f.read());
sw.print();
return 0;
}
示例4: setProperty
int Program::setProperty(map<string, string> prop) {
try {
datasets data = { };
for (auto p : prop) {
string s = p.second;
dataset d;
if (rcv_lookup.exists(p.first)) {
d.type = rcv_lookup.type(p.first);
if (rcv_lookup[p.first].format == table::STRING) {
d.len = s.size() + 1;
d.value = s;
data.push_back(d);
}
}
}
cout << "List:\n";
discover([this,data](Packet a) {
datasets d =a.getPayload();
Switch sw = Switch();
sw.parse(d);
sw.print();
datasets t = { {SND_PING, 0, {}}};
get(a, t, [this,data](Packet a) {
datasets d =a.getPayload();
Switch sw = Switch();
sw.parse(d);
set(a,data,
[this](Packet a) {
cout << a.opCodeToString() << "\n";
printHeader(a);
printPacket(a);
return 0;
});
return 0;
});
return 0;
});
} catch (exception& e) {
cerr << "Exception: " << e.what() << "\n";
}
return 0;
}