[ox/std] Make HashMap::at return type consistent between const/non-const

This commit is contained in:
Gary Talent 2021-04-01 02:41:12 -05:00
parent 291027e41e
commit 7bbd7bfdb5
6 changed files with 10 additions and 10 deletions

View File

@ -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())));
}
}
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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>