[ox/std] Make HashMap::at return type consistent between const/non-const
This commit is contained in:
parent
291027e41e
commit
7bbd7bfdb5
2
deps/ox/src/ox/mc/read.hpp
vendored
2
deps/ox/src/ox/mc/read.hpp
vendored
@ -215,7 +215,7 @@ Error MetalClawReader::field(const char*, HashMap<String, T> *val) {
|
||||
auto keyLen = reader.stringLength(nullptr);
|
||||
auto wkey = ox_malloca(keyLen + 1, char, 0);
|
||||
oxReturnError(reader.field("", SerStr(wkey.get(), keyLen)));
|
||||
oxReturnError(reader.field("", &val->at(wkey.get())));
|
||||
oxReturnError(reader.field("", &val->operator[](wkey.get())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
4
deps/ox/src/ox/model/descwrite.cpp
vendored
4
deps/ox/src/ox/model/descwrite.cpp
vendored
@ -144,12 +144,12 @@ DescriptorType *TypeDescWriter::type(bool*, bool *alreadyExisted) {
|
||||
DescriptorType *TypeDescWriter::getType(TypeName tn, PrimitiveType pt, int b, bool *alreadyExisted) {
|
||||
if (m_typeStore->contains(tn)) {
|
||||
*alreadyExisted = true;
|
||||
auto type = m_typeStore->at(tn);
|
||||
auto type = m_typeStore->operator[](tn);
|
||||
oxAssert(type != nullptr, "TypeDescWriter::getType returning null DescriptorType");
|
||||
return type;
|
||||
} else {
|
||||
*alreadyExisted = false;
|
||||
auto &t = m_typeStore->at(tn);
|
||||
auto &t = m_typeStore->operator[](tn);
|
||||
if (!t) {
|
||||
t = new DescriptorType;
|
||||
}
|
||||
|
4
deps/ox/src/ox/model/descwrite.hpp
vendored
4
deps/ox/src/ox/model/descwrite.hpp
vendored
@ -193,7 +193,7 @@ DescriptorType *TypeDescWriter::type(T *val, bool *alreadyExisted) {
|
||||
oxLogError(model(&nc, val));
|
||||
if (m_typeStore->contains(nc.name)) {
|
||||
*alreadyExisted = true;
|
||||
return m_typeStore->at(nc.name);
|
||||
return m_typeStore->operator[](nc.name);
|
||||
} else {
|
||||
TypeDescWriter dw(m_typeStore);
|
||||
oxLogError(model(&dw, val));
|
||||
@ -219,7 +219,7 @@ DescriptorType *TypeDescWriter::type(UnionView<U> val, bool *alreadyExisted) {
|
||||
|
||||
template<typename T>
|
||||
void TypeDescWriter::setTypeInfo(const char *name, int) {
|
||||
auto &t = m_typeStore->at(name);
|
||||
auto &t = m_typeStore->operator[](name);
|
||||
if (!t) {
|
||||
t = new DescriptorType;
|
||||
}
|
||||
|
2
deps/ox/src/ox/oc/read.hpp
vendored
2
deps/ox/src/ox/oc/read.hpp
vendored
@ -171,7 +171,7 @@ Error OrganicClawReader::field(const char *key, HashMap<String, T> *val) {
|
||||
OrganicClawReader r(srcVal);
|
||||
for (decltype(srcSize) i = 0; i < srcSize; ++i) {
|
||||
auto k = keys[i].c_str();
|
||||
oxReturnError(r.field(k, &val->at(k)));
|
||||
oxReturnError(r.field(k, &val->operator[](k)));
|
||||
}
|
||||
return OxError(0);
|
||||
}
|
||||
|
2
deps/ox/src/ox/oc/write.hpp
vendored
2
deps/ox/src/ox/oc/write.hpp
vendored
@ -140,7 +140,7 @@ Error OrganicClawWriter::field(const char *key, ox::HashMap<String, T> *val) {
|
||||
OrganicClawWriter w;
|
||||
for (std::size_t i = 0; i < keys.size(); ++i) {
|
||||
auto k = keys[i].c_str();
|
||||
oxReturnError(w.field(k, &val->at(k)));
|
||||
oxReturnError(w.field(k, &val->operator[](k)));
|
||||
}
|
||||
value(key) = w.m_json;
|
||||
}
|
||||
|
6
deps/ox/src/ox/std/hashmap.hpp
vendored
6
deps/ox/src/ox/std/hashmap.hpp
vendored
@ -46,7 +46,7 @@ class HashMap {
|
||||
/**
|
||||
* K is assumed to be a null terminated string.
|
||||
*/
|
||||
T &at(K key);
|
||||
Result<T*> at(K key);
|
||||
|
||||
/**
|
||||
* K is assumed to be a null terminated string.
|
||||
@ -132,8 +132,8 @@ T &HashMap<K, T>::operator[](K k) {
|
||||
}
|
||||
|
||||
template<typename K, typename T>
|
||||
T &HashMap<K, T>::at(K k) {
|
||||
return operator[](k);
|
||||
Result<T*> HashMap<K, T>::at(K k) {
|
||||
return &operator[](k);
|
||||
}
|
||||
|
||||
template<typename K, typename T>
|
||||
|
Loading…
Reference in New Issue
Block a user