[ox/oc] Move vector handling over to isVector_v
This commit is contained in:
parent
3a335084c9
commit
18491dafd9
12
deps/ox/src/ox/oc/read.hpp
vendored
12
deps/ox/src/ox/oc/read.hpp
vendored
@ -53,9 +53,6 @@ class OrganicClawReader {
|
||||
template<typename T>
|
||||
Error field(const char *key, T *val, std::size_t len);
|
||||
|
||||
template<typename T>
|
||||
Error field(const char *key, Vector<T> *val);
|
||||
|
||||
template<typename T>
|
||||
Error field(const char*, HashMap<String, T> *val);
|
||||
|
||||
@ -112,7 +109,9 @@ class OrganicClawReader {
|
||||
template<typename T>
|
||||
Error OrganicClawReader::field(const char *key, T *val) {
|
||||
auto err = OxError(0);
|
||||
if (targetValid()) {
|
||||
if constexpr(isVector_v<T>) {
|
||||
return field(key, val->data(), val->size());
|
||||
} else if (targetValid()) {
|
||||
const auto &jv = value(key);
|
||||
if (jv.empty() || jv.isObject()) {
|
||||
auto reader = child(key);
|
||||
@ -161,11 +160,6 @@ Error OrganicClawReader::field(const char *key, T *val, std::size_t valLen) {
|
||||
return OxError(0);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
Error OrganicClawReader::field(const char *key, ox::Vector<T> *val) {
|
||||
return field(key, val->data(), val->size());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
Error OrganicClawReader::field(const char *key, HashMap<String, T> *val) {
|
||||
const auto &srcVal = value(key);
|
||||
|
13
deps/ox/src/ox/oc/test/tests.cpp
vendored
13
deps/ox/src/ox/oc/test/tests.cpp
vendored
@ -53,16 +53,12 @@ struct TestStruct {
|
||||
|
||||
TestStruct() noexcept = default;
|
||||
|
||||
TestStruct(const TestStruct&) noexcept;
|
||||
|
||||
TestStruct(TestStruct &&other) noexcept;
|
||||
|
||||
~TestStruct() noexcept {
|
||||
delete[] CString;
|
||||
}
|
||||
|
||||
constexpr TestStruct &operator=(const TestStruct&) noexcept;
|
||||
|
||||
constexpr TestStruct &operator=(TestStruct&&) noexcept;
|
||||
|
||||
};
|
||||
@ -108,19 +104,10 @@ constexpr ox::Error model(T *io, TestStruct *obj) noexcept {
|
||||
return OxError(0);
|
||||
}
|
||||
|
||||
TestStruct::TestStruct(const TestStruct &other) noexcept {
|
||||
ox::copyModel(this, &other);
|
||||
}
|
||||
|
||||
TestStruct::TestStruct(TestStruct &&other) noexcept {
|
||||
ox::moveModel(this, &other);
|
||||
}
|
||||
|
||||
constexpr TestStruct &TestStruct::operator=(const TestStruct &other) noexcept {
|
||||
ox::copyModel(this, &other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr TestStruct &TestStruct::operator=(TestStruct &&other) noexcept {
|
||||
ox::moveModel(this, &other);
|
||||
return *this;
|
||||
|
12
deps/ox/src/ox/oc/write.hpp
vendored
12
deps/ox/src/ox/oc/write.hpp
vendored
@ -51,9 +51,6 @@ class OrganicClawWriter {
|
||||
template<typename U>
|
||||
Error field(const char*, UnionView<U> val);
|
||||
|
||||
template<typename T>
|
||||
Error field(const char*, ox::Vector<T> *val);
|
||||
|
||||
template<typename T>
|
||||
Error field(const char*, HashMap<String, T> *val);
|
||||
|
||||
@ -106,7 +103,9 @@ Error OrganicClawWriter::field(const char *key, ox::BString<L> *val) {
|
||||
|
||||
template<typename T>
|
||||
Error OrganicClawWriter::field(const char *key, T *val) {
|
||||
if (val && targetValid()) {
|
||||
if constexpr(isVector_v<T>) {
|
||||
return field(key, val->data(), val->size());
|
||||
} else if (val && targetValid()) {
|
||||
OrganicClawWriter w;
|
||||
oxReturnError(model(&w, val));
|
||||
if (!w.m_json.isNull()) {
|
||||
@ -130,11 +129,6 @@ Error OrganicClawWriter::field(const char *key, UnionView<U> val) {
|
||||
return OxError(0);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
Error OrganicClawWriter::field(const char *key, ox::Vector<T> *val) {
|
||||
return field(key, val->data(), val->size());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
Error OrganicClawWriter::field(const char *key, ox::HashMap<String, T> *val) {
|
||||
if (targetValid()) {
|
||||
|
Loading…
Reference in New Issue
Block a user