本文整理汇总了C++中StringBijection类的典型用法代码示例。如果您正苦于以下问题:C++ StringBijection类的具体用法?C++ StringBijection怎么用?C++ StringBijection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StringBijection类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
int
NWWriter_OpenDrive::getID(const std::string& origID, StringBijection<int>& map, int& lastID) {
if (map.hasString(origID)) {
return map.get(origID);
}
map.insert(origID, lastID++);
return lastID - 1;
}
示例2: InvalidArgument
SUMOVehicleClass
getVehicleClassID(const std::string& name) {
if (SumoVehicleClassStrings.hasString(name)) {
return SumoVehicleClassStrings.get(name);
}
throw InvalidArgument("Unknown vehicle class '" + name + "'.");
}
示例3: sta
SVCPermissions
parseVehicleClasses(const std::string& allowedS) {
if (allowedS == "all") {
return SVCAll;
}
// check if allowedS was previously cached
if (parseVehicleClassesCached.count(allowedS) == 0) {
SVCPermissions result = 0;
StringTokenizer sta(allowedS, " ");
while (sta.hasNext()) {
const std::string s = sta.next();
if (!SumoVehicleClassStrings.hasString(s)) {
WRITE_ERROR("Unknown vehicle class '" + s + "' encountered.");
} else {
const SUMOVehicleClass vc = getVehicleClassID(s);
const std::string& realName = SumoVehicleClassStrings.getString(vc);
if (realName != s) {
deprecatedVehicleClassesSeen.insert(s);
}
result |= vc;
}
}
// save parsed vehicle class cached
parseVehicleClassesCached[allowedS] = result;
}
return parseVehicleClassesCached.at(allowedS);
}
示例4:
int
getVehicleClassCompoundID(const std::string& name) {
int ret = SVC_IGNORING;
const std::vector<std::string> names = SumoVehicleClassStrings.getStrings();
for (std::vector<std::string>::const_iterator it = names.begin(); it != names.end(); it++) {
if (name.find(*it) != std::string::npos) {
ret = ret | (int) SumoVehicleClassStrings.get(*it);
}
}
return ret;
}
示例5:
std::vector<std::string>
getVehicleClassNamesList(SVCPermissions permissions) {
/// @todo cache values?
const std::vector<std::string> classNames = SumoVehicleClassStrings.getStrings();
std::vector<std::string> result;
for (std::vector<std::string>::const_iterator it = classNames.begin(); it != classNames.end(); it++) {
const int svc = (int)SumoVehicleClassStrings.get(*it);
if ((svc & permissions) == svc && svc != SVC_IGNORING) {
result.push_back(*it);
}
}
return result;
}
示例6: getVehicleClassID
SVCPermissions
parseVehicleClasses(const std::vector<std::string>& allowedS) {
SVCPermissions result = 0;
for (std::vector<std::string>::const_iterator i = allowedS.begin(); i != allowedS.end(); ++i) {
const SUMOVehicleClass vc = getVehicleClassID(*i);
const std::string& realName = SumoVehicleClassStrings.getString(vc);
if (realName != *i) {
WRITE_WARNING("The vehicle class '" + (*i) + "' is deprecated, use '" + realName + "' instead.");
}
result |= getVehicleClassID(*i);
}
return result;
}
示例7: sta
bool
canParseVehicleClasses(const std::string& classes) {
if (classes == "all") {
return true;
}
StringTokenizer sta(classes, " ");
while (sta.hasNext()) {
if (!SumoVehicleClassStrings.hasString(sta.next())) {
return false;
}
}
return true;
}
示例8: if
void
writePermissions(OutputDevice& into, SVCPermissions permissions) {
if (permissions == SVCAll) {
return;
} else if (permissions == 0) {
into.writeAttr(SUMO_ATTR_DISALLOW, "all");
return;
} else {
int num_allowed = 0;
for (int mask = 1; mask <= SUMOVehicleClass_MAX; mask = mask << 1) {
if ((mask & permissions) == mask) {
++num_allowed;
}
}
if (num_allowed <= (SumoVehicleClassStrings.size() - num_allowed) && num_allowed > 0) {
into.writeAttr(SUMO_ATTR_ALLOW, getVehicleClassNames(permissions));
} else {
into.writeAttr(SUMO_ATTR_DISALLOW, getVehicleClassNames(~permissions));
}
}
}