[ox] Add const char *const* fieldString handlers to OC and MC writers

This commit is contained in:
Gary Talent 2022-07-21 02:18:56 -05:00
parent 6b9d9c50c7
commit 1302d5bf85
4 changed files with 16 additions and 6 deletions

View File

@ -76,10 +76,12 @@ class MetalClawWriter {
template<std::size_t L> template<std::size_t L>
constexpr Error field(const char*, BString<L> *val) noexcept; constexpr Error field(const char*, BString<L> *val) noexcept;
constexpr Error fieldCString(const char *name, const char **val, std::size_t buffLen) noexcept; constexpr Error fieldCString(const char *name, const char *const*val, std::size_t buffLen) noexcept;
constexpr Error fieldCString(const char *name, const char **val) noexcept; constexpr Error fieldCString(const char *name, const char **val) noexcept;
constexpr Error fieldCString(const char *name, const char *const*val) noexcept;
constexpr Error fieldCString(const char *name, const char *val, std::size_t len) noexcept; constexpr Error fieldCString(const char *name, const char *val, std::size_t len) noexcept;
constexpr Error fieldCString(const char *name, char **val, std::size_t buffLen) noexcept { constexpr Error fieldCString(const char *name, char **val, std::size_t buffLen) noexcept {
@ -223,7 +225,7 @@ constexpr Error MetalClawWriter::field(const char *name, BString<L> *val) noexce
return fieldCString(name, val->data(), val->cap()); return fieldCString(name, val->data(), val->cap());
} }
constexpr Error MetalClawWriter::fieldCString(const char*, const char **val, std::size_t) noexcept { constexpr Error MetalClawWriter::fieldCString(const char*, const char *const*val, std::size_t) noexcept {
bool fieldSet = false; bool fieldSet = false;
if (m_unionIdx == -1 || m_unionIdx == m_field) { if (m_unionIdx == -1 || m_unionIdx == m_field) {
const auto strLen = *val ? ox_strlen(*val) : 0; const auto strLen = *val ? ox_strlen(*val) : 0;
@ -249,6 +251,10 @@ constexpr Error MetalClawWriter::fieldCString(const char *name, const char **val
return fieldCString(name, val, {}); return fieldCString(name, val, {});
} }
constexpr Error MetalClawWriter::fieldCString(const char *name, const char *const*val) noexcept {
return fieldCString(name, val, {});
}
constexpr Error MetalClawWriter::fieldCString(const char*, const char *val, std::size_t strLen) noexcept { constexpr Error MetalClawWriter::fieldCString(const char*, const char *val, std::size_t strLen) noexcept {
bool fieldSet = false; bool fieldSet = false;
if (strLen && (m_unionIdx == -1 || m_unionIdx == m_field)) { if (strLen && (m_unionIdx == -1 || m_unionIdx == m_field)) {

View File

@ -43,6 +43,10 @@ class ModelHandlerInterface {
return m_handler->fieldCString(name, val); return m_handler->fieldCString(name, val);
} }
constexpr Error fieldCString(const char *name, const char *const*val) noexcept {
return m_handler->fieldCString(name, val);
}
constexpr Error fieldCString(const char *name, const char **val) noexcept { constexpr Error fieldCString(const char *name, const char **val) noexcept {
return m_handler->fieldCString(name, val); return m_handler->fieldCString(name, val);
} }

View File

@ -26,7 +26,7 @@ Error OrganicClawWriter::field(const char *key, SerStr val) noexcept {
return OxError(0); return OxError(0);
} }
Error OrganicClawWriter::fieldCString(const char *key, const char **val, int len) noexcept { Error OrganicClawWriter::fieldCString(const char *key, const char *const*val, int len) noexcept {
if (targetValid() && len) { if (targetValid() && len) {
value(key) = *val; value(key) = *val;
} }
@ -38,7 +38,7 @@ Error OrganicClawWriter::fieldCString(const char *key, char **val, int len) noex
return fieldCString(key, const_cast<const char**>(val), len); return fieldCString(key, const_cast<const char**>(val), len);
} }
Error OrganicClawWriter::fieldCString(const char *key, const char **val) noexcept { Error OrganicClawWriter::fieldCString(const char *key, const char *const*val) noexcept {
return fieldCString(key, const_cast<const char**>(val), {}); return fieldCString(key, const_cast<const char**>(val), {});
} }

View File

@ -164,11 +164,11 @@ class OrganicClawWriter {
Error field(const char*, SerStr val) noexcept; Error field(const char*, SerStr val) noexcept;
Error fieldCString(const char*, const char **val, int len) noexcept; Error fieldCString(const char*, const char *const*val, int len) noexcept;
Error fieldCString(const char *name, char **val, int len) noexcept; Error fieldCString(const char *name, char **val, int len) noexcept;
Error fieldCString(const char *name, const char **val) noexcept; Error fieldCString(const char *name, const char *const*val) noexcept;
Error fieldCString(const char *name, char **val) noexcept; Error fieldCString(const char *name, char **val) noexcept;