48 virtual ~Map()
override;
56 size_t Size() const noexcept {
return data.size(); }
58 bool IsEmpty() const noexcept {
return data.empty(); }
69 void Set(
const String &key, SObject value);
72 using iterator = std::map<String, SObject>::iterator;
77 void Remove(
const SObject &obj);
83 void Clear() noexcept { data.clear(); }
120 using pair = std::pair<const crn::String, SObject>;
123 std::set<String>
GetKeys()
const;
130 void Swap(
Map &other) noexcept;
132 std::map<String, SObject>
Std() && {
return std::move(data); }
143 std::map<String, SObject> data;
String FirstKey() const
Returns the first (lowest) key.
void Clear() noexcept
Empties the map.
iterator Find(const String &key)
Returns an iterator to a specific key.
#define CRN_ADD_RANGED_FOR_TO_CONST_POINTERS(TYPE)
Enables ranged for for smart pointers on a type.
const_iterator Find(const String &key) const
Returns a const_iterator to a specific key.
const_iterator cbegin() const
Returns a const iterator to the first element.
void Set(const String &key, SObject value)
Sets a value for a key with constraints check.
void Deserialize(xml::Element &el)
Reads from an XML node if applicable.
#define CRN_ADD_RANGED_FOR_TO_POINTERS(TYPE)
Enables ranged for for smart pointers on a type.
void Remove(const String &key)
Removes an element (safe)
void Load(const Path &fname)
void Swap(Map &other) noexcept
Swaps contents with another map.
A UTF32 character string class.
std::map< String, SObject >::iterator iterator
iterator on the contents of the container
void Save(const Path &fname) const
const_iterator end() const
Returns a const iterator after the last element.
Map()
Default constructor.
String LastKey() const
Returns the last (greatest) key.
const_reverse_iterator rbegin() const
Returns a const reverse iterator to the last element.
SObject & operator[](const String &s)
Returns an object from index. No constraint check is performed if the reference is used as a lvalue...
A convenience class for file paths.
iterator begin()
Returns an iterator to the first element.
xml::Element Serialize(xml::Element &parent) const
Dumps to an XML node if applicable.
reverse_iterator rend()
Returns a reverse iterator before the first element.
std::map< String, SObject >::const_iterator const_iterator
const_iterator on the contents of the container
const_iterator begin() const
Returns a const iterator to the first element.
void Swap(Map &m1, Map &m2) noexcept
const_reverse_iterator rend() const
Returns a const reverse iterator before the first element.
std::map< String, SObject >::reverse_iterator reverse_iterator
reverse_iterator on the contents of the container
const_iterator cend() const
Returns a const iterator after the last element.
SObject Get(const String &s)
Returns an object from index or nullptr if inexistent.
size_t Size() const noexcept
Returns the number of data objects in the map.
bool IsEmpty() const noexcept
Tests if the map is empty.
std::map< String, SObject >::const_reverse_iterator const_reverse_iterator
const_reverse_iterator on the contents of the container
reverse_iterator rbegin()
Returns a reverse iterator to the last element.
#define CRN_DECLARE_CLASS_CONSTRUCTOR(classname)
Declares a class constructor.
std::pair< const crn::String, SObject > pair
A (key, value) pair.
iterator end()
Returns an iterator after the last element.
std::map< String, SObject > Std()&&
Map & operator=(const Map &other)
virtual ~Map() override
Destructor.
std::set< String > GetKeys() const
Returns all keys.