[ox] Make String::String(String const&) explicit
This commit is contained in:
parent
742427584a
commit
3de03bf1fd
2
deps/ox/src/ox/clargs/clargs.cpp
vendored
2
deps/ox/src/ox/clargs/clargs.cpp
vendored
@ -44,7 +44,7 @@ bool ClArgs::getBool(ox::CRStringView arg, bool defaultValue) const noexcept {
|
||||
|
||||
String ClArgs::getString(ox::CRStringView arg, const char *defaultValue) const noexcept {
|
||||
auto [value, err] = m_strings.at(arg);
|
||||
return !err ? *value : ox::String(defaultValue);
|
||||
return !err ? ox::String(std::move(*value)) : ox::String(defaultValue);
|
||||
}
|
||||
|
||||
int ClArgs::getInt(ox::CRStringView arg, int defaultValue) const noexcept {
|
||||
|
2
deps/ox/src/ox/mc/write.hpp
vendored
2
deps/ox/src/ox/mc/write.hpp
vendored
@ -361,7 +361,7 @@ constexpr Error MetalClawWriter<Writer>::field(const char*, const HashMap<String
|
||||
oxReturnError(handler.setTypeInfo("Map", 0, {}, len * 2));
|
||||
// this loop body needs to be in a lambda because of the potential alloca call
|
||||
constexpr auto loopBody = [](auto &handler, auto const&key, auto const&val) -> ox::Error {
|
||||
const auto keyLen = ox_strlen(key);
|
||||
const auto keyLen = key.len();
|
||||
auto wkey = ox_malloca(keyLen + 1, char, 0);
|
||||
memcpy(wkey.get(), key.c_str(), keyLen + 1);
|
||||
oxReturnError(handler.fieldCString("", wkey.get(), keyLen));
|
||||
|
4
deps/ox/src/ox/model/descwrite.hpp
vendored
4
deps/ox/src/ox/model/descwrite.hpp
vendored
@ -209,7 +209,7 @@ constexpr Error TypeDescWriter::field(CRStringView name, UnionView<T, force> val
|
||||
if (m_type) {
|
||||
const auto t = type(val);
|
||||
oxAssert(t != nullptr, "field(const char *name, T val): Type not found or generated");
|
||||
m_type->fieldList.emplace_back(t, String(name), 0, SubscriptStack{}, t->typeName);
|
||||
m_type->fieldList.emplace_back(t, String(name), 0, SubscriptStack{}, ox::String(t->typeName));
|
||||
return OxError(0);
|
||||
}
|
||||
return OxError(1);
|
||||
@ -238,7 +238,7 @@ template<typename ...Args>
|
||||
constexpr Error TypeDescWriter::fieldCString(CRStringView name, Args&&...) noexcept {
|
||||
constexpr auto s = "";
|
||||
const auto t = type(s);
|
||||
m_type->fieldList.emplace_back(t, String(name), 0, SubscriptStack{}, t->typeName);
|
||||
m_type->fieldList.emplace_back(t, String(name), 0, SubscriptStack{}, ox::String(t->typeName));
|
||||
return {};
|
||||
}
|
||||
|
||||
|
6
deps/ox/src/ox/model/modelvalue.hpp
vendored
6
deps/ox/src/ox/model/modelvalue.hpp
vendored
@ -350,7 +350,7 @@ class ModelObject {
|
||||
|
||||
constexpr ModelObject(const ModelObject &other) noexcept {
|
||||
for (const auto &f : other.m_fieldsOrder) {
|
||||
auto &field = m_fieldsOrder.emplace_back(new Field{f->name, f->value});
|
||||
auto &field = m_fieldsOrder.emplace_back(new Field{ox::String(f->name), f->value});
|
||||
m_fields[field->name] = &field->value;
|
||||
}
|
||||
m_type = other.m_type;
|
||||
@ -427,7 +427,7 @@ class ModelObject {
|
||||
return *this;
|
||||
}
|
||||
for (const auto &f : other.m_fieldsOrder) {
|
||||
auto &field = m_fieldsOrder.emplace_back(new Field{f->name, f->value});
|
||||
auto &field = m_fieldsOrder.emplace_back(new Field{ox::String(f->name), f->value});
|
||||
m_fields[field->name] = &field->value;
|
||||
}
|
||||
m_type = other.m_type;
|
||||
@ -528,7 +528,7 @@ class ModelUnion {
|
||||
public:
|
||||
constexpr ModelUnion(const ModelUnion &other) noexcept {
|
||||
for (auto i = 0; const auto &f : other.m_fieldsOrder) {
|
||||
auto &field = m_fieldsOrder.emplace_back(new Field{i, f->name, f->value});
|
||||
auto &field = m_fieldsOrder.emplace_back(new Field{i, ox::String(f->name), f->value});
|
||||
m_fields[field->name] = field.get();
|
||||
++i;
|
||||
}
|
||||
|
2
deps/ox/src/ox/std/cstrops.hpp
vendored
2
deps/ox/src/ox/std/cstrops.hpp
vendored
@ -46,7 +46,7 @@ constexpr auto ox_strnlen(const char *str1, std::size_t maxLen) noexcept {
|
||||
|
||||
template<typename T>
|
||||
[[nodiscard]]
|
||||
constexpr auto ox_strlen(T str1) noexcept {
|
||||
constexpr auto ox_strlen(T const&str1) noexcept {
|
||||
std::size_t len = 0;
|
||||
for (; str1[len]; len++);
|
||||
return len;
|
||||
|
2
deps/ox/src/ox/std/fmt.hpp
vendored
2
deps/ox/src/ox/std/fmt.hpp
vendored
@ -186,7 +186,7 @@ constexpr Fmt<segementCnt> fmtSegments(StringView fmt) noexcept {
|
||||
|
||||
template<typename StringType = String, typename ...Args>
|
||||
[[nodiscard]]
|
||||
constexpr StringType sfmt(StringView fmt, Args... args) noexcept {
|
||||
constexpr StringType sfmt(StringView fmt, Args&&... args) noexcept {
|
||||
assert(ox::detail::argCount(fmt) == sizeof...(args));
|
||||
StringType out;
|
||||
const auto fmtSegments = ox::detail::fmtSegments<sizeof...(args)+1>(fmt);
|
||||
|
2
deps/ox/src/ox/std/hashmap.hpp
vendored
2
deps/ox/src/ox/std/hashmap.hpp
vendored
@ -212,7 +212,7 @@ template<typename K, typename T>
|
||||
constexpr void HashMap<K, T>::expand() {
|
||||
Vector<Pair*> r;
|
||||
for (std::size_t i = 0; i < m_keys.size(); ++i) {
|
||||
auto k = m_keys[i];
|
||||
K k{m_keys[i]};
|
||||
access(r, k) = std::move(access(m_pairs, k));
|
||||
}
|
||||
m_pairs = std::move(r);
|
||||
|
2
deps/ox/src/ox/std/string.hpp
vendored
2
deps/ox/src/ox/std/string.hpp
vendored
@ -40,7 +40,7 @@ class BasicString {
|
||||
|
||||
constexpr explicit BasicString(CRStringView str) noexcept;
|
||||
|
||||
constexpr BasicString(BasicString const&) noexcept;
|
||||
constexpr explicit BasicString(BasicString const&) noexcept;
|
||||
|
||||
constexpr BasicString(BasicString&&) noexcept;
|
||||
|
||||
|
2
deps/ox/src/ox/std/trace.hpp
vendored
2
deps/ox/src/ox/std/trace.hpp
vendored
@ -159,7 +159,7 @@ class OutStream {
|
||||
}
|
||||
#else
|
||||
template<std::size_t fmtSegmentCnt, typename ...Args>
|
||||
constexpr OutStream(const char *file, int line, const char *ch, detail::Fmt<fmtSegmentCnt> fmtSegments, Args... args) noexcept {
|
||||
constexpr OutStream(const char *file, int line, const char *ch, detail::Fmt<fmtSegmentCnt> fmtSegments, Args const&...args) noexcept {
|
||||
//static_assert(sizeof...(args) == fmtSegmentCnt - 1, "Wrong number of trace arguments for format.");
|
||||
m_msg.file = file;
|
||||
m_msg.line = line;
|
||||
|
Loading…
Reference in New Issue
Block a user