本文整理汇总了C++中ConfigMap类的典型用法代码示例。如果您正苦于以下问题:C++ ConfigMap类的具体用法?C++ ConfigMap怎么用?C++ ConfigMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConfigMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getMultiConfigItem
StringArray
getMultiConfigItem(const ConfigMap& configItems, const String &itemName, const StringArray& defRetVal, const char* tokenizeSeparator)
{
ConfigMap::const_iterator item = configItems.find(itemName);
if (item != configItems.end())
{
StringArray rv;
rv.reserve(item->second.size());
for (size_t i = 0; i < item->second.size(); ++i)
{
if (tokenizeSeparator)
{
StringArray tokenizedValue(item->second[i].value.tokenize(tokenizeSeparator));
rv.insert(rv.end(), tokenizedValue.begin(), tokenizedValue.end());
}
else
{
rv.push_back(item->second[i].value);
}
}
return rv;
}
else
{
return defRetVal;
}
}
示例2: NaoBody
bool Settings::load()
{
#ifdef TARGET_ROBOT
robot = NaoBody().getName();
#else
robot = "Nao";
#endif
bool loadedSettingsFromFile = false;
#ifdef TARGET_ROBOT
// load settings from team.cfg
try
{
ConfigMap teams;
if(teams.read("teams.cfg", false, &ConfigMap::printOnErr) >= 0)
{
teams.setFlags(teams.getFlags() | ConfigMap::READONLY);
std::vector<std::string> keys = teams.getKeys();
for(std::vector<std::string>::const_iterator i = keys.begin(), end = keys.end(); i != end; ++i)
{
const ConfigValue& teamValue = teams[*i];
if(teamValue.getType() != ConfigValue::MAP)
continue;
const ConfigMap& team = teamValue;
if(!team.hasKey("players"))
continue;
const ConfigValue& playersValue = team["players"];
if(playersValue.getType() != ConfigValue::LIST)
continue;
const ListConfigValue& players = playersValue;
for(int i = 0, len = players.length(); i < len; ++i)
{
const ConfigValue& playersValue = players[i];
if(playersValue.getType() != ConfigValue::PLAIN)
continue;
if(((const PlainConfigValue&)playersValue).str() == robot)
{
playerNumber = i + 1;
team["number"] >> teamNumber;
teamPort = 10001 + teamNumber * 100;
team["location"] >> location;
std::string entryName;
team["color"] >> entryName;
if(entryName == "blue")
teamColor = TEAM_BLUE;
else if(entryName == "red")
teamColor = TEAM_RED;
else
ASSERT(false);
loadedSettingsFromFile = true;
goto loadedTeamsCfg;
}
}
}
loadedTeamsCfg:
;
}
示例3: ap
Command::ConfigList Command::selectedConfigs(MasterDevice &m)
{
unsigned int i;
ec_ioctl_master_t master;
ec_ioctl_config_t config;
ConfigList list;
stringstream err;
m.getMaster(&master);
if (aliases == "-" && positions == "-") { // shortcut
for (i = 0; i < master.config_count; i++) {
m.getConfig(&config, i);
list.push_back(config);
}
} else { // take the long way home...
ConfigMap configs;
uint16_t maxAlias = 0;
// fill cascaded map structure with all configs
for (i = 0; i < master.config_count; i++) {
m.getConfig(&config, i);
AliasMap &aliasMap = configs[config.alias];
aliasMap[config.position] = config;
if (config.alias > maxAlias) {
maxAlias = config.alias;
}
}
ConfigAliasParser ap(maxAlias);
NumberListParser::List aliasList = ap.parse(aliases.c_str());
NumberListParser::List::const_iterator ai;
for (ai = aliasList.begin(); ai != aliasList.end(); ai++) {
ConfigMap::iterator ci = configs.find(*ai);
if (ci == configs.end()) {
continue;
}
AliasMap &aliasMap = configs[*ai];
AliasPositionParser pp(aliasMap);
NumberListParser::List posList = pp.parse(positions.c_str());
NumberListParser::List::const_iterator pi;
for (pi = posList.begin(); pi != posList.end(); pi++) {
AliasMap::const_iterator ci;
ci = aliasMap.find(*pi);
if (ci != aliasMap.end()) {
list.push_back(ci->second);
}
}
}
}
list.sort();
return list;
}
示例4: getConfig
/* getConfig: {{{ */
int getConfig(ConfigMap &config, const string &name, int def) {
ConfigMap::iterator it=config.find(name);
if(it!=config.end())
return atoi(config[name].c_str());
cerr << "[W] Key : '" << name << "' not found, using default value : "
<< def << endl;
return def;
}
示例5: getSettingsString
std::string Robot::getSettingsString(const Team& team) const
{
ConfigMap cm;
cm["teamNumber"] << team.number;
cm["teamPort"] << team.port;
cm["teamColor"] << team.color;
cm["playerNumber"] << team.getPlayerNumber(*this);
cm["location"] << team.location;
return cm.str();
}
示例6: GetConfigValue
bool GetConfigValue(ConfigMap& configMap, std::string key, std::string& value) {
if(configMap.find(key) != configMap.end()) {
value = configMap[key];
string trimmedKey = trim(value);
if(trimmedKey == "") {
return false;
}
return true;
}
return false;
}
示例7: saveTeams
void TeamSelector::saveTeams(const QString& filename)
{
std::vector<Team> _teams;
_teams.reserve(teams.size());
for(size_t i = 0; i < teams.size(); ++i)
_teams.push_back(*teams[i]);
ConfigMap cm;
Team::writeTeams(cm, _teams);
std::string fn = toString(filename);
cm.write(&fn);
}
示例8: saveTrainingData
bool ColorTableCreator::saveTrainingData(string fileName) const
{
ConfigMap cm;
cm["handMadeClassification"] << handMadeClassification;
ofstream of;
of.open(fileName.c_str());
if(!of.is_open())
return false;
cm.write(of);
of.close();
return true;
}
示例9: getConfigItem
String
getConfigItem(const ConfigMap& configItems, const String &itemName, const String& defRetVal)
{
ConfigMap::const_iterator i = configItems.find(itemName);
if (i != configItems.end() && i->second.size() > 0)
{
return i->second.back().value;
}
else
{
return defRetVal;
}
}
示例10: dumpConfigMapToYaml
static void dumpConfigMapToYaml(YAML::Emitter &emitter,
const ConfigMap &configMap) {
emitter << YAML::BeginMap;
ConfigMap::const_iterator it;
for(it = configMap.begin(); it != configMap.end(); ++it) {
emitter << YAML::Key << it->first;
if(!(emitter.good())) {
fprintf(stderr, "problem with ConfigMap for: %s\n", it->first.c_str());
}
emitter << YAML::Value;
dumpConfigVectorToYaml(emitter, it->second);
}
emitter << YAML::EndMap;
}
示例11: float
void BallPerceptor::init(const FieldDimensions& theFieldDimensions)
{
sqrMaxBallDistance = float(Vector2<int>(theFieldDimensions.xPosOpponentFieldBorder - theFieldDimensions.xPosOwnFieldBorder,
theFieldDimensions.yPosLeftFieldBorder - theFieldDimensions.yPosRightFieldBorder).squareAbs());
/*
cout << "theFieldDimensions.xPosOpponentFieldBorder: " << theFieldDimensions.xPosOpponentFieldBorder << endl;
cout << "theFieldDimensions.xPosOwnFieldBorder: " << theFieldDimensions.xPosOwnFieldBorder << endl;
cout << "theFieldDimensions.yPosLeftFieldBorder: " << theFieldDimensions.yPosLeftFieldBorder << endl;
cout << "theFieldDimensions.yPosRightFieldBorder: " << theFieldDimensions.yPosRightFieldBorder << endl;
*/
ConfigMap params;
params["clippingApproxRadiusScale"] << 2.f;
params["clippingApproxRadiusPixelBonus"] << 2.5f;
params["scanMaxColorDistance"] << (unsigned int) 30;
params["scanPixelTolerance"] << (unsigned int) 2;
params["refineMaxPixelCount"] << (unsigned int) 2;
params["refineMaxColorDistance"] << (unsigned int) 40;
params["checkMaxRadiusDifference"] << 1.6f;
params["checkMinRadiusDifference"] << 0.9f;
params["checkMinRadiusPixelBonus"] << 6.f;
params["checkOutlineRadiusScale"] << 1.1f;
params["checkOutlineRadiusPixelBonus"] << 2.f;
//params.read(Global::getSettings().expandRobotLocationFilename("ballPerceptor.cfg"));
params.read("/home/nao/.config/naoqi/Data/Config/Locations/Default/Robots/Nao/ballPerceptor.cfg");
params["clippingApproxRadiusScale"] >> p.clippingApproxRadiusScale;
params["clippingApproxRadiusPixelBonus"] >> p.clippingApproxRadiusPixelBonus;
params["scanMaxColorDistance"] >> p.scanMaxColorDistance;
params["scanPixelTolerance"] >> p.scanPixelTolerance;
params["refineMaxPixelCount"] >> p.refineMaxPixelCount;
params["refineMaxColorDistance"] >> p.refineMaxColorDistance;
params["checkMaxRadiusDifference"] >> p.checkMaxRadiusDifference;
params["checkMinRadiusDifference"] >> p.checkMinRadiusDifference;
params["checkMinRadiusPixelBonus"] >> p.checkMinRadiusPixelBonus;
params["checkOutlineRadiusScale"] >> p.checkOutlineRadiusScale;
params["checkOutlineRadiusPixelBonus"] >> p.checkOutlineRadiusPixelBonus;
}
示例12: main
/* main method {{{ */
int main(int argc, char *argv[]) {
ConfigMap config;
if(!parseOptions(argc,argv,config)) { //Parse cmd line options
cerr << "==> Try '" << argv[0] << " --usage'" << endl;
return -1;
}
if(config.find("usage")!=config.end()||config.find("help")!=config.end()) {
usage(argv[0]);
return -1;
}
if(!parseConfig(config)) {
cerr << "==> Try 'man " << argv[0] << "'" << endl;
return -1;
}
return mainFunction(config);
}
示例13: setConfigItem
void
setConfigItem(ConfigMap& configItems, const String& itemName,
const String& value, EOverwritePreviousFlag overwritePrevious)
{
ConfigMap::iterator it = configItems.find(itemName);
if (it == configItems.end())
{
configItems[itemName].push_back(ItemData("", value));
}
else if (overwritePrevious == E_OVERWRITE_PREVIOUS)
{
ItemDataArray& values = configItems[itemName];
values.clear();
values.push_back(ItemData("", value));
}
// else overwritePrevious == E_PRESERVE_PREVIOUS, and do nothing
}
示例14: loadTrainingData
bool ColorTableCreator::loadTrainingData(string fileName)
{
handMadeClassification.clear();
ConfigMap cm;
if(cm.read(fileName) < 0)
return false;
try
{
cm["handMadeClassification"] >> handMadeClassification;
}
catch(std::invalid_argument e)
{
return false;
} //In this case the Vector was empty
return true;
}
示例15: context_
ompl::tools::SelfConfig::SelfConfig(const base::SpaceInformationPtr &si, const std::string &context) : context_(context)
{
typedef std::map<base::SpaceInformation*, boost::shared_ptr<SelfConfigImpl> > ConfigMap;
static ConfigMap SMAP;
static boost::mutex LOCK;
boost::mutex::scoped_lock smLock(LOCK);
ConfigMap::const_iterator it = SMAP.find(si.get());
if (it != SMAP.end())
impl_ = it->second.get();
else
{
impl_ = new SelfConfigImpl(si);
SMAP[si.get()].reset(impl_);
}
}