make ConfigFile sections ordered
This commit is contained in:
parent
9aebdd2ae8
commit
1386647cdf
3 changed files with 18 additions and 34 deletions
|
@ -106,8 +106,8 @@ bool ConfigFile::has_section_key(const String &p_section, const String &p_key) c
|
|||
|
||||
void ConfigFile::get_sections(List<String> *r_sections) const {
|
||||
|
||||
for (const Map<String, OrderedHashMap<String, Variant> >::Element *E = values.front(); E; E = E->next()) {
|
||||
r_sections->push_back(E->key());
|
||||
for (OrderedHashMap<String, OrderedHashMap<String, Variant> >::ConstElement E = values.front(); E; E = E.next()) {
|
||||
r_sections->push_back(E.key());
|
||||
}
|
||||
}
|
||||
void ConfigFile::get_section_keys(const String &p_section, List<String> *r_keys) const {
|
||||
|
@ -135,13 +135,13 @@ Error ConfigFile::save(const String &p_path) {
|
|||
return err;
|
||||
}
|
||||
|
||||
for (Map<String, OrderedHashMap<String, Variant> >::Element *E = values.front(); E; E = E->next()) {
|
||||
for (OrderedHashMap<String, OrderedHashMap<String, Variant> >::Element E = values.front(); E; E = E.next()) {
|
||||
|
||||
if (E != values.front())
|
||||
file->store_string("\n");
|
||||
file->store_string("[" + E->key() + "]\n\n");
|
||||
file->store_string("[" + E.key() + "]\n\n");
|
||||
|
||||
for (OrderedHashMap<String, Variant>::Element F = E->get().front(); F; F = F.next()) {
|
||||
for (OrderedHashMap<String, Variant>::Element F = E.get().front(); F; F = F.next()) {
|
||||
|
||||
String vstr;
|
||||
VariantWriter::write_to_string(F.get(), vstr);
|
||||
|
|
|
@ -37,7 +37,7 @@ class ConfigFile : public Reference {
|
|||
|
||||
GDCLASS(ConfigFile, Reference);
|
||||
|
||||
Map<String, OrderedHashMap<String, Variant> > values;
|
||||
OrderedHashMap<String, OrderedHashMap<String, Variant> > values;
|
||||
|
||||
PoolStringArray _get_sections() const;
|
||||
PoolStringArray _get_section_keys(const String &p_section) const;
|
||||
|
|
|
@ -93,8 +93,12 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
friend bool operator==(const Element &, const Element &);
|
||||
friend bool operator!=(const Element &, const Element &);
|
||||
_FORCE_INLINE_ bool operator==(const Element &p_other) const {
|
||||
return this->list_element == p_other.list_element;
|
||||
}
|
||||
_FORCE_INLINE_ bool operator!=(const Element &p_other) const {
|
||||
return this->list_element != p_other.list_element;
|
||||
}
|
||||
|
||||
operator bool() const {
|
||||
return (list_element != NULL);
|
||||
|
@ -157,8 +161,12 @@ public:
|
|||
return ConstElement(list_element ? list_element->prev() : NULL);
|
||||
}
|
||||
|
||||
friend bool operator==(const ConstElement &, const ConstElement &);
|
||||
friend bool operator!=(const ConstElement &, const ConstElement &);
|
||||
_FORCE_INLINE_ bool operator==(const ConstElement &p_other) const {
|
||||
return this->list_element == p_other.list_element;
|
||||
}
|
||||
_FORCE_INLINE_ bool operator!=(const ConstElement &p_other) const {
|
||||
return this->list_element != p_other.list_element;
|
||||
}
|
||||
|
||||
operator bool() const {
|
||||
return (list_element != NULL);
|
||||
|
@ -288,28 +296,4 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
template <class K, class V, class Hasher, class Comparator, uint8_t MIN_HASH_TABLE_POWER, uint8_t RELATIONSHIP>
|
||||
bool operator==(const typename OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>::Element &first,
|
||||
const typename OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>::Element &second) {
|
||||
return (first.list_element == second.list_element);
|
||||
}
|
||||
|
||||
template <class K, class V, class Hasher, class Comparator, uint8_t MIN_HASH_TABLE_POWER, uint8_t RELATIONSHIP>
|
||||
bool operator!=(const typename OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>::Element &first,
|
||||
const typename OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>::Element &second) {
|
||||
return (first.list_element != second.list_element);
|
||||
}
|
||||
|
||||
template <class K, class V, class Hasher, class Comparator, uint8_t MIN_HASH_TABLE_POWER, uint8_t RELATIONSHIP>
|
||||
bool operator==(const typename OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>::ConstElement &first,
|
||||
const typename OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>::ConstElement &second) {
|
||||
return (first.list_element == second.list_element);
|
||||
}
|
||||
|
||||
template <class K, class V, class Hasher, class Comparator, uint8_t MIN_HASH_TABLE_POWER, uint8_t RELATIONSHIP>
|
||||
bool operator!=(const typename OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>::ConstElement &first,
|
||||
const typename OrderedHashMap<K, V, Hasher, Comparator, MIN_HASH_TABLE_POWER, RELATIONSHIP>::ConstElement &second) {
|
||||
return (first.list_element != second.list_element);
|
||||
}
|
||||
|
||||
#endif // ORDERED_HASH_MAP_H
|
||||
|
|
Loading…
Reference in a new issue