diff options
author | Elias Fleckenstein <eliasfleckenstein@web.de> | 2020-11-04 16:19:54 +0100 |
---|---|---|
committer | Elias Fleckenstein <eliasfleckenstein@web.de> | 2020-11-04 16:19:54 +0100 |
commit | ad148587dcf5244c2d2011dba339786c765c54c4 (patch) | |
tree | bdd914121cd326da2ed26679838878e3edffc841 /src/settings.cpp | |
parent | 1145b05ea0bda87dc0827821385810eced08f774 (diff) | |
download | dragonfireclient-ad148587dcf5244c2d2011dba339786c765c54c4.tar.xz |
Make Lint Happy
Diffstat (limited to 'src/settings.cpp')
-rw-r--r-- | src/settings.cpp | 237 |
1 files changed, 84 insertions, 153 deletions
diff --git a/src/settings.cpp b/src/settings.cpp index 55404319e..4f8b7b617 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -42,16 +42,14 @@ Settings::~Settings() clear(); } - -Settings & Settings::operator += (const Settings &other) +Settings &Settings::operator+=(const Settings &other) { update(other); return *this; } - -Settings & Settings::operator = (const Settings &other) +Settings &Settings::operator=(const Settings &other) { if (&other == this) return *this; @@ -65,7 +63,6 @@ Settings & Settings::operator = (const Settings &other) return *this; } - bool Settings::checkNameValid(const std::string &name) { bool valid = name.find_first_of("=\"{}#") == std::string::npos; @@ -73,20 +70,19 @@ bool Settings::checkNameValid(const std::string &name) valid = std::find_if(name.begin(), name.end(), ::isspace) == name.end(); if (!valid) { - errorstream << "Invalid setting name \"" << name << "\"" - << std::endl; + errorstream << "Invalid setting name \"" << name << "\"" << std::endl; return false; } return true; } - bool Settings::checkValueValid(const std::string &value) { if (value.substr(0, 3) == "\"\"\"" || - value.find("\n\"\"\"") != std::string::npos) { + value.find("\n\"\"\"") != std::string::npos) { errorstream << "Invalid character sequence '\"\"\"' found in" - " setting value!" << std::endl; + " setting value!" + << std::endl; return false; } return true; @@ -117,7 +113,6 @@ std::string Settings::getMultiline(std::istream &is, size_t *num_lines) return value; } - bool Settings::readConfigFile(const char *filename) { std::ifstream is(filename); @@ -127,7 +122,6 @@ bool Settings::readConfigFile(const char *filename) return parseConfigLines(is, ""); } - bool Settings::parseConfigLines(std::istream &is, const std::string &end) { MutexAutoLock lock(m_mutex); @@ -166,7 +160,6 @@ bool Settings::parseConfigLines(std::istream &is, const std::string &end) return end.empty(); } - void Settings::writeLines(std::ostream &os, u32 tab_depth) const { MutexAutoLock lock(m_mutex); @@ -175,9 +168,8 @@ void Settings::writeLines(std::ostream &os, u32 tab_depth) const printEntry(os, setting_it.first, setting_it.second, tab_depth); } - void Settings::printEntry(std::ostream &os, const std::string &name, - const SettingsEntry &entry, u32 tab_depth) + const SettingsEntry &entry, u32 tab_depth) { for (u32 i = 0; i != tab_depth; i++) os << "\t"; @@ -200,9 +192,8 @@ void Settings::printEntry(std::ostream &os, const std::string &name, } } - -bool Settings::updateConfigObject(std::istream &is, std::ostream &os, - const std::string &end, u32 tab_depth) +bool Settings::updateConfigObject( + std::istream &is, std::ostream &os, const std::string &end, u32 tab_depth) { SettingEntries::const_iterator it; std::set<std::string> present_entries; @@ -227,7 +218,8 @@ bool Settings::updateConfigObject(std::istream &is, std::ostream &os, case SPE_KVPAIR: it = m_settings.find(name); if (it != m_settings.end() && - (it->second.is_group || it->second.value != value)) { + (it->second.is_group || + it->second.value != value)) { printEntry(os, name, it->second, tab_depth); was_modified = true; } else if (it == m_settings.end()) { @@ -246,14 +238,15 @@ bool Settings::updateConfigObject(std::istream &is, std::ostream &os, if (it != m_settings.end() && it->second.is_group) { os << line << "\n"; sanity_check(it->second.group != NULL); - was_modified |= it->second.group->updateConfigObject(is, os, - "}", tab_depth + 1); + was_modified |= it->second.group->updateConfigObject( + is, os, "}", tab_depth + 1); } else if (it == m_settings.end()) { // Remove by skipping was_modified = true; Settings removed_group; // Move 'is' to group end std::stringstream ss; - removed_group.updateConfigObject(is, ss, "}", tab_depth + 1); + removed_group.updateConfigObject( + is, ss, "}", tab_depth + 1); break; } else { printEntry(os, name, it->second, tab_depth); @@ -279,7 +272,6 @@ bool Settings::updateConfigObject(std::istream &is, std::ostream &os, return was_modified; } - bool Settings::updateConfigFile(const char *filename) { MutexAutoLock lock(m_mutex); @@ -294,32 +286,31 @@ bool Settings::updateConfigFile(const char *filename) return true; if (!fs::safeWriteToFile(filename, os.str())) { - errorstream << "Error writing configuration file: \"" - << filename << "\"" << std::endl; + errorstream << "Error writing configuration file: \"" << filename << "\"" + << std::endl; return false; } return true; } - -bool Settings::parseCommandLine(int argc, char *argv[], - std::map<std::string, ValueSpec> &allowed_options) +bool Settings::parseCommandLine( + int argc, char *argv[], std::map<std::string, ValueSpec> &allowed_options) { int nonopt_index = 0; for (int i = 1; i < argc; i++) { std::string arg_name = argv[i]; if (arg_name.substr(0, 2) != "--") { // If option doesn't start with -, read it in as nonoptX - if (arg_name[0] != '-'){ + if (arg_name[0] != '-') { std::string name = "nonopt"; name += itos(nonopt_index); set(name, arg_name); nonopt_index++; continue; } - errorstream << "Invalid command-line parameter \"" - << arg_name << "\": --<option> expected." << std::endl; + errorstream << "Invalid command-line parameter \"" << arg_name + << "\": --<option> expected." << std::endl; return false; } @@ -328,8 +319,8 @@ bool Settings::parseCommandLine(int argc, char *argv[], std::map<std::string, ValueSpec>::iterator n; n = allowed_options.find(name); if (n == allowed_options.end()) { - errorstream << "Unknown command-line parameter \"" - << arg_name << "\"" << std::endl; + errorstream << "Unknown command-line parameter \"" << arg_name + << "\"" << std::endl; return false; } @@ -341,8 +332,8 @@ bool Settings::parseCommandLine(int argc, char *argv[], value = "true"; } else { if ((i + 1) >= argc) { - errorstream << "Invalid command-line parameter \"" - << name << "\": missing value" << std::endl; + errorstream << "Invalid command-line parameter \"" << name + << "\": missing value" << std::endl; return false; } value = argv[++i]; @@ -354,13 +345,10 @@ bool Settings::parseCommandLine(int argc, char *argv[], return true; } - - /*********** * Getters * ***********/ - const SettingsEntry &Settings::getEntry(const std::string &name) const { MutexAutoLock lock(m_mutex); @@ -368,12 +356,12 @@ const SettingsEntry &Settings::getEntry(const std::string &name) const SettingEntries::const_iterator n; if ((n = m_settings.find(name)) == m_settings.end()) { if ((n = m_defaults.find(name)) == m_defaults.end()) - throw SettingNotFoundException("Setting [" + name + "] not found."); + throw SettingNotFoundException( + "Setting [" + name + "] not found."); } return n->second; } - const SettingsEntry &Settings::getEntryDefault(const std::string &name) const { MutexAutoLock lock(m_mutex); @@ -385,7 +373,6 @@ const SettingsEntry &Settings::getEntryDefault(const std::string &name) const return n->second; } - Settings *Settings::getGroup(const std::string &name) const { const SettingsEntry &entry = getEntry(name); @@ -394,7 +381,6 @@ Settings *Settings::getGroup(const std::string &name) const return entry.group; } - const std::string &Settings::get(const std::string &name) const { const SettingsEntry &entry = getEntry(name); @@ -403,7 +389,6 @@ const std::string &Settings::get(const std::string &name) const return entry.value; } - const std::string &Settings::getDefault(const std::string &name) const { const SettingsEntry &entry = getEntryDefault(name); @@ -412,28 +397,24 @@ const std::string &Settings::getDefault(const std::string &name) const return entry.value; } - bool Settings::getBool(const std::string &name) const { return is_yes(get(name)); } - u16 Settings::getU16(const std::string &name) const { return stoi(get(name), 0, 65535); } - s16 Settings::getS16(const std::string &name) const { return stoi(get(name), -32768, 32767); } - u32 Settings::getU32(const std::string &name) const { - return (u32) stoi(get(name)); + return (u32)stoi(get(name)); } s32 Settings::getS32(const std::string &name) const @@ -441,13 +422,11 @@ s32 Settings::getS32(const std::string &name) const return stoi(get(name)); } - float Settings::getFloat(const std::string &name) const { return stof(get(name)); } - u64 Settings::getU64(const std::string &name) const { u64 value = 0; @@ -457,7 +436,6 @@ u64 Settings::getU64(const std::string &name) const return value; } - v2f Settings::getV2F(const std::string &name) const { v2f value; @@ -468,7 +446,6 @@ v2f Settings::getV2F(const std::string &name) const return value; } - v3f Settings::getV3F(const std::string &name) const { v3f value; @@ -480,9 +457,8 @@ v3f Settings::getV3F(const std::string &name) const return value; } - -u32 Settings::getFlagStr(const std::string &name, const FlagDesc *flagdesc, - u32 *flagmask) const +u32 Settings::getFlagStr( + const std::string &name, const FlagDesc *flagdesc, u32 *flagmask) const { u32 flags = 0; u32 mask_default = 0; @@ -491,20 +467,19 @@ u32 Settings::getFlagStr(const std::string &name, const FlagDesc *flagdesc, // Read default value (if there is any) if (getDefaultNoEx(name, value)) { flags = std::isdigit(value[0]) - ? stoi(value) - : readFlagString(value, flagdesc, &mask_default); + ? stoi(value) + : readFlagString(value, flagdesc, &mask_default); } // Apply custom flags "on top" value = get(name); u32 flags_user; u32 mask_user = U32_MAX; - flags_user = std::isdigit(value[0]) - ? stoi(value) // Override default - : readFlagString(value, flagdesc, &mask_user); + flags_user = std::isdigit(value[0]) ? stoi(value) // Override default + : readFlagString(value, flagdesc, &mask_user); flags &= ~mask_user; - flags |= flags_user; + flags |= flags_user; if (flagmask) *flagmask = mask_default | mask_user; @@ -514,8 +489,8 @@ u32 Settings::getFlagStr(const std::string &name, const FlagDesc *flagdesc, // N.B. if getStruct() is used to read a non-POD aggregate type, // the behavior is undefined. -bool Settings::getStruct(const std::string &name, const std::string &format, - void *out, size_t olen) const +bool Settings::getStruct(const std::string &name, const std::string &format, void *out, + size_t olen) const { std::string valstr; @@ -531,15 +506,12 @@ bool Settings::getStruct(const std::string &name, const std::string &format, return true; } - bool Settings::getNoiseParams(const std::string &name, NoiseParams &np) const { return getNoiseParamsFromGroup(name, np) || getNoiseParamsFromValue(name, np); } - -bool Settings::getNoiseParamsFromValue(const std::string &name, - NoiseParams &np) const +bool Settings::getNoiseParamsFromValue(const std::string &name, NoiseParams &np) const { std::string value; @@ -548,16 +520,16 @@ bool Settings::getNoiseParamsFromValue(const std::string &name, Strfnd f(value); - np.offset = stof(f.next(",")); - np.scale = stof(f.next(",")); + np.offset = stof(f.next(",")); + np.scale = stof(f.next(",")); f.next("("); np.spread.X = stof(f.next(",")); np.spread.Y = stof(f.next(",")); np.spread.Z = stof(f.next(")")); f.next(","); - np.seed = stoi(f.next(",")); - np.octaves = stoi(f.next(",")); - np.persist = stof(f.next(",")); + np.seed = stoi(f.next(",")); + np.octaves = stoi(f.next(",")); + np.persist = stof(f.next(",")); std::string optional_params = f.next(""); if (!optional_params.empty()) @@ -566,22 +538,20 @@ bool Settings::getNoiseParamsFromValue(const std::string &name, return true; } - -bool Settings::getNoiseParamsFromGroup(const std::string &name, - NoiseParams &np) const +bool Settings::getNoiseParamsFromGroup(const std::string &name, NoiseParams &np) const { Settings *group = NULL; if (!getGroupNoEx(name, group)) return false; - group->getFloatNoEx("offset", np.offset); - group->getFloatNoEx("scale", np.scale); - group->getV3FNoEx("spread", np.spread); - group->getS32NoEx("seed", np.seed); - group->getU16NoEx("octaves", np.octaves); + group->getFloatNoEx("offset", np.offset); + group->getFloatNoEx("scale", np.scale); + group->getV3FNoEx("spread", np.spread); + group->getS32NoEx("seed", np.seed); + group->getU16NoEx("octaves", np.octaves); group->getFloatNoEx("persistence", np.persist); - group->getFloatNoEx("lacunarity", np.lacunarity); + group->getFloatNoEx("lacunarity", np.lacunarity); np.flags = 0; if (!group->getFlagStrNoEx("flags", np.flags, flagdesc_noiseparams)) @@ -590,16 +560,14 @@ bool Settings::getNoiseParamsFromGroup(const std::string &name, return true; } - bool Settings::exists(const std::string &name) const { MutexAutoLock lock(m_mutex); return (m_settings.find(name) != m_settings.end() || - m_defaults.find(name) != m_defaults.end()); + m_defaults.find(name) != m_defaults.end()); } - std::vector<std::string> Settings::getNames() const { std::vector<std::string> names; @@ -609,8 +577,6 @@ std::vector<std::string> Settings::getNames() const return names; } - - /*************************************** * Getters that don't throw exceptions * ***************************************/ @@ -625,7 +591,6 @@ bool Settings::getEntryNoEx(const std::string &name, SettingsEntry &val) const } } - bool Settings::getEntryDefaultNoEx(const std::string &name, SettingsEntry &val) const { try { @@ -636,7 +601,6 @@ bool Settings::getEntryDefaultNoEx(const std::string &name, SettingsEntry &val) } } - bool Settings::getGroupNoEx(const std::string &name, Settings *&val) const { try { @@ -647,7 +611,6 @@ bool Settings::getGroupNoEx(const std::string &name, Settings *&val) const } } - bool Settings::getNoEx(const std::string &name, std::string &val) const { try { @@ -658,7 +621,6 @@ bool Settings::getNoEx(const std::string &name, std::string &val) const } } - bool Settings::getDefaultNoEx(const std::string &name, std::string &val) const { try { @@ -669,17 +631,15 @@ bool Settings::getDefaultNoEx(const std::string &name, std::string &val) const } } - bool Settings::getFlag(const std::string &name) const { try { return getBool(name); - } catch(SettingNotFoundException &e) { + } catch (SettingNotFoundException &e) { return false; } } - bool Settings::getFloatNoEx(const std::string &name, float &val) const { try { @@ -690,7 +650,6 @@ bool Settings::getFloatNoEx(const std::string &name, float &val) const } } - bool Settings::getU16NoEx(const std::string &name, u16 &val) const { try { @@ -701,7 +660,6 @@ bool Settings::getU16NoEx(const std::string &name, u16 &val) const } } - bool Settings::getS16NoEx(const std::string &name, s16 &val) const { try { @@ -712,7 +670,6 @@ bool Settings::getS16NoEx(const std::string &name, s16 &val) const } } - bool Settings::getS32NoEx(const std::string &name, s32 &val) const { try { @@ -723,7 +680,6 @@ bool Settings::getS32NoEx(const std::string &name, s32 &val) const } } - bool Settings::getU64NoEx(const std::string &name, u64 &val) const { try { @@ -734,7 +690,6 @@ bool Settings::getU64NoEx(const std::string &name, u64 &val) const } } - bool Settings::getV2FNoEx(const std::string &name, v2f &val) const { try { @@ -745,7 +700,6 @@ bool Settings::getV2FNoEx(const std::string &name, v2f &val) const } } - bool Settings::getV3FNoEx(const std::string &name, v3f &val) const { try { @@ -756,9 +710,8 @@ bool Settings::getV3FNoEx(const std::string &name, v3f &val) const } } - -bool Settings::getFlagStrNoEx(const std::string &name, u32 &val, - const FlagDesc *flagdesc) const +bool Settings::getFlagStrNoEx( + const std::string &name, u32 &val, const FlagDesc *flagdesc) const { if (!flagdesc) { if (!(flagdesc = getFlagDescFallback(name))) @@ -774,13 +727,12 @@ bool Settings::getFlagStrNoEx(const std::string &name, u32 &val, } } - /*********** * Setters * ***********/ -bool Settings::setEntry(const std::string &name, const void *data, - bool set_group, bool set_default) +bool Settings::setEntry(const std::string &name, const void *data, bool set_group, + bool set_default) { Settings *old_group = NULL; @@ -795,8 +747,8 @@ bool Settings::setEntry(const std::string &name, const void *data, SettingsEntry &entry = set_default ? m_defaults[name] : m_settings[name]; old_group = entry.group; - entry.value = set_group ? "" : *(const std::string *)data; - entry.group = set_group ? *(Settings **)data : NULL; + entry.value = set_group ? "" : *(const std::string *)data; + entry.group = set_group ? *(Settings **)data : NULL; entry.is_group = set_group; } @@ -805,7 +757,6 @@ bool Settings::setEntry(const std::string &name, const void *data, return true; } - bool Settings::set(const std::string &name, const std::string &value) { if (!setEntry(name, &value, false, false)) @@ -815,49 +766,41 @@ bool Settings::set(const std::string &name, const std::string &value) return true; } - bool Settings::setDefault(const std::string &name, const std::string &value) { return setEntry(name, &value, false, true); } - bool Settings::setGroup(const std::string &name, Settings *group) { return setEntry(name, &group, true, false); } - bool Settings::setGroupDefault(const std::string &name, Settings *group) { return setEntry(name, &group, true, true); } - bool Settings::setBool(const std::string &name, bool value) { return set(name, value ? "true" : "false"); } - bool Settings::setS16(const std::string &name, s16 value) { return set(name, itos(value)); } - bool Settings::setU16(const std::string &name, u16 value) { return set(name, itos(value)); } - bool Settings::setS32(const std::string &name, s32 value) { return set(name, itos(value)); } - bool Settings::setU64(const std::string &name, u64 value) { std::ostringstream os; @@ -865,13 +808,11 @@ bool Settings::setU64(const std::string &name, u64 value) return set(name, os.str()); } - bool Settings::setFloat(const std::string &name, float value) { return set(name, ftos(value)); } - bool Settings::setV2F(const std::string &name, v2f value) { std::ostringstream os; @@ -879,7 +820,6 @@ bool Settings::setV2F(const std::string &name, v2f value) return set(name, os.str()); } - bool Settings::setV3F(const std::string &name, v3f value) { std::ostringstream os; @@ -887,9 +827,8 @@ bool Settings::setV3F(const std::string &name, v3f value) return set(name, os.str()); } - -bool Settings::setFlagStr(const std::string &name, u32 flags, - const FlagDesc *flagdesc, u32 flagmask) +bool Settings::setFlagStr(const std::string &name, u32 flags, const FlagDesc *flagdesc, + u32 flagmask) { if (!flagdesc) { if (!(flagdesc = getFlagDescFallback(name))) @@ -899,9 +838,7 @@ bool Settings::setFlagStr(const std::string &name, u32 flags, return set(name, writeFlagString(flags, flagdesc, flagmask)); } - -bool Settings::setStruct(const std::string &name, const std::string &format, - void *value) +bool Settings::setStruct(const std::string &name, const std::string &format, void *value) { std::string structstr; if (!serializeStructToString(&structstr, format, value)) @@ -910,25 +847,23 @@ bool Settings::setStruct(const std::string &name, const std::string &format, return set(name, structstr); } - -bool Settings::setNoiseParams(const std::string &name, - const NoiseParams &np, bool set_default) +bool Settings::setNoiseParams( + const std::string &name, const NoiseParams &np, bool set_default) { Settings *group = new Settings; - group->setFloat("offset", np.offset); - group->setFloat("scale", np.scale); - group->setV3F("spread", np.spread); - group->setS32("seed", np.seed); - group->setU16("octaves", np.octaves); + group->setFloat("offset", np.offset); + group->setFloat("scale", np.scale); + group->setV3F("spread", np.spread); + group->setS32("seed", np.seed); + group->setU16("octaves", np.octaves); group->setFloat("persistence", np.persist); - group->setFloat("lacunarity", np.lacunarity); - group->setFlagStr("flags", np.flags, flagdesc_noiseparams, np.flags); + group->setFloat("lacunarity", np.lacunarity); + group->setFlagStr("flags", np.flags, flagdesc_noiseparams, np.flags); return setEntry(name, &group, true, set_default); } - bool Settings::remove(const std::string &name) { // Lock as short as possible, unlock before doCallbacks() @@ -948,7 +883,6 @@ bool Settings::remove(const std::string &name) return false; } - void Settings::clear() { MutexAutoLock lock(m_mutex); @@ -974,7 +908,6 @@ void Settings::updateValue(const Settings &other, const std::string &name) } } - void Settings::update(const Settings &other) { if (&other == this) @@ -986,9 +919,8 @@ void Settings::update(const Settings &other) updateNoLock(other); } - SettingsParseEvent Settings::parseConfigObject(const std::string &line, - const std::string &end, std::string &name, std::string &value) + const std::string &end, std::string &name, std::string &value) { std::string trimmed_line = trim(line); @@ -1003,7 +935,7 @@ SettingsParseEvent Settings::parseConfigObject(const std::string &line, if (pos == std::string::npos) return SPE_INVALID; - name = trim(trimmed_line.substr(0, pos)); + name = trim(trimmed_line.substr(0, pos)); value = trim(trimmed_line.substr(pos + 1)); if (value == "{") @@ -1014,14 +946,12 @@ SettingsParseEvent Settings::parseConfigObject(const std::string &line, return SPE_KVPAIR; } - void Settings::updateNoLock(const Settings &other) { m_settings.insert(other.m_settings.begin(), other.m_settings.end()); m_defaults.insert(other.m_defaults.begin(), other.m_defaults.end()); } - void Settings::clearNoLock() { @@ -1041,8 +971,7 @@ void Settings::clearDefaultsNoLock() m_defaults.clear(); } -void Settings::setDefault(const std::string &name, const FlagDesc *flagdesc, - u32 flags) +void Settings::setDefault(const std::string &name, const FlagDesc *flagdesc, u32 flags) { m_flags[name] = flagdesc; setDefault(name, writeFlagString(flags, flagdesc, U32_MAX)); @@ -1062,9 +991,11 @@ void Settings::overrideDefaults(Settings *other) u32 flags = getFlagStr(setting.first, flagdesc, nullptr); // 2) Set the flags as defaults other->setDefault(setting.first, flagdesc, flags); - // 3) Get the newly set flags and override the default setting value + // 3) Get the newly set flags and override the default setting + // value setDefault(setting.first, flagdesc, - other->getFlagStr(setting.first, flagdesc, nullptr)); + other->getFlagStr(setting.first, flagdesc, + nullptr)); continue; } // Also covers FlagDesc settings @@ -1078,15 +1009,15 @@ const FlagDesc *Settings::getFlagDescFallback(const std::string &name) const return it == m_flags.end() ? nullptr : it->second; } -void Settings::registerChangedCallback(const std::string &name, - SettingsChangedCallback cbf, void *userdata) +void Settings::registerChangedCallback( + const std::string &name, SettingsChangedCallback cbf, void *userdata) { MutexAutoLock lock(m_callback_mutex); m_callbacks[name].emplace_back(cbf, userdata); } -void Settings::deregisterChangedCallback(const std::string &name, - SettingsChangedCallback cbf, void *userdata) +void Settings::deregisterChangedCallback( + const std::string &name, SettingsChangedCallback cbf, void *userdata) { MutexAutoLock lock(m_callback_mutex); SettingsCallbackMap::iterator it_cbks = m_callbacks.find(name); @@ -1094,8 +1025,8 @@ void Settings::deregisterChangedCallback(const std::string &name, if (it_cbks != m_callbacks.end()) { SettingsCallbackList &cbks = it_cbks->second; - SettingsCallbackList::iterator position = - std::find(cbks.begin(), cbks.end(), std::make_pair(cbf, userdata)); + SettingsCallbackList::iterator position = std::find( + cbks.begin(), cbks.end(), std::make_pair(cbf, userdata)); if (position != cbks.end()) cbks.erase(position); |