Changeset View
Changeset View
Standalone View
Standalone View
src/util/settings.h
Show First 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | |||||
//! considered negated. | //! considered negated. | ||||
struct SettingsSpan { | struct SettingsSpan { | ||||
explicit SettingsSpan() = default; | explicit SettingsSpan() = default; | ||||
explicit SettingsSpan(const SettingsValue &value) noexcept | explicit SettingsSpan(const SettingsValue &value) noexcept | ||||
: SettingsSpan(&value, 1) {} | : SettingsSpan(&value, 1) {} | ||||
explicit SettingsSpan(const SettingsValue *dataIn, size_t sizeIn) noexcept | explicit SettingsSpan(const SettingsValue *dataIn, size_t sizeIn) noexcept | ||||
: data(dataIn), size(sizeIn) {} | : data(dataIn), size(sizeIn) {} | ||||
explicit SettingsSpan(const std::vector<SettingsValue> &vec) noexcept; | explicit SettingsSpan(const std::vector<SettingsValue> &vec) noexcept; | ||||
const SettingsValue *begin() const; //<! Pointer to first non-negated value. | //! Pointer to first non-negated value. | ||||
const SettingsValue *end() const; //<! Pointer to end of values. | const SettingsValue *begin() const; | ||||
bool empty() const; //<! True if there are any non-negated values. | //! Pointer to end of values. | ||||
bool last_negated() const; //<! True if the last value is negated. | const SettingsValue *end() const; | ||||
size_t negated() const; //<! Number of negated values. | //! True if there are any non-negated values. | ||||
bool empty() const; | |||||
//! True if the last value is negated. | |||||
bool last_negated() const; | |||||
//! Number of negated values. | |||||
size_t negated() const; | |||||
const SettingsValue *data = nullptr; | const SettingsValue *data = nullptr; | ||||
size_t size = 0; | size_t size = 0; | ||||
}; | }; | ||||
//! Map lookup helper. | //! Map lookup helper. | ||||
template <typename Map, typename Key> | template <typename Map, typename Key> | ||||
auto FindKey(Map &&map, Key &&key) -> decltype(&map.at(key)) { | auto FindKey(Map &&map, Key &&key) -> decltype(&map.at(key)) { | ||||
auto it = map.find(key); | auto it = map.find(key); | ||||
return it == map.end() ? nullptr : &it->second; | return it == map.end() ? nullptr : &it->second; | ||||
} | } | ||||
} // namespace util | } // namespace util | ||||
#endif // BITCOIN_UTIL_SETTINGS_H | #endif // BITCOIN_UTIL_SETTINGS_H |