Squashed 'deps/nostalgia/' changes from 84205879..0c0ccd1a
0c0ccd1a [nostalgia/core/studio] Cleanup scratchpad code 1b629da8 [ox/std] Make Vector::contains always noexcept 32e4702d [ox] Improve hasing and MaybeView 6b47133c [nostalgia] Cleanup StudioModules 0764720f [nostalgia,olympic] Update for Ox changes 78955376 [glutils] Update for Ox changes a00a0bd2 [ox] Rename BString to IString ed4f0e1f [nostalgia,olympic] Replace oxIgnoreError with std::ignore ea1feb72 [ox] Remove oxIgnoreError e9a6a096 [ox] Run liccor d7f30975 Merge commit 'c0baf7efca0e4c3a86a018ad2564d9df7b07c133' eeb2a5a1 [olympic/studio] Add new ImGui util functions 453f2750 [nostalgia/core/studio] Cleanup context types 189ba4c5 [olympic/studio] Make studio::run static 05773808 [olympic] Change TypeId building to use constexpr globals 272eabc7 [nostalgia/core/opengl] Unbind vertex arrays when done with them a0256669 [glutils] Remove trailing whitespace 6808adc8 [ox/std] Replace ox::ignore with std::ignore abc076d6 [ox/std] Cleanup 1b790a34 [ox/std] Fix Signed_c and Unsigned_c 92202716 [nostalgia/core] Update pack transforms to use ModelTypeId_v 7941a514 [ox/model] Add constexpr ModelTypeId_v 0c09c530 [ox/std] Fix sfmt constexpr problems 3ff91af8 [ox/std] Sort of fix custom assert 79b42e1d [ox/std] Fix some Vector constexpr problems 5eec9085 [ox/std] Add nodiscard to some string functions af7c8956 [ox/std] Add ox::ignore git-subtree-dir: deps/nostalgia git-subtree-split: 0c0ccd1a692169d99beb8c238b8b2c466e81a13d
This commit is contained in:
4
deps/ox/src/ox/std/CMakeLists.txt
vendored
4
deps/ox/src/ox/std/CMakeLists.txt
vendored
@@ -81,6 +81,7 @@ target_link_libraries(
|
||||
OxStd PUBLIC
|
||||
$<$<CXX_COMPILER_ID:GNU>:gcc>
|
||||
OxTraceHook
|
||||
CityHash
|
||||
)
|
||||
|
||||
install(
|
||||
@@ -90,7 +91,7 @@ install(
|
||||
assert.hpp
|
||||
bit.hpp
|
||||
bounds.hpp
|
||||
bstring.hpp
|
||||
istring.hpp
|
||||
buffer.hpp
|
||||
buildinfo.hpp
|
||||
byteswap.hpp
|
||||
@@ -103,6 +104,7 @@ install(
|
||||
hardware.hpp
|
||||
hashmap.hpp
|
||||
heapmgr.hpp
|
||||
ignore.hpp
|
||||
iterator.hpp
|
||||
math.hpp
|
||||
maybeview.hpp
|
||||
|
2
deps/ox/src/ox/std/algorithm.hpp
vendored
2
deps/ox/src/ox/std/algorithm.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
7
deps/ox/src/ox/std/anyptr.hpp
vendored
7
deps/ox/src/ox/std/anyptr.hpp
vendored
@@ -1,3 +1,10 @@
|
||||
/*
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
2
deps/ox/src/ox/std/array.hpp
vendored
2
deps/ox/src/ox/std/array.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/assert.cpp
vendored
2
deps/ox/src/ox/std/assert.cpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/assert.hpp
vendored
2
deps/ox/src/ox/std/assert.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/basestringview.hpp
vendored
2
deps/ox/src/ox/std/basestringview.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/bit.cpp
vendored
2
deps/ox/src/ox/std/bit.cpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/bit.hpp
vendored
2
deps/ox/src/ox/std/bit.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/bounds.hpp
vendored
2
deps/ox/src/ox/std/bounds.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/buffer.cpp
vendored
2
deps/ox/src/ox/std/buffer.cpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/buffer.hpp
vendored
2
deps/ox/src/ox/std/buffer.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/buildinfo.cpp
vendored
2
deps/ox/src/ox/std/buildinfo.cpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/buildinfo.hpp
vendored
2
deps/ox/src/ox/std/buildinfo.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/byteswap.cpp
vendored
2
deps/ox/src/ox/std/byteswap.cpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/byteswap.hpp
vendored
2
deps/ox/src/ox/std/byteswap.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/concepts.cpp
vendored
2
deps/ox/src/ox/std/concepts.cpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/concepts.hpp
vendored
2
deps/ox/src/ox/std/concepts.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
6
deps/ox/src/ox/std/cstringview.hpp
vendored
6
deps/ox/src/ox/std/cstringview.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@@ -9,7 +9,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "basestringview.hpp"
|
||||
#include "bstring.hpp"
|
||||
#include "istring.hpp"
|
||||
#include "string.hpp"
|
||||
#include "stringliteral.hpp"
|
||||
|
||||
@@ -27,7 +27,7 @@ class CStringView: public detail::BaseStringView {
|
||||
constexpr CStringView(BasicString<SmallStrSz> const&str) noexcept: BaseStringView(str.data(), str.len()) {}
|
||||
|
||||
template<std::size_t SmallStrSz>
|
||||
constexpr CStringView(BString<SmallStrSz> const&str) noexcept: BaseStringView(str.data(), str.len()) {}
|
||||
constexpr CStringView(IString<SmallStrSz> const&str) noexcept: BaseStringView(str.data(), str.len()) {}
|
||||
|
||||
constexpr CStringView(std::nullptr_t) noexcept {}
|
||||
|
||||
|
2
deps/ox/src/ox/std/cstrops.hpp
vendored
2
deps/ox/src/ox/std/cstrops.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/def.hpp
vendored
2
deps/ox/src/ox/std/def.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/defer.hpp
vendored
2
deps/ox/src/ox/std/defer.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/defines.hpp
vendored
2
deps/ox/src/ox/std/defines.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
6
deps/ox/src/ox/std/error.hpp
vendored
6
deps/ox/src/ox/std/error.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@@ -314,7 +314,3 @@ constexpr Error toError(const Result<T> &r) noexcept {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
constexpr void oxIgnoreError(const ox::Error&) noexcept {}
|
||||
template<typename T>
|
||||
constexpr void oxIgnoreError(const ox::Result<T>&) noexcept {}
|
||||
|
2
deps/ox/src/ox/std/fmt.cpp
vendored
2
deps/ox/src/ox/std/fmt.cpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
13
deps/ox/src/ox/std/fmt.hpp
vendored
13
deps/ox/src/ox/std/fmt.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@@ -18,7 +18,8 @@
|
||||
|
||||
#include "realstd.hpp"
|
||||
#include "error.hpp"
|
||||
#include "bstring.hpp"
|
||||
#include "ignore.hpp"
|
||||
#include "istring.hpp"
|
||||
#include "string.hpp"
|
||||
#include "strops.hpp"
|
||||
#include "types.hpp"
|
||||
@@ -38,7 +39,7 @@ constexpr StringView toStringView(const char *s) noexcept {
|
||||
}
|
||||
|
||||
template<bool force = false, std::size_t size>
|
||||
constexpr StringView toStringView(const BString<size> &s) noexcept {
|
||||
constexpr StringView toStringView(const IString<size> &s) noexcept {
|
||||
return s.c_str();
|
||||
}
|
||||
|
||||
@@ -77,7 +78,7 @@ class FmtArg {
|
||||
char dataStr[10] = {};
|
||||
|
||||
template<typename T>
|
||||
static StringView sv(const T &v, char *dataStr) noexcept {
|
||||
constexpr StringView sv(const T &v, char *dataStr) noexcept {
|
||||
if constexpr(is_bool_v<T>) {
|
||||
return v ? "true" : "false";
|
||||
} else if constexpr(is_integer_v<T>) {
|
||||
@@ -191,12 +192,12 @@ constexpr StringType sfmt(StringView fmt, Args&&... args) noexcept {
|
||||
StringType out;
|
||||
const auto fmtSegments = ox::detail::fmtSegments<sizeof...(args)+1>(fmt);
|
||||
const auto &firstSegment = fmtSegments.segments[0];
|
||||
oxIgnoreError(out.append(firstSegment.str, firstSegment.length));
|
||||
std::ignore = out.append(firstSegment.str, firstSegment.length);
|
||||
const detail::FmtArg elements[sizeof...(args)] = {args...};
|
||||
for (size_t i = 0; i < fmtSegments.size - 1; ++i) {
|
||||
out += elements[i].out;
|
||||
const auto &s = fmtSegments.segments[i + 1];
|
||||
oxIgnoreError(out.append(s.str, s.length));
|
||||
std::ignore = out.append(s.str, s.length);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
2
deps/ox/src/ox/std/hardware.hpp
vendored
2
deps/ox/src/ox/std/hardware.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
170
deps/ox/src/ox/std/hash.hpp
vendored
Normal file
170
deps/ox/src/ox/std/hash.hpp
vendored
Normal file
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if __has_include(<functional>)
|
||||
#include <functional>
|
||||
#else
|
||||
namespace std {
|
||||
template<typename T>
|
||||
struct hash;
|
||||
}
|
||||
#endif
|
||||
|
||||
#include <cityhash/city.h>
|
||||
|
||||
#include "istring.hpp"
|
||||
#include "string.hpp"
|
||||
#include "stringview.hpp"
|
||||
#include "types.hpp"
|
||||
|
||||
namespace ox {
|
||||
|
||||
template<typename T>
|
||||
struct hash {
|
||||
[[nodiscard]]
|
||||
constexpr size_t operator()(T const&v) const noexcept {
|
||||
return std::hash<T>{}(v);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct hash<bool> {
|
||||
[[nodiscard]]
|
||||
constexpr size_t operator()(bool v) const noexcept {
|
||||
return static_cast<size_t>(v);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct hash<char> {
|
||||
[[nodiscard]]
|
||||
constexpr size_t operator()(char v) const noexcept {
|
||||
return static_cast<size_t>(v);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct hash<short> {
|
||||
[[nodiscard]]
|
||||
constexpr size_t operator()(short v) const noexcept {
|
||||
return static_cast<size_t>(v);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct hash<int> {
|
||||
[[nodiscard]]
|
||||
constexpr size_t operator()(int v) const noexcept {
|
||||
return static_cast<size_t>(v);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct hash<long> {
|
||||
[[nodiscard]]
|
||||
constexpr size_t operator()(long v) const noexcept {
|
||||
return static_cast<size_t>(v);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct hash<long long> {
|
||||
[[nodiscard]]
|
||||
constexpr size_t operator()(long long v) const noexcept {
|
||||
return static_cast<size_t>(v);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
template<>
|
||||
struct hash<unsigned char> {
|
||||
[[nodiscard]]
|
||||
constexpr size_t operator()(unsigned char v) const noexcept {
|
||||
return static_cast<size_t>(v);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct hash<unsigned short> {
|
||||
[[nodiscard]]
|
||||
constexpr size_t operator()(unsigned short v) const noexcept {
|
||||
return static_cast<size_t>(v);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct hash<unsigned int> {
|
||||
[[nodiscard]]
|
||||
constexpr size_t operator()(unsigned int v) const noexcept {
|
||||
return static_cast<size_t>(v);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct hash<unsigned long> {
|
||||
[[nodiscard]]
|
||||
constexpr size_t operator()(unsigned long v) const noexcept {
|
||||
return static_cast<size_t>(v);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct hash<unsigned long long> {
|
||||
[[nodiscard]]
|
||||
constexpr size_t operator()(unsigned long long v) const noexcept {
|
||||
return static_cast<size_t>(v);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr auto hashString(ox::StringView const&v) noexcept {
|
||||
if constexpr(sizeof(void*) == 8) {
|
||||
return cityhash::CityHash64(v.data(), v.bytes());
|
||||
} else {
|
||||
return cityhash::CityHash32(v.data(), v.bytes());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
struct hash<ox::StringView> {
|
||||
[[nodiscard]]
|
||||
constexpr size_t operator()(ox::StringView v) const noexcept {
|
||||
return hashString(v);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct hash<ox::String> {
|
||||
[[nodiscard]]
|
||||
constexpr size_t operator()(ox::StringView v) const noexcept {
|
||||
return hashString(v);
|
||||
}
|
||||
};
|
||||
|
||||
template<size_t sz>
|
||||
struct hash<ox::IString<sz>> {
|
||||
[[nodiscard]]
|
||||
constexpr size_t operator()(ox::StringView v) const noexcept {
|
||||
return hashString(v);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct hash<const char*> {
|
||||
[[nodiscard]]
|
||||
constexpr size_t operator()(ox::StringView v) const noexcept {
|
||||
return hashString(v);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
44
deps/ox/src/ox/std/hashmap.hpp
vendored
44
deps/ox/src/ox/std/hashmap.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@@ -9,6 +9,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "algorithm.hpp"
|
||||
#include "hash.hpp"
|
||||
#include "ignore.hpp"
|
||||
#include "stringview.hpp"
|
||||
#include "strops.hpp"
|
||||
#include "vector.hpp"
|
||||
@@ -31,7 +33,7 @@ class HashMap {
|
||||
Vector<Pair*> m_pairs;
|
||||
|
||||
public:
|
||||
explicit constexpr HashMap(std::size_t size = 100);
|
||||
explicit constexpr HashMap(std::size_t size = 127);
|
||||
|
||||
constexpr HashMap(HashMap const&other);
|
||||
|
||||
@@ -67,10 +69,6 @@ class HashMap {
|
||||
private:
|
||||
constexpr void expand();
|
||||
|
||||
constexpr static uint64_t hash(Integral_c auto) noexcept;
|
||||
|
||||
constexpr static uint64_t hash(StringView const&) noexcept;
|
||||
|
||||
template<typename KK>
|
||||
constexpr Pair *const&access(Vector<Pair*> const&pairs, KK const&key) const;
|
||||
|
||||
@@ -171,17 +169,17 @@ constexpr void HashMap<K, T>::erase(MaybeView_t<K> const&k) {
|
||||
if (!contains(k)) {
|
||||
return;
|
||||
}
|
||||
auto h = hash(k) % m_pairs.size();
|
||||
auto h = ox::hash<MaybeView_t<K>>{}(k) % m_pairs.size();
|
||||
while (true) {
|
||||
const auto &p = m_pairs[h];
|
||||
if (p == nullptr || p->key == k) {
|
||||
oxIgnoreError(m_pairs.erase(h));
|
||||
std::ignore = m_pairs.erase(h);
|
||||
break;
|
||||
} else {
|
||||
h = hash(h) % m_pairs.size();
|
||||
h = ox::hash<MaybeView_t<K>>{}(k) % m_pairs.size();
|
||||
}
|
||||
}
|
||||
oxIgnoreError(m_keys.erase(ox::find(m_keys.begin(), m_keys.end(), k)));
|
||||
std::ignore = m_keys.erase(ox::find(m_keys.begin(), m_keys.end(), k));
|
||||
}
|
||||
|
||||
template<typename K, typename T>
|
||||
@@ -205,7 +203,7 @@ constexpr void HashMap<K, T>::clear() {
|
||||
delete m_pairs[i];
|
||||
}
|
||||
m_pairs.clear();
|
||||
m_pairs.resize(100);
|
||||
m_pairs.resize(127);
|
||||
}
|
||||
|
||||
template<typename K, typename T>
|
||||
@@ -218,30 +216,10 @@ constexpr void HashMap<K, T>::expand() {
|
||||
m_pairs = std::move(r);
|
||||
}
|
||||
|
||||
template<typename K, typename T>
|
||||
constexpr uint64_t HashMap<K, T>::hash(Integral_c auto k) noexcept {
|
||||
uint64_t sum = 1;
|
||||
for (auto i = 0u; i < sizeof(K); ++i) {
|
||||
const auto shift = i * 8;
|
||||
const auto v = static_cast<uint64_t>(k >> shift & 0xff);
|
||||
sum += (sum + v) * 7 * sum;
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
template<typename K, typename T>
|
||||
constexpr uint64_t HashMap<K, T>::hash(StringView const&k) noexcept {
|
||||
uint64_t sum = 1;
|
||||
for (auto i = 0u; i < k.len(); ++i) {
|
||||
sum += ((sum + static_cast<uint64_t>(k[i])) * 7) * sum;
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
template<typename K, typename T>
|
||||
template<typename KK>
|
||||
constexpr typename HashMap<K, T>::Pair *const&HashMap<K, T>::access(Vector<Pair*> const&pairs, KK const&k) const {
|
||||
auto h = static_cast<std::size_t>(hash(k) % pairs.size());
|
||||
auto h = static_cast<std::size_t>(ox::hash<KK>{}(k) % pairs.size());
|
||||
while (true) {
|
||||
const auto &p = pairs[h];
|
||||
if (p == nullptr || p->key == k) {
|
||||
@@ -255,7 +233,7 @@ constexpr typename HashMap<K, T>::Pair *const&HashMap<K, T>::access(Vector<Pair*
|
||||
template<typename K, typename T>
|
||||
template<typename KK>
|
||||
constexpr typename HashMap<K, T>::Pair *&HashMap<K, T>::access(Vector<Pair*> &pairs, KK const&k) {
|
||||
auto h = static_cast<std::size_t>(hash(k) % pairs.size());
|
||||
auto h = static_cast<std::size_t>(ox::hash<KK>{}(k) % pairs.size());
|
||||
while (true) {
|
||||
auto &p = pairs[h];
|
||||
if (p == nullptr || p->key == k) {
|
||||
|
2
deps/ox/src/ox/std/heapmgr.cpp
vendored
2
deps/ox/src/ox/std/heapmgr.cpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/heapmgr.hpp
vendored
2
deps/ox/src/ox/std/heapmgr.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
24
deps/ox/src/ox/std/ignore.hpp
vendored
Normal file
24
deps/ox/src/ox/std/ignore.hpp
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if __has_include(<tuple>)
|
||||
|
||||
#include <tuple>
|
||||
|
||||
#else
|
||||
|
||||
namespace std {
|
||||
|
||||
inline constexpr struct {
|
||||
constexpr void operator=(auto&&) const noexcept {}
|
||||
} ignore;
|
||||
|
||||
}
|
||||
#endif
|
2
deps/ox/src/ox/std/initializerlist.hpp
vendored
2
deps/ox/src/ox/std/initializerlist.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ignore.hpp"
|
||||
#include "memops.hpp"
|
||||
#include "stringview.hpp"
|
||||
#include "strops.hpp"
|
||||
@@ -15,40 +16,41 @@
|
||||
|
||||
namespace ox {
|
||||
|
||||
// Bounded String
|
||||
// Inline String
|
||||
template<std::size_t buffLen>
|
||||
class BString {
|
||||
class IString {
|
||||
private:
|
||||
char m_buff[buffLen + 1];
|
||||
size_t m_size{};
|
||||
|
||||
public:
|
||||
constexpr BString() noexcept;
|
||||
constexpr IString() noexcept;
|
||||
|
||||
constexpr BString(StringView str) noexcept;
|
||||
constexpr IString(StringView str) noexcept;
|
||||
|
||||
constexpr BString(const char *str) noexcept;
|
||||
constexpr IString(const char *str) noexcept;
|
||||
|
||||
constexpr BString &operator=(CRStringView str) noexcept;
|
||||
constexpr IString &operator=(CRStringView str) noexcept;
|
||||
|
||||
constexpr BString &operator=(const char *str) noexcept;
|
||||
constexpr IString &operator=(const char *str) noexcept;
|
||||
|
||||
constexpr BString &operator=(char *str) noexcept;
|
||||
constexpr IString &operator=(char *str) noexcept;
|
||||
|
||||
constexpr BString &operator=(Integer_c auto i) noexcept;
|
||||
constexpr IString &operator=(Integer_c auto i) noexcept;
|
||||
|
||||
constexpr BString &operator+=(const char *str) noexcept;
|
||||
constexpr IString &operator+=(const char *str) noexcept;
|
||||
|
||||
constexpr BString &operator+=(char *str) noexcept;
|
||||
constexpr IString &operator+=(char *str) noexcept;
|
||||
|
||||
constexpr BString &operator+=(Integer_c auto i) noexcept;
|
||||
constexpr IString &operator+=(Integer_c auto i) noexcept;
|
||||
|
||||
constexpr BString &operator+=(StringView s) noexcept;
|
||||
constexpr IString &operator+=(StringView s) noexcept;
|
||||
|
||||
constexpr BString operator+(const char *str) const noexcept;
|
||||
constexpr IString operator+(const char *str) const noexcept;
|
||||
|
||||
constexpr BString operator+(char *str) const noexcept;
|
||||
constexpr IString operator+(char *str) const noexcept;
|
||||
|
||||
constexpr BString operator+(Integer_c auto i) const noexcept;
|
||||
constexpr IString operator+(Integer_c auto i) const noexcept;
|
||||
|
||||
constexpr bool operator==(const char *other) const noexcept;
|
||||
|
||||
@@ -93,133 +95,135 @@ class BString {
|
||||
};
|
||||
|
||||
template<std::size_t size>
|
||||
constexpr BString<size>::BString() noexcept: m_buff{{0}} {
|
||||
constexpr IString<size>::IString() noexcept: m_buff{{0}} {
|
||||
}
|
||||
|
||||
template<std::size_t size>
|
||||
constexpr BString<size>::BString(StringView str) noexcept: m_buff{{0}} {
|
||||
constexpr IString<size>::IString(StringView str) noexcept: m_buff{{0}} {
|
||||
operator=(str);
|
||||
}
|
||||
|
||||
template<std::size_t size>
|
||||
constexpr BString<size>::BString(const char *str) noexcept: m_buff{{0}} {
|
||||
constexpr IString<size>::IString(const char *str) noexcept: m_buff{{0}} {
|
||||
operator=(str);
|
||||
}
|
||||
|
||||
template<std::size_t size>
|
||||
constexpr BString<size> &BString<size>::operator=(Integer_c auto i) noexcept {
|
||||
constexpr IString<size> &IString<size>::operator=(Integer_c auto i) noexcept {
|
||||
char str[65] = {};
|
||||
ox::itoa(i, str);
|
||||
return this->operator=(str);
|
||||
}
|
||||
|
||||
template<std::size_t size>
|
||||
constexpr BString<size> &BString<size>::operator=(ox::CRStringView str) noexcept {
|
||||
constexpr IString<size> &IString<size>::operator=(ox::CRStringView str) noexcept {
|
||||
std::size_t strLen = str.bytes() + 1;
|
||||
if (cap() < strLen) {
|
||||
strLen = cap();
|
||||
}
|
||||
ox::memcpy(m_buff, str.data(), strLen);
|
||||
m_size = strLen;
|
||||
ox::listcpy(m_buff, str.data(), strLen);
|
||||
// make sure last element is a null terminator
|
||||
m_buff[strLen] = 0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<std::size_t size>
|
||||
constexpr BString<size> &BString<size>::operator=(const char *str) noexcept {
|
||||
constexpr IString<size> &IString<size>::operator=(const char *str) noexcept {
|
||||
std::size_t strLen = ox::strlen(str) + 1;
|
||||
if (cap() < strLen) {
|
||||
strLen = cap();
|
||||
}
|
||||
ox::memcpy(m_buff, str, strLen);
|
||||
m_size = strLen;
|
||||
ox::listcpy(m_buff, str, strLen);
|
||||
// make sure last element is a null terminator
|
||||
m_buff[cap()] = 0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<std::size_t size>
|
||||
constexpr BString<size> &BString<size>::operator=(char *str) noexcept {
|
||||
constexpr IString<size> &IString<size>::operator=(char *str) noexcept {
|
||||
return *this = static_cast<const char*>(str);
|
||||
}
|
||||
|
||||
template<std::size_t size>
|
||||
constexpr BString<size> &BString<size>::operator+=(const char *str) noexcept {
|
||||
constexpr IString<size> &IString<size>::operator+=(const char *str) noexcept {
|
||||
std::size_t strLen = ox::strlen(str) + 1;
|
||||
oxIgnoreError(append(str, strLen));
|
||||
std::ignore = append(str, strLen);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<std::size_t size>
|
||||
constexpr BString<size> &BString<size>::operator+=(char *str) noexcept {
|
||||
constexpr IString<size> &IString<size>::operator+=(char *str) noexcept {
|
||||
return *this += static_cast<const char*>(str);
|
||||
}
|
||||
|
||||
template<std::size_t size>
|
||||
constexpr BString<size> &BString<size>::operator+=(Integer_c auto i) noexcept {
|
||||
constexpr IString<size> &IString<size>::operator+=(Integer_c auto i) noexcept {
|
||||
char str[65] = {};
|
||||
ox::itoa(i, str);
|
||||
return this->operator+=(str);
|
||||
}
|
||||
|
||||
template<std::size_t size>
|
||||
constexpr BString<size> &BString<size>::operator+=(StringView s) noexcept {
|
||||
constexpr IString<size> &IString<size>::operator+=(StringView s) noexcept {
|
||||
std::size_t strLen = s.bytes();
|
||||
oxIgnoreError(append(s.data(), strLen));
|
||||
std::ignore = append(s.data(), strLen);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<std::size_t size>
|
||||
constexpr BString<size> BString<size>::operator+(const char *str) const noexcept {
|
||||
constexpr IString<size> IString<size>::operator+(const char *str) const noexcept {
|
||||
auto out = *this;
|
||||
std::size_t strLen = ox::strlen(str) + 1;
|
||||
oxIgnoreError(out.append(str, strLen));
|
||||
std::ignore = out.append(str, strLen);
|
||||
return out;
|
||||
}
|
||||
|
||||
template<std::size_t size>
|
||||
constexpr BString<size> BString<size>::operator+(char *str) const noexcept {
|
||||
constexpr IString<size> IString<size>::operator+(char *str) const noexcept {
|
||||
return *this + static_cast<const char*>(str);
|
||||
}
|
||||
|
||||
template<std::size_t size>
|
||||
constexpr BString<size> BString<size>::operator+(Integer_c auto i) const noexcept {
|
||||
constexpr IString<size> IString<size>::operator+(Integer_c auto i) const noexcept {
|
||||
char str[65] = {};
|
||||
ox::itoa(i, str);
|
||||
return this->operator+(str);
|
||||
}
|
||||
|
||||
template<std::size_t buffLen>
|
||||
constexpr bool BString<buffLen>::operator==(const char *other) const noexcept {
|
||||
constexpr bool IString<buffLen>::operator==(const char *other) const noexcept {
|
||||
return ox::StringView(*this) == other;
|
||||
}
|
||||
|
||||
template<std::size_t buffLen>
|
||||
constexpr bool BString<buffLen>::operator==(const OxString_c auto &other) const noexcept {
|
||||
constexpr bool IString<buffLen>::operator==(const OxString_c auto &other) const noexcept {
|
||||
return ox::StringView(*this) == ox::StringView(other);
|
||||
}
|
||||
|
||||
template<std::size_t buffLen>
|
||||
constexpr bool BString<buffLen>::operator!=(const char *other) const noexcept {
|
||||
constexpr bool IString<buffLen>::operator!=(const char *other) const noexcept {
|
||||
return !operator==(other);
|
||||
}
|
||||
|
||||
template<std::size_t buffLen>
|
||||
constexpr bool BString<buffLen>::operator!=(const OxString_c auto &other) noexcept {
|
||||
constexpr bool IString<buffLen>::operator!=(const OxString_c auto &other) noexcept {
|
||||
return !operator==(other);
|
||||
}
|
||||
|
||||
template<std::size_t buffLen>
|
||||
constexpr char BString<buffLen>::operator[](std::size_t i) const noexcept {
|
||||
constexpr char IString<buffLen>::operator[](std::size_t i) const noexcept {
|
||||
return m_buff[i];
|
||||
}
|
||||
|
||||
template<std::size_t buffLen>
|
||||
constexpr char &BString<buffLen>::operator[](std::size_t i) noexcept {
|
||||
constexpr char &IString<buffLen>::operator[](std::size_t i) noexcept {
|
||||
return m_buff[i];
|
||||
}
|
||||
|
||||
template<std::size_t buffLen>
|
||||
constexpr Error BString<buffLen>::append(const char *str, std::size_t strLen) noexcept {
|
||||
constexpr Error IString<buffLen>::append(const char *str, std::size_t strLen) noexcept {
|
||||
Error err;
|
||||
auto currentLen = len();
|
||||
if (cap() < currentLen + strLen + 1) {
|
||||
@@ -233,23 +237,23 @@ constexpr Error BString<buffLen>::append(const char *str, std::size_t strLen) no
|
||||
}
|
||||
|
||||
template<std::size_t buffLen>
|
||||
constexpr const char *BString<buffLen>::data() const noexcept {
|
||||
constexpr const char *IString<buffLen>::data() const noexcept {
|
||||
return static_cast<const char*>(m_buff);
|
||||
}
|
||||
|
||||
template<std::size_t buffLen>
|
||||
constexpr char *BString<buffLen>::data() noexcept {
|
||||
constexpr char *IString<buffLen>::data() noexcept {
|
||||
return static_cast<char*>(m_buff);
|
||||
}
|
||||
|
||||
template<std::size_t buffLen>
|
||||
constexpr const char *BString<buffLen>::c_str() const noexcept {
|
||||
constexpr const char *IString<buffLen>::c_str() const noexcept {
|
||||
return static_cast<const char*>(m_buff);
|
||||
}
|
||||
|
||||
|
||||
template<std::size_t buffLen>
|
||||
constexpr std::size_t BString<buffLen>::len() const noexcept {
|
||||
constexpr std::size_t IString<buffLen>::len() const noexcept {
|
||||
std::size_t length = 0;
|
||||
for (std::size_t i = 0; i < buffLen; i++) {
|
||||
uint8_t b = static_cast<uint8_t>(m_buff[i]);
|
||||
@@ -267,15 +271,20 @@ constexpr std::size_t BString<buffLen>::len() const noexcept {
|
||||
}
|
||||
|
||||
template<std::size_t buffLen>
|
||||
constexpr std::size_t BString<buffLen>::bytes() const noexcept {
|
||||
constexpr std::size_t IString<buffLen>::bytes() const noexcept {
|
||||
std::size_t i = 0;
|
||||
for (i = 0; i < buffLen && m_buff[i]; i++);
|
||||
return i + 1; // add one for null terminator
|
||||
}
|
||||
|
||||
template<std::size_t buffLen>
|
||||
constexpr std::size_t BString<buffLen>::cap() const noexcept {
|
||||
constexpr std::size_t IString<buffLen>::cap() const noexcept {
|
||||
return buffLen;
|
||||
}
|
||||
|
||||
template<size_t sz>
|
||||
struct MaybeView<ox::IString<sz>> {
|
||||
using type = ox::StringView;
|
||||
};
|
||||
|
||||
}
|
2
deps/ox/src/ox/std/iterator.hpp
vendored
2
deps/ox/src/ox/std/iterator.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/math.cpp
vendored
2
deps/ox/src/ox/std/math.cpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/math.hpp
vendored
2
deps/ox/src/ox/std/math.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
4
deps/ox/src/ox/std/maybeview.hpp
vendored
4
deps/ox/src/ox/std/maybeview.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@@ -15,7 +15,7 @@ namespace ox {
|
||||
// Maybe StringView. If T is a string type, MaybeType::type/MaybeView_t is a
|
||||
// StringView. This avoids creating unnecessary Strings when taking a
|
||||
// StringView or C string as a function argument.
|
||||
template<typename T, bool isStr = isOxString_v<T>>
|
||||
template<typename T>
|
||||
struct MaybeView {
|
||||
using type = T;
|
||||
};
|
||||
|
2
deps/ox/src/ox/std/memops.cpp
vendored
2
deps/ox/src/ox/std/memops.cpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/memops.hpp
vendored
2
deps/ox/src/ox/std/memops.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/memory.hpp
vendored
2
deps/ox/src/ox/std/memory.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/new.hpp
vendored
2
deps/ox/src/ox/std/new.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/optional.hpp
vendored
2
deps/ox/src/ox/std/optional.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/point.hpp
vendored
2
deps/ox/src/ox/std/point.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/random.cpp
vendored
2
deps/ox/src/ox/std/random.cpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/random.hpp
vendored
2
deps/ox/src/ox/std/random.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/range.hpp
vendored
2
deps/ox/src/ox/std/range.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/ranges.hpp
vendored
2
deps/ox/src/ox/std/ranges.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/reader.cpp
vendored
2
deps/ox/src/ox/std/reader.cpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/reader.hpp
vendored
2
deps/ox/src/ox/std/reader.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
4
deps/ox/src/ox/std/realstd.hpp
vendored
4
deps/ox/src/ox/std/realstd.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@@ -11,5 +11,5 @@
|
||||
#if __has_include(<cassert>)
|
||||
#include <cassert>
|
||||
#else
|
||||
#define assert(e) while (1);
|
||||
#define assert(e) while (!(e));
|
||||
#endif
|
2
deps/ox/src/ox/std/serialize.hpp
vendored
2
deps/ox/src/ox/std/serialize.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/size.hpp
vendored
2
deps/ox/src/ox/std/size.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/span.hpp
vendored
2
deps/ox/src/ox/std/span.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/stacktrace.cpp
vendored
2
deps/ox/src/ox/std/stacktrace.cpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/stacktrace.hpp
vendored
2
deps/ox/src/ox/std/stacktrace.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
5
deps/ox/src/ox/std/std.hpp
vendored
5
deps/ox/src/ox/std/std.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "assert.hpp"
|
||||
#include "bit.hpp"
|
||||
#include "bounds.hpp"
|
||||
#include "bstring.hpp"
|
||||
#include "istring.hpp"
|
||||
#include "byteswap.hpp"
|
||||
#include "concepts.hpp"
|
||||
#include "cstringview.hpp"
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "hardware.hpp"
|
||||
#include "hashmap.hpp"
|
||||
#include "heapmgr.hpp"
|
||||
#include "ignore.hpp"
|
||||
#include "iterator.hpp"
|
||||
#include "math.hpp"
|
||||
#include "maybeview.hpp"
|
||||
|
2
deps/ox/src/ox/std/stddef.hpp
vendored
2
deps/ox/src/ox/std/stddef.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/string.cpp
vendored
2
deps/ox/src/ox/std/string.cpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
17
deps/ox/src/ox/std/string.hpp
vendored
17
deps/ox/src/ox/std/string.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@@ -13,6 +13,7 @@
|
||||
#endif
|
||||
|
||||
#include "algorithm.hpp"
|
||||
#include "ignore.hpp"
|
||||
#include "memops.hpp"
|
||||
#include "serialize.hpp"
|
||||
#include "stringliteral.hpp"
|
||||
@@ -33,9 +34,6 @@ class BasicString {
|
||||
|
||||
constexpr explicit BasicString(std::size_t cap) noexcept;
|
||||
|
||||
template<size_t Sz>
|
||||
constexpr BasicString(char const (&str)[Sz]) noexcept;
|
||||
|
||||
constexpr explicit BasicString(const char *str) noexcept;
|
||||
|
||||
constexpr explicit BasicString(const char8_t *str) noexcept;
|
||||
@@ -364,7 +362,7 @@ constexpr BasicString<SmallStringSize_v> &BasicString<SmallStringSize_v>::operat
|
||||
template<std::size_t SmallStringSize_v>
|
||||
constexpr BasicString<SmallStringSize_v> &BasicString<SmallStringSize_v>::operator+=(const char *str) noexcept {
|
||||
std::size_t strLen = ox::strlen(str);
|
||||
oxIgnoreError(append(str, strLen));
|
||||
std::ignore = append(str, strLen);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -389,13 +387,13 @@ constexpr BasicString<SmallStringSize_v> &BasicString<SmallStringSize_v>::operat
|
||||
template<std::size_t SmallStringSize_v>
|
||||
constexpr BasicString<SmallStringSize_v> &BasicString<SmallStringSize_v>::operator+=(StringView s) noexcept {
|
||||
std::size_t strLen = s.bytes();
|
||||
oxIgnoreError(append(s.data(), strLen));
|
||||
std::ignore = append(s.data(), strLen);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<std::size_t SmallStringSize_v>
|
||||
constexpr BasicString<SmallStringSize_v> &BasicString<SmallStringSize_v>::operator+=(BasicString const&src) noexcept {
|
||||
oxIgnoreError(append(src.c_str(), src.len()));
|
||||
std::ignore = append(src.c_str(), src.len());
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -591,4 +589,9 @@ constexpr auto alignOf(const ox::BasicString<SmallStringSize_v>&) noexcept {
|
||||
return alignOf<PlatSpec>(&v);
|
||||
}
|
||||
|
||||
template<size_t sz>
|
||||
struct MaybeView<ox::BasicString<sz>> {
|
||||
using type = ox::StringView;
|
||||
};
|
||||
|
||||
}
|
||||
|
7
deps/ox/src/ox/std/stringliteral.hpp
vendored
7
deps/ox/src/ox/std/stringliteral.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@@ -30,10 +30,11 @@ class StringLiteral: public detail::BaseStringView {
|
||||
|
||||
constexpr explicit StringLiteral(std::nullptr_t) noexcept {}
|
||||
|
||||
constexpr explicit StringLiteral(const char *str) noexcept: BaseStringView(str) {}
|
||||
|
||||
constexpr explicit StringLiteral(const char *str, std::size_t len) noexcept: BaseStringView(str, len) {}
|
||||
|
||||
constexpr explicit StringLiteral(char const *str) noexcept: StringLiteral(str, ox::strlen(str)) {
|
||||
}
|
||||
|
||||
constexpr auto &operator=(StringLiteral const&other) noexcept {
|
||||
if (&other != this) {
|
||||
set(other.data(), other.len());
|
||||
|
2
deps/ox/src/ox/std/stringview.cpp
vendored
2
deps/ox/src/ox/std/stringview.cpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
11
deps/ox/src/ox/std/stringview.hpp
vendored
11
deps/ox/src/ox/std/stringview.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@@ -20,7 +20,7 @@
|
||||
namespace ox {
|
||||
|
||||
template<std::size_t buffLen>
|
||||
class BString;
|
||||
class IString;
|
||||
|
||||
template<std::size_t buffLen>
|
||||
class BasicString;
|
||||
@@ -41,7 +41,7 @@ class StringView: public detail::BaseStringView {
|
||||
constexpr StringView(const BasicString<SmallStrSz> &str) noexcept: BaseStringView(str.data(), str.len()) {}
|
||||
|
||||
template<std::size_t SmallStrSz>
|
||||
constexpr StringView(const BString<SmallStrSz> &str) noexcept: BaseStringView(str.data(), str.len()) {}
|
||||
constexpr StringView(const IString<SmallStrSz> &str) noexcept: BaseStringView(str.data(), str.len()) {}
|
||||
|
||||
constexpr StringView(std::nullptr_t) noexcept {}
|
||||
|
||||
@@ -98,11 +98,6 @@ constexpr auto toStdStringView(CRStringView sv) noexcept {
|
||||
#endif
|
||||
|
||||
|
||||
template<typename T>
|
||||
struct MaybeView<T, true> {
|
||||
using type = ox::StringView;
|
||||
};
|
||||
|
||||
constexpr ox::Result<int> atoi(ox::CRStringView str) noexcept {
|
||||
int total = 0;
|
||||
int multiplier = 1;
|
||||
|
2
deps/ox/src/ox/std/strongint.hpp
vendored
2
deps/ox/src/ox/std/strongint.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/strops.cpp
vendored
2
deps/ox/src/ox/std/strops.cpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
6
deps/ox/src/ox/std/strops.hpp
vendored
6
deps/ox/src/ox/std/strops.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@@ -80,6 +80,7 @@ constexpr bool endsWith(CRStringView base, CRStringView ending) noexcept {
|
||||
return base.len() >= endingLen && ox::strcmp(base.data() + (base.len() - endingLen), ending) == 0;
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr std::size_t find(CRStringView str, char search) noexcept {
|
||||
std::size_t i = 0;
|
||||
for (; i < str.len(); ++i) {
|
||||
@@ -90,6 +91,7 @@ constexpr std::size_t find(CRStringView str, char search) noexcept {
|
||||
return i;
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr std::size_t find(CRStringView str, CRStringView search) noexcept {
|
||||
std::size_t i = 0;
|
||||
for (; i < str.len(); ++i) {
|
||||
@@ -101,6 +103,7 @@ constexpr std::size_t find(CRStringView str, CRStringView search) noexcept {
|
||||
}
|
||||
|
||||
template<std::size_t smallSz = 0>
|
||||
[[nodiscard]]
|
||||
constexpr ox::Vector<ox::StringView, smallSz> split(CRStringView str, char del) noexcept {
|
||||
ox::Vector<ox::StringView, smallSz> out;
|
||||
constexpr auto nextSeg = [](CRStringView current, char del) {
|
||||
@@ -117,6 +120,7 @@ constexpr ox::Vector<ox::StringView, smallSz> split(CRStringView str, char del)
|
||||
}
|
||||
|
||||
template<std::size_t smallSz = 0>
|
||||
[[nodiscard]]
|
||||
constexpr ox::Vector<ox::StringView, smallSz> split(CRStringView str, CRStringView del) noexcept {
|
||||
ox::Vector<ox::StringView, smallSz> out;
|
||||
constexpr auto nextSeg = [](CRStringView current, CRStringView del) {
|
||||
|
2
deps/ox/src/ox/std/substitutes.cpp
vendored
2
deps/ox/src/ox/std/substitutes.cpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
4
deps/ox/src/ox/std/test/tests.cpp
vendored
4
deps/ox/src/ox/std/test/tests.cpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@@ -68,7 +68,7 @@ static std::map<ox::StringView, ox::Error(*)()> tests = {
|
||||
{
|
||||
"BString",
|
||||
[]() {
|
||||
ox::BString<5> s;
|
||||
ox::IString<5> s;
|
||||
s += "A";
|
||||
s += "B";
|
||||
s += 9;
|
||||
|
4
deps/ox/src/ox/std/trace.cpp
vendored
4
deps/ox/src/ox/std/trace.cpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@@ -37,7 +37,7 @@ void setLogger(Logger *logger) noexcept {
|
||||
}
|
||||
|
||||
void send(const TraceMsg &msg) noexcept {
|
||||
oxIgnoreError(logger->send(msg));
|
||||
std::ignore = logger->send(msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
10
deps/ox/src/ox/std/trace.hpp
vendored
10
deps/ox/src/ox/std/trace.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <array>
|
||||
#endif
|
||||
|
||||
#include "bstring.hpp"
|
||||
#include "istring.hpp"
|
||||
#include "def.hpp"
|
||||
#include "fmt.hpp"
|
||||
#include "hashmap.hpp"
|
||||
@@ -148,12 +148,12 @@ class OutStream {
|
||||
m_msg.line = line;
|
||||
m_msg.ch = ch;
|
||||
const auto &firstSegment = fmtSegments.segments[0];
|
||||
oxIgnoreError(m_msg.msg.append(firstSegment.str, firstSegment.length));
|
||||
std::ignore = m_msg.msg.append(firstSegment.str, firstSegment.length);
|
||||
//const detail::FmtArg elements[sizeof...(args)] = {args...};
|
||||
for (size_t i = 0; auto const&e : std::initializer_list<detail::FmtArg>{elements...}) {
|
||||
m_msg.msg += e.out;
|
||||
const auto &s = fmtSegments.segments[i + 1];
|
||||
oxIgnoreError(m_msg.msg.append(s.str, s.length));
|
||||
std::ignore = m_msg.msg.append(s.str, s.length);
|
||||
++i;
|
||||
}
|
||||
}
|
||||
@@ -182,7 +182,7 @@ class OutStream {
|
||||
}
|
||||
|
||||
template<std::size_t sz>
|
||||
constexpr OutStream &operator<<(const BString<sz> &v) noexcept {
|
||||
constexpr OutStream &operator<<(const IString<sz> &v) noexcept {
|
||||
return operator<<(v.c_str());
|
||||
}
|
||||
|
||||
|
2
deps/ox/src/ox/std/tracehook.cpp
vendored
2
deps/ox/src/ox/std/tracehook.cpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/typeinfo.hpp
vendored
2
deps/ox/src/ox/std/typeinfo.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/types.hpp
vendored
2
deps/ox/src/ox/std/types.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/typetraits.cpp
vendored
2
deps/ox/src/ox/std/typetraits.cpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
16
deps/ox/src/ox/std/typetraits.hpp
vendored
16
deps/ox/src/ox/std/typetraits.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@@ -143,7 +143,7 @@ template<typename T>
|
||||
constexpr bool memberable(...) { return false; }
|
||||
|
||||
template<typename T>
|
||||
struct is_class: integral_constant<bool, !is_union<T>::value && memberable<T>(0)> {};
|
||||
struct is_class: integral_constant<bool, !is_union_v<T> && memberable<T>(nullptr)> {};
|
||||
|
||||
namespace test {
|
||||
struct TestClass {int i;};
|
||||
@@ -159,11 +159,11 @@ constexpr bool is_class_v = is_class<T>();
|
||||
template<typename T>
|
||||
constexpr bool is_signed_v = integral_constant<bool, T(-1) < T(0)>::value;
|
||||
|
||||
template<typename T, std::size_t bits>
|
||||
concept Signed_c = is_signed_v<T> && sizeof(T) == 8 * bits;
|
||||
template<typename T, std::size_t bits = sizeof(T) * 8>
|
||||
concept Signed_c = is_signed_v<T> && sizeof(T) == bits / 8;
|
||||
|
||||
template<typename T, std::size_t bits>
|
||||
concept Unsigned_c = !is_signed_v<T> && sizeof(T) == 8 * bits;
|
||||
template<typename T, std::size_t bits = sizeof(T) * 8>
|
||||
concept Unsigned_c = !is_signed_v<T> && sizeof(T) == bits / 8;
|
||||
|
||||
template<typename T, typename U>
|
||||
struct is_same: false_type {};
|
||||
@@ -272,7 +272,7 @@ constexpr bool is_move_constructible_v = detail::is_move_constructible<T>(0);
|
||||
template<std::size_t SmallStringSize>
|
||||
class BasicString;
|
||||
template<std::size_t sz>
|
||||
class BString;
|
||||
class IString;
|
||||
class CStringView;
|
||||
class StringLiteral;
|
||||
class StringView;
|
||||
@@ -289,7 +289,7 @@ constexpr auto isOxString(const BasicString<sz>*) noexcept {
|
||||
}
|
||||
|
||||
template<std::size_t sz>
|
||||
constexpr auto isOxString(const BString<sz>*) noexcept {
|
||||
constexpr auto isOxString(const IString<sz>*) noexcept {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
2
deps/ox/src/ox/std/units.hpp
vendored
2
deps/ox/src/ox/std/units.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
33
deps/ox/src/ox/std/utility.hpp
vendored
33
deps/ox/src/ox/std/utility.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@@ -8,7 +8,27 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#if __has_include(<utility>)
|
||||
#include <utility>
|
||||
#include "typetraits.hpp"
|
||||
#else
|
||||
#include "typetraits.hpp"
|
||||
namespace std {
|
||||
|
||||
template<typename T>
|
||||
constexpr typename ox::remove_reference<T>::type &&move(T &&t) noexcept {
|
||||
return static_cast<typename ox::remove_reference<T>::type&&>(t);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr void swap(T &a, T &b) noexcept {
|
||||
auto temp = std::move(a);
|
||||
a = std::move(b);
|
||||
b = std::move(temp);
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace ox {
|
||||
|
||||
@@ -30,14 +50,3 @@ constexpr T &&forward(remove_reference_t<T> &&t) noexcept {
|
||||
|
||||
}
|
||||
|
||||
|
||||
#if __has_include(<utility>)
|
||||
#include <utility>
|
||||
#else
|
||||
namespace std {
|
||||
template<typename T>
|
||||
constexpr typename ox::remove_reference<T>::type &&move(T &&t) noexcept {
|
||||
return static_cast<typename ox::remove_reference<T>::type&&>(t);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
2
deps/ox/src/ox/std/uuid.cpp
vendored
2
deps/ox/src/ox/std/uuid.cpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
12
deps/ox/src/ox/std/uuid.hpp
vendored
12
deps/ox/src/ox/std/uuid.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@@ -9,7 +9,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "array.hpp"
|
||||
#include "bstring.hpp"
|
||||
#include "istring.hpp"
|
||||
#include "buffer.hpp"
|
||||
#include "random.hpp"
|
||||
#include "ranges.hpp"
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
namespace ox {
|
||||
|
||||
using UUIDStr = ox::BString<36>;
|
||||
using UUIDStr = ox::IString<36>;
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -61,7 +61,7 @@ constexpr ox::Result<uint8_t> fromHex(ox::CRStringView v) noexcept {
|
||||
return out;
|
||||
}
|
||||
|
||||
constexpr ox::BString<2> toHex(uint8_t v) noexcept {
|
||||
constexpr ox::IString<2> toHex(uint8_t v) noexcept {
|
||||
constexpr ox::Array<char, 16> valMap {
|
||||
'0',
|
||||
'1',
|
||||
@@ -155,7 +155,7 @@ class UUID {
|
||||
for (auto i = 0u; i < cnt; ++i) {
|
||||
const auto v = value[valueI];
|
||||
const auto h = detail::toHex(v);
|
||||
oxIgnoreError(writer.write(h.c_str(), h.len()));
|
||||
std::ignore = writer.write(h.c_str(), h.len());
|
||||
++valueI;
|
||||
}
|
||||
};
|
||||
@@ -175,7 +175,7 @@ class UUID {
|
||||
constexpr UUIDStr toString() const noexcept {
|
||||
UUIDStr out;
|
||||
ox::CharBuffWriter bw(out.data(), out.cap());
|
||||
oxIgnoreError(toString(bw));
|
||||
std::ignore = toString(bw);
|
||||
out[out.cap()] = 0;
|
||||
return out;
|
||||
}
|
||||
|
2
deps/ox/src/ox/std/vec.cpp
vendored
2
deps/ox/src/ox/std/vec.cpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
2
deps/ox/src/ox/std/vec.hpp
vendored
2
deps/ox/src/ox/std/vec.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
81
deps/ox/src/ox/std/vector.hpp
vendored
81
deps/ox/src/ox/std/vector.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@@ -52,13 +52,15 @@ struct VectorAllocator {
|
||||
const std::size_t cap) noexcept {
|
||||
// this totally idiotic redundant check (&& count <= Size) is required to address a bug in devkitARM,
|
||||
// try removing it later
|
||||
if (cap <= m_data.size() && count <= m_data.size()) {
|
||||
for (auto i = 0u; i < count; ++i) {
|
||||
const auto dstItem = reinterpret_cast<T*>(&m_data[i]);
|
||||
const auto srcItem = reinterpret_cast<T*>(&src->m_data[i]);
|
||||
std::construct_at<T>(dstItem, std::move(*srcItem));
|
||||
if (!std::is_constant_evaluated()) {
|
||||
if (cap <= m_data.size() && count <= m_data.size()) {
|
||||
for (auto i = 0u; i < count; ++i) {
|
||||
const auto dstItem = reinterpret_cast<T *>(&m_data[i]);
|
||||
const auto srcItem = reinterpret_cast<T *>(&src->m_data[i]);
|
||||
std::construct_at<T>(dstItem, std::move(*srcItem));
|
||||
}
|
||||
*items = reinterpret_cast<T*>(m_data.data());
|
||||
}
|
||||
*items = reinterpret_cast<T*>(m_data.data());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,20 +71,24 @@ struct VectorAllocator {
|
||||
const std::size_t cap) noexcept {
|
||||
// this totally idiotic redundant check (&& count <= Size) is required to address a bug in devkitARM,
|
||||
// try removing it later
|
||||
if (cap <= m_data.size() && count <= m_data.size()) {
|
||||
for (std::size_t i = 0; i < count; ++i) {
|
||||
const auto dstItem = reinterpret_cast<T*>(&m_data[i]);
|
||||
const auto srcItem = reinterpret_cast<T*>(&src->m_data[i]);
|
||||
*dstItem = std::move(*srcItem);
|
||||
if (!std::is_constant_evaluated()) {
|
||||
if (cap <= m_data.size() && count <= m_data.size()) {
|
||||
for (std::size_t i = 0; i < count; ++i) {
|
||||
const auto dstItem = reinterpret_cast<T *>(&m_data[i]);
|
||||
const auto srcItem = reinterpret_cast<T *>(&src->m_data[i]);
|
||||
*dstItem = std::move(*srcItem);
|
||||
}
|
||||
*items = reinterpret_cast<T*>(m_data.data());
|
||||
}
|
||||
*items = reinterpret_cast<T*>(m_data.data());
|
||||
}
|
||||
}
|
||||
|
||||
constexpr void deallocate(T *items, std::size_t cap) noexcept {
|
||||
// small vector optimization cannot be done it constexpr, but it doesn't really matter in constexpr
|
||||
if (std::is_constant_evaluated() || (items && static_cast<void*>(items) != static_cast<void*>(m_data.data()))) {
|
||||
m_allocator.deallocate(items, cap);
|
||||
if (std::is_constant_evaluated()) {
|
||||
if (items && static_cast<void*>(items) != static_cast<void*>(m_data.data())) {
|
||||
m_allocator.deallocate(items, cap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,12 +269,12 @@ class Vector: detail::VectorAllocator<T, Allocator, SmallVectorSize> {
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr bool contains(MaybeView_t<T> const&) const noexcept(useNoexcept);
|
||||
constexpr bool contains(MaybeView_t<T> const&) const noexcept;
|
||||
|
||||
constexpr iterator<T&, T*, false> insert(
|
||||
std::size_t pos, std::size_t cnt, MaybeView_t<T> const&val) noexcept(useNoexcept);
|
||||
std::size_t pos, std::size_t cnt, T val) noexcept(useNoexcept);
|
||||
|
||||
constexpr iterator<T&, T*, false> insert(std::size_t pos, MaybeView_t<T> const&val) noexcept(useNoexcept);
|
||||
constexpr iterator<T&, T*, false> insert(std::size_t pos, T val) noexcept(useNoexcept);
|
||||
|
||||
template<typename... Args>
|
||||
constexpr iterator<T&, T*, false> emplace(std::size_t pos, Args&&... args) noexcept(useNoexcept);
|
||||
@@ -276,9 +282,7 @@ class Vector: detail::VectorAllocator<T, Allocator, SmallVectorSize> {
|
||||
template<typename... Args>
|
||||
constexpr T &emplace_back(Args&&... args) noexcept(useNoexcept);
|
||||
|
||||
constexpr void push_back(T &&item) noexcept(useNoexcept);
|
||||
|
||||
constexpr void push_back(MaybeView_t<T> const&item) noexcept(useNoexcept);
|
||||
constexpr void push_back(T item) noexcept(useNoexcept);
|
||||
|
||||
constexpr void pop_back() noexcept(useNoexcept);
|
||||
|
||||
@@ -516,8 +520,8 @@ constexpr void Vector<T, SmallVectorSize, Allocator>::resize(std::size_t size) n
|
||||
}
|
||||
|
||||
template<typename T, std::size_t SmallVectorSize, typename Allocator>
|
||||
constexpr bool Vector<T, SmallVectorSize, Allocator>::contains(MaybeView_t<T> const&v) const noexcept(useNoexcept) {
|
||||
for (std::size_t i = 0; i < m_size; i++) {
|
||||
constexpr bool Vector<T, SmallVectorSize, Allocator>::contains(MaybeView_t<T> const&v) const noexcept {
|
||||
for (std::size_t i = 0; i < m_size; ++i) {
|
||||
if (m_items[i] == v) {
|
||||
return true;
|
||||
}
|
||||
@@ -528,14 +532,14 @@ constexpr bool Vector<T, SmallVectorSize, Allocator>::contains(MaybeView_t<T> co
|
||||
template<typename T, std::size_t SmallVectorSize, typename Allocator>
|
||||
constexpr typename Vector<T, SmallVectorSize, Allocator>::template iterator<T&, T*, false>
|
||||
Vector<T, SmallVectorSize, Allocator>::insert(
|
||||
std::size_t pos, std::size_t cnt, MaybeView_t<T> const&val) noexcept(useNoexcept) {
|
||||
std::size_t pos, std::size_t cnt, T val) noexcept(useNoexcept) {
|
||||
if (m_size + cnt > m_cap) {
|
||||
reserveInsert(m_cap ? m_size + cnt : initialCap, pos, cnt);
|
||||
if (pos < m_size) {
|
||||
m_items[pos] = val;
|
||||
m_items[pos] = std::move(val);
|
||||
} else {
|
||||
for (auto i = 0u; i < cnt; ++i) {
|
||||
std::construct_at(&m_items[pos + i], val);
|
||||
std::construct_at(&m_items[pos + i], m_items[pos]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -543,10 +547,10 @@ Vector<T, SmallVectorSize, Allocator>::insert(
|
||||
for (auto i = m_size + cnt - 1; i > pos; --i) {
|
||||
std::construct_at(&m_items[i], std::move(m_items[i - cnt]));
|
||||
}
|
||||
m_items[pos] = val;
|
||||
m_items[pos] = std::move(val);
|
||||
} else {
|
||||
for (auto i = 0u; i < cnt; ++i) {
|
||||
std::construct_at(&m_items[pos + i], val);
|
||||
std::construct_at(&m_items[pos + i], m_items[pos]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -556,22 +560,22 @@ Vector<T, SmallVectorSize, Allocator>::insert(
|
||||
|
||||
template<typename T, std::size_t SmallVectorSize, typename Allocator>
|
||||
constexpr typename Vector<T, SmallVectorSize, Allocator>::template iterator<T&, T*, false>
|
||||
Vector<T, SmallVectorSize, Allocator>::insert(std::size_t pos, MaybeView_t<T> const&val) noexcept(useNoexcept) {
|
||||
Vector<T, SmallVectorSize, Allocator>::insert(std::size_t pos, T val) noexcept(useNoexcept) {
|
||||
if (m_size == m_cap) {
|
||||
reserveInsert(m_cap ? m_cap * 2 : initialCap, pos);
|
||||
if (pos < m_size) {
|
||||
m_items[pos] = val;
|
||||
m_items[pos] = std::move(val);
|
||||
} else {
|
||||
std::construct_at(&m_items[pos], val);
|
||||
std::construct_at(&m_items[pos], m_items[pos]);
|
||||
}
|
||||
} else {
|
||||
if (pos < m_size) {
|
||||
for (auto i = m_size; i > pos; --i) {
|
||||
std::construct_at(&m_items[i], std::move(m_items[i - 1]));
|
||||
}
|
||||
m_items[pos] = val;
|
||||
m_items[pos] = std::move(val);
|
||||
} else {
|
||||
std::construct_at(&m_items[pos], val);
|
||||
std::construct_at(&m_items[pos], m_items[pos]);
|
||||
}
|
||||
}
|
||||
++m_size;
|
||||
@@ -613,7 +617,7 @@ constexpr T &Vector<T, SmallVectorSize, Allocator>::emplace_back(Args&&... args)
|
||||
}
|
||||
|
||||
template<typename T, std::size_t SmallVectorSize, typename Allocator>
|
||||
constexpr void Vector<T, SmallVectorSize, Allocator>::push_back(T &&item) noexcept(useNoexcept) {
|
||||
constexpr void Vector<T, SmallVectorSize, Allocator>::push_back(T item) noexcept(useNoexcept) {
|
||||
if (m_size == m_cap) {
|
||||
reserve(m_cap ? m_cap * 2 : initialCap);
|
||||
}
|
||||
@@ -621,15 +625,6 @@ constexpr void Vector<T, SmallVectorSize, Allocator>::push_back(T &&item) noexce
|
||||
++m_size;
|
||||
}
|
||||
|
||||
template<typename T, std::size_t SmallVectorSize, typename Allocator>
|
||||
constexpr void Vector<T, SmallVectorSize, Allocator>::push_back(MaybeView_t<T> const&item) noexcept(useNoexcept) {
|
||||
if (m_size == m_cap) {
|
||||
reserve(m_cap ? m_cap * 2 : initialCap);
|
||||
}
|
||||
std::construct_at(&m_items[m_size], item);
|
||||
++m_size;
|
||||
}
|
||||
|
||||
template<typename T, std::size_t SmallVectorSize, typename Allocator>
|
||||
constexpr void Vector<T, SmallVectorSize, Allocator>::pop_back() noexcept(useNoexcept) {
|
||||
--m_size;
|
||||
|
2
deps/ox/src/ox/std/writer.hpp
vendored
2
deps/ox/src/ox/std/writer.hpp
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 - 2022 gary@drinkingtea.net
|
||||
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
Reference in New Issue
Block a user