diff --git a/source/base/CMakeLists.txt b/source/base/CMakeLists.txt index 77778675c7..9d62727c19 100644 --- a/source/base/CMakeLists.txt +++ b/source/base/CMakeLists.txt @@ -5,7 +5,6 @@ add_library(tactile::base ALIAS tactile-base) target_sources(tactile-base INTERFACE FILE_SET "HEADERS" BASE_DIRS "inc" FILES - "inc/tactile/base/container/string.hpp" "inc/tactile/base/container/string_map.hpp" "inc/tactile/base/document/component_view.hpp" "inc/tactile/base/document/document.hpp" @@ -45,6 +44,7 @@ target_sources(tactile-base "inc/tactile/base/numeric/vec_stream.hpp" "inc/tactile/base/platform/bits.hpp" "inc/tactile/base/platform/filesystem.hpp" + "inc/tactile/base/platform/native_string.hpp" "inc/tactile/base/render/renderer.hpp" "inc/tactile/base/render/texture.hpp" "inc/tactile/base/render/window.hpp" diff --git a/source/base/inc/tactile/base/container/string.hpp b/source/base/inc/tactile/base/container/string.hpp deleted file mode 100644 index c70e695fe9..0000000000 --- a/source/base/inc/tactile/base/container/string.hpp +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2024 Albin Johansson (GNU General Public License v3.0) - -#pragma once - -#include // path -#include // basic_string, string -#include // basic_string_view, string_view, wstring_view -#include // conditional_t - -#include "tactile/base/prelude.hpp" - -#if TACTILE_OS_WINDOWS - #define TACTILE_NATIVE_STR(Str) L##Str -#else - #define TACTILE_NATIVE_STR(Str) Str -#endif - -#define TACTILE_NATIVE_CHAR(Ch) TACTILE_NATIVE_STR(Ch) - -namespace tactile { - -using String = std::string; -using StringView = std::string_view; - -using NativeChar = std::conditional_t; -using NativeString = std::basic_string; -using NativeStringView = std::basic_string_view; - -} // namespace tactile diff --git a/source/base/inc/tactile/base/container/string_map.hpp b/source/base/inc/tactile/base/container/string_map.hpp index 8662e5ea69..f464067a43 100644 --- a/source/base/inc/tactile/base/container/string_map.hpp +++ b/source/base/inc/tactile/base/container/string_map.hpp @@ -3,10 +3,11 @@ #pragma once #include // hash, equal_to +#include // string +#include // string_view #include // true_type #include // unordered_map -#include "tactile/base/container/string.hpp" #include "tactile/base/int.hpp" namespace tactile { @@ -14,7 +15,7 @@ namespace tactile { /** Custom hash object capable of hashing several string types. */ struct StringHash final { - using hash_type = std::hash; + using hash_type = std::hash; using is_transparent [[maybe_unused]] = std::true_type; [[nodiscard]] auto operator()(const char* str) const -> usize @@ -22,12 +23,12 @@ struct StringHash final return hash_type {}(str); } - [[nodiscard]] auto operator()(StringView str) const -> usize + [[nodiscard]] auto operator()(const std::string_view str) const -> usize { return hash_type {}(str); } - [[nodiscard]] auto operator()(const String& str) const -> usize + [[nodiscard]] auto operator()(const std::string& str) const -> usize { return hash_type {}(str); } @@ -35,6 +36,6 @@ struct StringHash final /** A hash map optimized for string keys, using heterogeneous lookups. */ template -using StringMap = std::unordered_map>; +using StringMap = std::unordered_map>; } // namespace tactile diff --git a/source/base/inc/tactile/base/document/component_view.hpp b/source/base/inc/tactile/base/document/component_view.hpp index a9f9c76f0f..94121b19f5 100644 --- a/source/base/inc/tactile/base/document/component_view.hpp +++ b/source/base/inc/tactile/base/document/component_view.hpp @@ -3,10 +3,11 @@ #pragma once #include // expected +#include // string +#include // string_view #include // error_code #include // pair -#include "tactile/base/container/string.hpp" #include "tactile/base/int.hpp" #include "tactile/base/prelude.hpp" @@ -42,7 +43,7 @@ class IComponentView * A component name. */ [[nodiscard]] - virtual auto get_name() const -> StringView = 0; + virtual auto get_name() const -> std::string_view = 0; /** * Returns an attribute in the component. @@ -54,7 +55,7 @@ class IComponentView */ [[nodiscard]] virtual auto get_attribute(usize index) const - -> std::pair = 0; + -> std::pair = 0; /** * Returns the number of attributes in the component. diff --git a/source/base/inc/tactile/base/document/layer_view.hpp b/source/base/inc/tactile/base/document/layer_view.hpp index f452bd4c12..4efc15b67e 100644 --- a/source/base/inc/tactile/base/document/layer_view.hpp +++ b/source/base/inc/tactile/base/document/layer_view.hpp @@ -6,7 +6,6 @@ #include // optional #include // error_code -#include "tactile/base/container/string.hpp" #include "tactile/base/id.hpp" #include "tactile/base/io/byte_stream.hpp" #include "tactile/base/io/compress/compression_format.hpp" diff --git a/source/base/inc/tactile/base/document/meta_view.hpp b/source/base/inc/tactile/base/document/meta_view.hpp index 7daa4748a3..b54a8e6406 100644 --- a/source/base/inc/tactile/base/document/meta_view.hpp +++ b/source/base/inc/tactile/base/document/meta_view.hpp @@ -2,9 +2,10 @@ #pragma once -#include // pair +#include // string +#include // string_view +#include // pair -#include "tactile/base/container/string.hpp" #include "tactile/base/int.hpp" #include "tactile/base/prelude.hpp" @@ -27,7 +28,7 @@ class IMetaView * A context name. */ [[nodiscard]] - virtual auto get_name() const -> StringView = 0; + virtual auto get_name() const -> std::string_view = 0; /** * Returns a property attached to the context. @@ -39,7 +40,7 @@ class IMetaView */ [[nodiscard]] virtual auto get_property(usize index) const - -> std::pair = 0; + -> std::pair = 0; /** * Returns the number of properties attached to the context. diff --git a/source/base/inc/tactile/base/document/object_view.hpp b/source/base/inc/tactile/base/document/object_view.hpp index b7c71277d0..83d9e03727 100644 --- a/source/base/inc/tactile/base/document/object_view.hpp +++ b/source/base/inc/tactile/base/document/object_view.hpp @@ -3,9 +3,9 @@ #pragma once #include // expected +#include // string_view #include // error_code -#include "tactile/base/container/string.hpp" #include "tactile/base/id.hpp" #include "tactile/base/layer/object_type.hpp" #include "tactile/base/numeric/vec.hpp" @@ -99,7 +99,7 @@ class IObjectView * A type tag. */ [[nodiscard]] - virtual auto get_tag() const -> StringView = 0; + virtual auto get_tag() const -> std::string_view = 0; /** * Indicates whether the object is visible. diff --git a/source/base/inc/tactile/base/document/tileset_view.hpp b/source/base/inc/tactile/base/document/tileset_view.hpp index 20c962477d..f09348da1f 100644 --- a/source/base/inc/tactile/base/document/tileset_view.hpp +++ b/source/base/inc/tactile/base/document/tileset_view.hpp @@ -4,9 +4,9 @@ #include // expected #include // path +#include // string #include // error_code -#include "tactile/base/container/string.hpp" #include "tactile/base/id.hpp" #include "tactile/base/numeric/vec.hpp" #include "tactile/base/prelude.hpp" @@ -120,7 +120,7 @@ class ITilesetView * A filename without a file extension. */ [[nodiscard]] - virtual auto get_filename() const -> String = 0; + virtual auto get_filename() const -> std::string = 0; }; } // namespace tactile diff --git a/source/base/inc/tactile/base/io/color_parser.hpp b/source/base/inc/tactile/base/io/color_parser.hpp index 425157f42d..c99f1f6268 100644 --- a/source/base/inc/tactile/base/io/color_parser.hpp +++ b/source/base/inc/tactile/base/io/color_parser.hpp @@ -2,9 +2,10 @@ #pragma once -#include // optional, nullopt +#include // optional, nullopt +#include // string +#include // string_view -#include "tactile/base/container/string.hpp" #include "tactile/base/io/int_parser.hpp" #include "tactile/base/meta/color.hpp" #include "tactile/base/prelude.hpp" @@ -20,7 +21,7 @@ namespace tactile { * A color if successful; an empty optional otherwise. */ [[nodiscard]] -constexpr auto parse_color_rgb(const StringView rgb) noexcept -> std::optional +constexpr auto parse_color_rgb(const std::string_view rgb) noexcept -> std::optional { if (rgb.length() != 7 || rgb.front() != '#') { return std::nullopt; @@ -49,7 +50,7 @@ constexpr auto parse_color_rgb(const StringView rgb) noexcept -> std::optional std::optional +constexpr auto parse_color_rgba(const std::string_view rgba) noexcept -> std::optional { if (rgba.length() != 9 || rgba.front() != '#') { return std::nullopt; @@ -79,7 +80,7 @@ constexpr auto parse_color_rgba(const StringView rgba) noexcept -> std::optional * A color if successful; an empty optional otherwise. */ [[nodiscard]] -constexpr auto parse_color_argb(const StringView argb) noexcept -> std::optional +constexpr auto parse_color_argb(const std::string_view argb) noexcept -> std::optional { if (argb.length() != 9 || argb.front() != '#') { return std::nullopt; diff --git a/source/base/inc/tactile/base/io/file_io.hpp b/source/base/inc/tactile/base/io/file_io.hpp index db8d6cf473..91a0c7a730 100644 --- a/source/base/inc/tactile/base/io/file_io.hpp +++ b/source/base/inc/tactile/base/io/file_io.hpp @@ -7,8 +7,8 @@ #include // ios #include // istreambuf_iterator #include // optional +#include // string -#include "tactile/base/container/string.hpp" #include "tactile/base/prelude.hpp" namespace tactile { @@ -21,12 +21,13 @@ namespace tactile { * \return * The file content if successful; an empty optional otherwise. */ -inline auto read_binary_file(const std::filesystem::path& path) -> std::optional +inline auto read_binary_file(const std::filesystem::path& path) -> std::optional { std::ifstream stream {path, std::ios::in | std::ios::binary}; if (stream.good()) { - return String {std::istreambuf_iterator {stream}, std::istreambuf_iterator {}}; + return std::string {std::istreambuf_iterator {stream}, + std::istreambuf_iterator {}}; } return std::nullopt; diff --git a/source/base/inc/tactile/base/io/int_parser.hpp b/source/base/inc/tactile/base/io/int_parser.hpp index 85ee5fac44..6031ce8722 100644 --- a/source/base/inc/tactile/base/io/int_parser.hpp +++ b/source/base/inc/tactile/base/io/int_parser.hpp @@ -4,9 +4,10 @@ #include // from_chars #include // optional +#include // string +#include // string_view #include // errc -#include "tactile/base/container/string.hpp" #include "tactile/base/int.hpp" #include "tactile/base/prelude.hpp" @@ -24,8 +25,8 @@ namespace tactile { * An integer if successful; an empty optional otherwise. */ template -[[nodiscard]] constexpr auto parse(StringView str, - const int base = 10) noexcept -> std::optional +[[nodiscard]] constexpr auto parse(std::string_view str, const int base = 10) noexcept + -> std::optional { const auto* const begin = str.data(); const auto* const end = begin + str.size(); diff --git a/source/base/inc/tactile/base/io/save/ir.hpp b/source/base/inc/tactile/base/io/save/ir.hpp index dc979e2268..a083d0a8e6 100644 --- a/source/base/inc/tactile/base/io/save/ir.hpp +++ b/source/base/inc/tactile/base/io/save/ir.hpp @@ -4,9 +4,9 @@ #include // path #include // optional +#include // string #include // vector -#include "tactile/base/container/string.hpp" #include "tactile/base/id.hpp" #include "tactile/base/io/compress/compression_format.hpp" #include "tactile/base/layer/layer_type.hpp" @@ -26,13 +26,14 @@ namespace tactile::ir { struct NamedAttribute final { /** The attribute name. */ - String name; + std::string name; /** The attribute value. */ Attribute value; [[nodiscard]] - auto operator==(const NamedAttribute&) const -> bool = default; + auto + operator==(const NamedAttribute&) const -> bool = default; }; /** @@ -41,13 +42,14 @@ struct NamedAttribute final struct Component final { /** The component name. */ - String name; + std::string name; /** The component attribute defaults. */ std::vector attributes; [[nodiscard]] - auto operator==(const Component&) const -> bool = default; + auto + operator==(const Component&) const -> bool = default; }; /** @@ -57,13 +59,14 @@ struct Component final struct AttachedComponent final { /** The component type name. */ - String type; + std::string type; /** The component attributes. */ std::vector attributes; [[nodiscard]] - auto operator==(const AttachedComponent&) const -> bool = default; + auto + operator==(const AttachedComponent&) const -> bool = default; }; /** @@ -72,7 +75,7 @@ struct AttachedComponent final struct Metadata final { /** The name of the context. */ - String name; + std::string name; /** The attached properties. */ std::vector properties; @@ -81,7 +84,8 @@ struct Metadata final std::vector components; [[nodiscard]] - auto operator==(const Metadata&) const -> bool = default; + auto + operator==(const Metadata&) const -> bool = default; }; /** @@ -105,13 +109,14 @@ struct Object final Float2 size; /** A user-provided label. */ - String tag; + std::string tag; /** Whether the object is rendered. */ bool visible; [[nodiscard]] - auto operator==(const Object&) const -> bool = default; + auto + operator==(const Object&) const -> bool = default; }; /** @@ -147,7 +152,8 @@ struct Layer final bool visible {}; [[nodiscard]] - auto operator==(const Layer&) const -> bool = default; + auto + operator==(const Layer&) const -> bool = default; }; /** @@ -162,7 +168,8 @@ struct AnimationFrame final Milliseconds duration; [[nodiscard]] - auto operator==(const AnimationFrame&) const -> bool = default; + auto + operator==(const AnimationFrame&) const -> bool = default; }; using TileAnimation = std::vector; @@ -185,7 +192,8 @@ struct Tile final TileAnimation animation; [[nodiscard]] - auto operator==(const Tile&) const -> bool = default; + auto + operator==(const Tile&) const -> bool = default; }; /** @@ -218,7 +226,8 @@ struct Tileset final bool is_embedded; [[nodiscard]] - auto operator==(const Tileset&) const -> bool = default; + auto + operator==(const Tileset&) const -> bool = default; }; /** @@ -233,7 +242,8 @@ struct TilesetRef final TileID first_tile_id; [[nodiscard]] - auto operator==(const TilesetRef&) const -> bool = default; + auto + operator==(const TilesetRef&) const -> bool = default; }; /** @@ -251,7 +261,8 @@ struct TileFormat final std::optional compression_level; [[nodiscard]] - auto operator==(const TileFormat&) const -> bool = default; + auto + operator==(const TileFormat&) const -> bool = default; }; /** @@ -287,7 +298,8 @@ struct Map final std::vector layers; [[nodiscard]] - auto operator==(const Map&) const -> bool = default; + auto + operator==(const Map&) const -> bool = default; }; } // namespace tactile::ir diff --git a/source/base/inc/tactile/base/io/save/save_format_parse_error.hpp b/source/base/inc/tactile/base/io/save/save_format_parse_error.hpp index aa817c31f2..a0935cce6b 100644 --- a/source/base/inc/tactile/base/io/save/save_format_parse_error.hpp +++ b/source/base/inc/tactile/base/io/save/save_format_parse_error.hpp @@ -2,7 +2,8 @@ #pragma once -#include "tactile/base/container/string.hpp" +#include // string_view + #include "tactile/base/int.hpp" #include "tactile/base/prelude.hpp" @@ -79,7 +80,7 @@ enum class SaveFormatParseError : uint8 * An error description. */ [[nodiscard]] -constexpr auto to_string(const SaveFormatParseError error) noexcept -> StringView +constexpr auto to_string(const SaveFormatParseError error) noexcept -> std::string_view { switch (error) { case SaveFormatParseError::kNoPropertyName: return "missing property name"; diff --git a/source/base/inc/tactile/base/meta/attribute.hpp b/source/base/inc/tactile/base/meta/attribute.hpp index c249f467b0..b1b26bc9b0 100644 --- a/source/base/inc/tactile/base/meta/attribute.hpp +++ b/source/base/inc/tactile/base/meta/attribute.hpp @@ -6,11 +6,11 @@ #include // same_as, convertible_to #include // path #include // logic_error +#include // string #include // decay_t #include // move #include // variant, visit -#include "tactile/base/container/string.hpp" #include "tactile/base/id.hpp" #include "tactile/base/meta/attribute_type.hpp" #include "tactile/base/meta/color.hpp" @@ -22,7 +22,7 @@ namespace tactile { template concept AttributeValueType = std::same_as || // - std::convertible_to || // + std::convertible_to || // std::convertible_to || // std::convertible_to || // std::convertible_to || // @@ -56,7 +56,7 @@ class Attribute final inline static constexpr usize kObjRefTypeIndex = 12; public: - using string_type = String; + using string_type = std::string; using int_type = int32; using int2_type = Int2; using int3_type = Int3; diff --git a/source/base/inc/tactile/base/platform/filesystem.hpp b/source/base/inc/tactile/base/platform/filesystem.hpp index b90b6c01eb..dfd94328f1 100644 --- a/source/base/inc/tactile/base/platform/filesystem.hpp +++ b/source/base/inc/tactile/base/platform/filesystem.hpp @@ -4,8 +4,8 @@ #include // replace #include // path +#include // string -#include "tactile/base/container/string.hpp" #include "tactile/base/prelude.hpp" namespace tactile { @@ -19,7 +19,7 @@ namespace tactile { * A string that represents the provided path but using forward slashes. */ [[nodiscard]] -inline auto normalize_path_separators(const std::filesystem::path& path) -> String +inline auto normalize_path_separators(const std::filesystem::path& path) -> std::string { auto path_str = path.string(); diff --git a/source/base/inc/tactile/base/platform/native_string.hpp b/source/base/inc/tactile/base/platform/native_string.hpp new file mode 100644 index 0000000000..4eac64da6c --- /dev/null +++ b/source/base/inc/tactile/base/platform/native_string.hpp @@ -0,0 +1,23 @@ +// Copyright (C) 2024 Albin Johansson (GNU General Public License v3.0) + +#pragma once + +#include // basic_string +#include // basic_string_view + +#include "tactile/base/prelude.hpp" + +#if TACTILE_OS_WINDOWS + #define TACTILE_NATIVE_STR(Str) L##Str +#else + #define TACTILE_NATIVE_STR(Str) Str +#endif + +#define TACTILE_NATIVE_CHAR(Ch) TACTILE_NATIVE_STR(Ch) + +namespace tactile { + +using NativeString = std::basic_string; +using NativeStringView = std::basic_string_view; + +} // namespace tactile diff --git a/source/base/inc/tactile/base/prelude.hpp b/source/base/inc/tactile/base/prelude.hpp index 4240427e4a..b614bdaf1b 100644 --- a/source/base/inc/tactile/base/prelude.hpp +++ b/source/base/inc/tactile/base/prelude.hpp @@ -86,7 +86,7 @@ #define TACTILE_INIT_COPY(Name, Op) \ Name(const Name&) = Op; \ - auto operator=(const Name&)->Name& = Op + auto operator=(const Name&) -> Name& = Op #define TACTILE_INIT_MOVE(Name, Op) \ Name(Name&&) noexcept = Op; \ @@ -100,7 +100,7 @@ #define TACTILE_DECLARE_COPY(Name) \ Name(const Name&); \ - auto operator=(const Name&)->Name& + auto operator=(const Name&) -> Name& #define TACTILE_DECLARE_MOVE(Name) \ Name(Name&&) noexcept; \ diff --git a/source/base/inc/tactile/base/util/buffer.hpp b/source/base/inc/tactile/base/util/buffer.hpp index b54fdb7272..3a08bdb767 100644 --- a/source/base/inc/tactile/base/util/buffer.hpp +++ b/source/base/inc/tactile/base/util/buffer.hpp @@ -2,14 +2,15 @@ #pragma once -#include // min, copy_n -#include // array -#include // same_as, input_iterator -#include // abs -#include // distance -#include // span +#include // min, copy_n +#include // array +#include // same_as, input_iterator +#include // abs +#include // distance +#include // span +#include // string +#include // string_view -#include "tactile/base/container/string.hpp" #include "tactile/base/int.hpp" #include "tactile/base/numeric/saturate_cast.hpp" #include "tactile/base/numeric/sign_cast.hpp" @@ -247,7 +248,7 @@ class Buffer final */ [[nodiscard]] constexpr auto view() const noexcept -> std::span - requires(!std::same_as) + requires(!std::same_as) { return std::span {data(), size()}; } @@ -259,10 +260,10 @@ class Buffer final * A string view. */ [[nodiscard]] - constexpr auto view() const noexcept -> StringView - requires(std::same_as) + constexpr auto view() const noexcept -> std::string_view + requires(std::same_as) { - return StringView {data(), size()}; + return std::string_view {data(), size()}; } private: diff --git a/source/base/inc/tactile/base/util/format.hpp b/source/base/inc/tactile/base/util/format.hpp index cd2ca2b4a7..58cac7d292 100644 --- a/source/base/inc/tactile/base/util/format.hpp +++ b/source/base/inc/tactile/base/util/format.hpp @@ -4,11 +4,12 @@ #include // format_to_n, vformat_to, make_format_args, format_args #include // back_inserter +#include // string +#include // string_view #include // type_identity_t #include // forward #include // __cpp_lib_format -#include "tactile/base/container/string.hpp" #include "tactile/base/int.hpp" #include "tactile/base/prelude.hpp" #include "tactile/base/util/buffer.hpp" @@ -36,7 +37,7 @@ using FormatString = std::format_string...>; #else template -using FormatString = StringView; +using FormatString = std::string_view; #endif @@ -53,7 +54,9 @@ using FormatString = StringView; * \param args The format arguments. */ template -void vformat_to_buffer(Buffer& buffer, const StringView fmt, std::format_args args) +void vformat_to_buffer(Buffer& buffer, + const std::string_view fmt, + std::format_args args) { const auto remaining_chars = buffer.capacity() - buffer.size(); if (remaining_chars < 1) { diff --git a/source/base/inc/tactile/base/util/strong_type.hpp b/source/base/inc/tactile/base/util/strong_type.hpp index 5f4f0e1560..7441b12acc 100644 --- a/source/base/inc/tactile/base/util/strong_type.hpp +++ b/source/base/inc/tactile/base/util/strong_type.hpp @@ -21,16 +21,16 @@ -> std::strong_ordering = default; \ }; \ \ - inline auto operator<<(std::ostream& stream, const Name obj)->std::ostream& \ + inline auto operator<<(std::ostream& stream, const Name obj) -> std::ostream& \ { \ stream << obj.value; \ return stream; \ } \ static_assert(true, "Missing semicolon") -#define TACTILE_STRONG_TYPE_ADD_BINARY_OP(Type, Op) \ - [[nodiscard]] constexpr auto operator Op(const Type t1, const Type t2)->Type \ - { \ - return Type {t1.value Op t2.value}; \ - } \ +#define TACTILE_STRONG_TYPE_ADD_BINARY_OP(Type, Op) \ + [[nodiscard]] constexpr auto operator Op(const Type t1, const Type t2) -> Type \ + { \ + return Type {t1.value Op t2.value}; \ + } \ static_assert(true, "Missing semicolon") diff --git a/source/base/test/src/io/int_parser_test.cpp b/source/base/test/src/io/int_parser_test.cpp index 650ef9d01d..4b90d7e35d 100644 --- a/source/base/test/src/io/int_parser_test.cpp +++ b/source/base/test/src/io/int_parser_test.cpp @@ -2,6 +2,8 @@ #include "tactile/base/io/int_parser.hpp" +#include // string_view + #include #include "tactile/base/int.hpp" @@ -36,8 +38,8 @@ TEST(StringConv, ParseValidInt) EXPECT_EQ(parse("F", 16), int64 {0xF}); EXPECT_EQ(parse("10", 8), int64 {010}); EXPECT_EQ(parse("7FFFFFFFFFFFFFFF", 16), std::numeric_limits::max()); - EXPECT_EQ(parse(StringView {"1234"}.substr(0, 2)), int64 {12}); - EXPECT_EQ(parse(StringView {"1234"}.substr(2, 2)), int64 {34}); + EXPECT_EQ(parse(std::string_view {"1234"}.substr(0, 2)), int64 {12}); + EXPECT_EQ(parse(std::string_view {"1234"}.substr(2, 2)), int64 {34}); } // tactile::parse [integral] @@ -67,8 +69,8 @@ TEST(StringConv, ParseValidUint) EXPECT_EQ(parse("F", 16), uint64 {0xF}); EXPECT_EQ(parse("10", 8), uint64 {010}); EXPECT_EQ(parse("FFFFFFFFFFFFFFFF", 16), std::numeric_limits::max()); - EXPECT_EQ(parse(StringView {"1234"}.substr(0, 2)), uint64 {12}); - EXPECT_EQ(parse(StringView {"1234"}.substr(2, 2)), uint64 {34}); + EXPECT_EQ(parse(std::string_view {"1234"}.substr(0, 2)), uint64 {12}); + EXPECT_EQ(parse(std::string_view {"1234"}.substr(2, 2)), uint64 {34}); } } // namespace tactile::test diff --git a/source/base/test/src/meta/attribute_test.cpp b/source/base/test/src/meta/attribute_test.cpp index b785f540f6..e1e9827d9e 100644 --- a/source/base/test/src/meta/attribute_test.cpp +++ b/source/base/test/src/meta/attribute_test.cpp @@ -2,6 +2,8 @@ #include "tactile/base/meta/attribute.hpp" +#include // string + #include namespace tactile { @@ -17,7 +19,7 @@ TEST(Attribute, DefaultConstructor) // tactile::Attribute::Attribute [AttributeType] TEST(Attribute, ExplicitTypeConstructor) { - EXPECT_EQ(Attribute {AttributeType::kStr}, Attribute {String {}}); + EXPECT_EQ(Attribute {AttributeType::kStr}, Attribute {std::string {}}); EXPECT_EQ(Attribute {AttributeType::kInt}, Attribute {int32 {}}); EXPECT_EQ(Attribute {AttributeType::kInt2}, Attribute {Int2 {}}); EXPECT_EQ(Attribute {AttributeType::kInt3}, Attribute {Int3 {}}); @@ -37,7 +39,7 @@ TEST(Attribute, ImplicitValueConstructor) { { const Attribute str1 {"foo"}; - const Attribute str2 {String {"bar"}}; + const Attribute str2 {std::string {"bar"}}; EXPECT_EQ(str1.get_type(), AttributeType::kStr); EXPECT_EQ(str2.get_type(), AttributeType::kStr); @@ -106,7 +108,7 @@ TEST(Attribute, Reset) attribute.reset(AttributeType::kStr); EXPECT_TRUE(attribute.has_default_value()); - EXPECT_EQ(attribute, Attribute {String {}}); + EXPECT_EQ(attribute, Attribute {std::string {}}); attribute.reset(AttributeType::kInt); EXPECT_TRUE(attribute.has_default_value()); diff --git a/source/core/inc/tactile/core/cmd/meta/rename_property_command.hpp b/source/core/inc/tactile/core/cmd/meta/rename_property_command.hpp index c67e9bcf1d..22ab5024c6 100644 --- a/source/core/inc/tactile/core/cmd/meta/rename_property_command.hpp +++ b/source/core/inc/tactile/core/cmd/meta/rename_property_command.hpp @@ -47,7 +47,7 @@ class RenamePropertyCommand final : public ICommand std::string m_old_name; std::string m_new_name; - void _rename_property(StringView from, String to); + void _rename_property(std::string_view from, std::string to); }; } // namespace tactile diff --git a/source/core/inc/tactile/core/debug/exception.hpp b/source/core/inc/tactile/core/debug/exception.hpp index 5a50993b84..3675cc0b9a 100644 --- a/source/core/inc/tactile/core/debug/exception.hpp +++ b/source/core/inc/tactile/core/debug/exception.hpp @@ -3,8 +3,8 @@ #pragma once #include // exception +#include // string -#include "tactile/base/container/string.hpp" #include "tactile/base/prelude.hpp" namespace tactile { @@ -13,17 +13,17 @@ namespace tactile { class Exception final : public std::exception { public: - TACTILE_NOINLINE explicit Exception(String message); + TACTILE_NOINLINE explicit Exception(std::string message); [[nodiscard]] auto what() const noexcept -> const char* override; [[nodiscard]] - auto trace() const -> const String&; + auto trace() const -> const std::string&; private: - String mMessage; - String mTrace; + std::string mMessage; + std::string mTrace; }; } // namespace tactile diff --git a/source/core/inc/tactile/core/debug/stacktrace.hpp b/source/core/inc/tactile/core/debug/stacktrace.hpp index 8af5fd6b30..cc18c9e0be 100644 --- a/source/core/inc/tactile/core/debug/stacktrace.hpp +++ b/source/core/inc/tactile/core/debug/stacktrace.hpp @@ -2,7 +2,8 @@ #pragma once -#include "tactile/base/container/string.hpp" +#include // string + #include "tactile/base/prelude.hpp" namespace tactile { @@ -14,6 +15,6 @@ namespace tactile { * The call stack encoded in a string. */ [[nodiscard]] -TACTILE_NOINLINE auto get_stacktrace() -> String; +TACTILE_NOINLINE auto get_stacktrace() -> std::string; } // namespace tactile diff --git a/source/core/inc/tactile/core/document/document_info.hpp b/source/core/inc/tactile/core/document/document_info.hpp index fa7524ba16..ddf6642c1e 100644 --- a/source/core/inc/tactile/core/document/document_info.hpp +++ b/source/core/inc/tactile/core/document/document_info.hpp @@ -2,7 +2,8 @@ #pragma once -#include "tactile/base/container/string.hpp" +#include // string + #include "tactile/base/numeric/vec.hpp" #include "tactile/base/prelude.hpp" #include "tactile/core/entity/entity.hpp" @@ -15,7 +16,7 @@ namespace tactile { struct CDocumentInfo final { /** The human-readable name of the document. */ - String name; + std::string name; /** The "root" entity, basically a map or a tileset. */ EntityID root; diff --git a/source/core/inc/tactile/core/document/meta_view_impl.hpp b/source/core/inc/tactile/core/document/meta_view_impl.hpp index 698090aa5a..42cfd7531c 100644 --- a/source/core/inc/tactile/core/document/meta_view_impl.hpp +++ b/source/core/inc/tactile/core/document/meta_view_impl.hpp @@ -25,10 +25,11 @@ class MetaViewImpl final : public IMetaView MetaViewImpl(const IDocument* document, EntityID meta_id); [[nodiscard]] - auto get_name() const -> StringView override; + auto get_name() const -> std::string_view override; [[nodiscard]] - auto get_property(usize index) const -> std::pair override; + auto get_property(usize index) const + -> std::pair override; [[nodiscard]] auto property_count() const -> usize override; diff --git a/source/core/inc/tactile/core/document/object_view_impl.hpp b/source/core/inc/tactile/core/document/object_view_impl.hpp index dcb2537618..3fee45c3f1 100644 --- a/source/core/inc/tactile/core/document/object_view_impl.hpp +++ b/source/core/inc/tactile/core/document/object_view_impl.hpp @@ -60,7 +60,7 @@ class ObjectViewImpl final : public IObjectView auto get_size() const -> Float2 override; [[nodiscard]] - auto get_tag() const -> StringView override; + auto get_tag() const -> std::string_view override; [[nodiscard]] auto is_visible() const -> bool override; diff --git a/source/core/inc/tactile/core/document/tileset_view_impl.hpp b/source/core/inc/tactile/core/document/tileset_view_impl.hpp index 0c4f7e8f57..396fbcb574 100644 --- a/source/core/inc/tactile/core/document/tileset_view_impl.hpp +++ b/source/core/inc/tactile/core/document/tileset_view_impl.hpp @@ -54,7 +54,7 @@ class TilesetViewImpl final : public ITilesetView auto get_meta() const -> const IMetaView& override; [[nodiscard]] - auto get_filename() const -> String override; + auto get_filename() const -> std::string override; private: const MapDocument* mDocument; diff --git a/source/core/inc/tactile/core/entity/entity.hpp b/source/core/inc/tactile/core/entity/entity.hpp index f1ccfd3887..e08d502388 100644 --- a/source/core/inc/tactile/core/entity/entity.hpp +++ b/source/core/inc/tactile/core/entity/entity.hpp @@ -2,9 +2,10 @@ #pragma once +#include // string + #include -#include "tactile/base/container/string.hpp" #include "tactile/base/prelude.hpp" namespace tactile { @@ -30,6 +31,6 @@ struct CTag * A string describing an entity identifier. */ [[nodiscard]] -auto entity_to_string(EntityID entity) -> String; +auto entity_to_string(EntityID entity) -> std::string; } // namespace tactile diff --git a/source/core/inc/tactile/core/event/component_events.hpp b/source/core/inc/tactile/core/event/component_events.hpp index 142c0be3c7..7d3fc0bb04 100644 --- a/source/core/inc/tactile/core/event/component_events.hpp +++ b/source/core/inc/tactile/core/event/component_events.hpp @@ -2,7 +2,8 @@ #pragma once -#include "tactile/base/container/string.hpp" +#include // string + #include "tactile/base/prelude.hpp" namespace tactile { @@ -18,7 +19,7 @@ struct ShowComponentEditorDialogEvent final */ struct CreateComponentEvent final { - String name; + std::string name; }; } // namespace tactile diff --git a/source/core/inc/tactile/core/event/layer_events.hpp b/source/core/inc/tactile/core/event/layer_events.hpp index f65741b8c1..db24d0a0ef 100644 --- a/source/core/inc/tactile/core/event/layer_events.hpp +++ b/source/core/inc/tactile/core/event/layer_events.hpp @@ -2,7 +2,8 @@ #pragma once -#include "tactile/base/container/string.hpp" +#include // string + #include "tactile/base/layer/layer_type.hpp" #include "tactile/base/numeric/vec.hpp" #include "tactile/base/prelude.hpp" @@ -64,7 +65,7 @@ struct RenameLayerEvent final EntityID layer_entity; /** The new layer name. */ - String name; + std::string name; }; /** diff --git a/source/core/inc/tactile/core/event/property_events.hpp b/source/core/inc/tactile/core/event/property_events.hpp index 244e5b014f..8b888430c5 100644 --- a/source/core/inc/tactile/core/event/property_events.hpp +++ b/source/core/inc/tactile/core/event/property_events.hpp @@ -2,7 +2,8 @@ #pragma once -#include "tactile/base/container/string.hpp" +#include // string + #include "tactile/base/meta/attribute.hpp" #include "tactile/base/prelude.hpp" #include "tactile/core/entity/entity.hpp" @@ -27,7 +28,7 @@ struct ShowRenamePropertyDialogEvent final EntityID context_entity; /** The target property. */ - String name; + std::string name; }; /** @@ -39,7 +40,7 @@ struct CreatePropertyEvent final EntityID context_entity; /** The new property name. */ - String name; + std::string name; /** The initial value of the property. */ Attribute value; @@ -54,7 +55,7 @@ struct UpdatePropertyEvent final EntityID context_entity; /** The target property name. */ - String name; + std::string name; /** The new value of the property. */ Attribute value; @@ -69,7 +70,7 @@ struct RemovePropertyEvent final EntityID context_entity; /** The target property name. */ - String name; + std::string name; }; /** @@ -81,10 +82,10 @@ struct RenamePropertyEvent final EntityID context_entity; /** The old property name. */ - String old_name; + std::string old_name; /** The new property name. */ - String new_name; + std::string new_name; }; } // namespace tactile diff --git a/source/core/inc/tactile/core/io/ini.hpp b/source/core/inc/tactile/core/io/ini.hpp index 583c27b3ee..1b2c66958a 100644 --- a/source/core/inc/tactile/core/io/ini.hpp +++ b/source/core/inc/tactile/core/io/ini.hpp @@ -4,15 +4,15 @@ #include // expected #include // path +#include // string #include // error_code -#include "tactile/base/container/string.hpp" #include "tactile/base/container/string_map.hpp" #include "tactile/base/prelude.hpp" namespace tactile { -using IniSection = StringMap; +using IniSection = StringMap; using IniData = StringMap; /** diff --git a/source/core/inc/tactile/core/io/save/vec_serialization.hpp b/source/core/inc/tactile/core/io/save/vec_serialization.hpp index baa99022ca..69c8b64fcf 100644 --- a/source/core/inc/tactile/core/io/save/vec_serialization.hpp +++ b/source/core/inc/tactile/core/io/save/vec_serialization.hpp @@ -3,47 +3,48 @@ #pragma once #include // expected +#include // string +#include // string_view #include // error_code -#include "tactile/base/container/string.hpp" #include "tactile/base/numeric/vec.hpp" namespace tactile { [[nodiscard]] -auto serialize(const Int2& vec) -> String; +auto serialize(const Int2& vec) -> std::string; [[nodiscard]] -auto serialize(const Float2& vec) -> String; +auto serialize(const Float2& vec) -> std::string; [[nodiscard]] -auto serialize(const Int3& vec) -> String; +auto serialize(const Int3& vec) -> std::string; [[nodiscard]] -auto serialize(const Float3& vec) -> String; +auto serialize(const Float3& vec) -> std::string; [[nodiscard]] -auto serialize(const Int4& vec) -> String; +auto serialize(const Int4& vec) -> std::string; [[nodiscard]] -auto serialize(const Float4& vec) -> String; +auto serialize(const Float4& vec) -> std::string; [[nodiscard]] -auto deserialize_int2(StringView str) -> std::expected; +auto deserialize_int2(std::string_view str) -> std::expected; [[nodiscard]] -auto deserialize_int3(StringView str) -> std::expected; +auto deserialize_int3(std::string_view str) -> std::expected; [[nodiscard]] -auto deserialize_int4(StringView str) -> std::expected; +auto deserialize_int4(std::string_view str) -> std::expected; [[nodiscard]] -auto deserialize_float2(StringView str) -> std::expected; +auto deserialize_float2(std::string_view str) -> std::expected; [[nodiscard]] -auto deserialize_float3(StringView str) -> std::expected; +auto deserialize_float3(std::string_view str) -> std::expected; [[nodiscard]] -auto deserialize_float4(StringView str) -> std::expected; +auto deserialize_float4(std::string_view str) -> std::expected; } // namespace tactile diff --git a/source/core/inc/tactile/core/layer/object.hpp b/source/core/inc/tactile/core/layer/object.hpp index edc4e1343a..7cfbe02d96 100644 --- a/source/core/inc/tactile/core/layer/object.hpp +++ b/source/core/inc/tactile/core/layer/object.hpp @@ -2,7 +2,8 @@ #pragma once -#include "tactile/base/container/string.hpp" +#include // string + #include "tactile/base/id.hpp" #include "tactile/base/layer/object_type.hpp" #include "tactile/base/numeric/vec.hpp" @@ -35,7 +36,7 @@ struct CObject final ObjectType type; /** Arbitrary user-provided tag. */ - String tag; + std::string tag; /** Indicates whether the object is rendered. */ bool is_visible; diff --git a/source/core/inc/tactile/core/log/log_sink.hpp b/source/core/inc/tactile/core/log/log_sink.hpp index 4f9b5fce50..142ccf9ff8 100644 --- a/source/core/inc/tactile/core/log/log_sink.hpp +++ b/source/core/inc/tactile/core/log/log_sink.hpp @@ -2,7 +2,8 @@ #pragma once -#include "tactile/base/container/string.hpp" +#include // string_view + #include "tactile/base/log/log_level.hpp" #include "tactile/base/prelude.hpp" #include "tactile/base/util/chrono.hpp" @@ -20,9 +21,9 @@ namespace tactile { struct LogMessage final { LogLevel level; ///< The severity of the message. - StringView prefix; ///< A string that encodes the severity and timestamp. - StringView scope; ///< Scope identifier, might be empty. - StringView text; ///< The formatted log message. + std::string_view prefix; ///< A string that encodes the severity and timestamp. + std::string_view scope; ///< Scope identifier, might be empty. + std::string_view text; ///< The formatted log message. SteadyClockInstant instant; ///< The instant that the message was logged. }; diff --git a/source/core/inc/tactile/core/log/logger.hpp b/source/core/inc/tactile/core/log/logger.hpp index 482ea3854a..68b747e0b4 100644 --- a/source/core/inc/tactile/core/log/logger.hpp +++ b/source/core/inc/tactile/core/log/logger.hpp @@ -2,12 +2,12 @@ #pragma once -#include // make_format_args, format_args -#include // unique_ptr -#include // optional -#include // vector +#include // make_format_args, format_args +#include // unique_ptr +#include // optional +#include // string_view +#include // vector -#include "tactile/base/container/string.hpp" #include "tactile/base/log/log_level.hpp" #include "tactile/base/prelude.hpp" #include "tactile/base/util/chrono.hpp" @@ -110,7 +110,7 @@ class Logger final * * \param scope An arbitrary scope identifier. */ - void set_scope(StringView scope) noexcept; + void set_scope(std::string_view scope) noexcept; /** * Returns the current scope identifier. @@ -119,7 +119,7 @@ class Logger final * An arbitrary string. */ [[nodiscard]] - auto get_scope() const noexcept -> StringView; + auto get_scope() const noexcept -> std::string_view; /** * Indicates whether a message with a specific severity will be logged. @@ -152,16 +152,16 @@ class Logger final * A log level acronym. */ [[nodiscard]] - static auto get_acronym(LogLevel level) noexcept -> StringView; + static auto get_acronym(LogLevel level) noexcept -> std::string_view; private: LogLevel mMinLevel {LogLevel::kInfo}; LogLevel mFlushLevel {LogLevel::kError}; std::vector> mSinks {}; std::optional mReferenceInstant {}; - StringView mScope {}; + std::string_view mScope {}; - void _log(LogLevel level, StringView fmt_string, std::format_args args) noexcept; + void _log(LogLevel level, std::string_view fmt_string, std::format_args args) noexcept; [[nodiscard]] auto _to_elapsed_time(SteadyClockInstant instant) const -> Microseconds; diff --git a/source/core/inc/tactile/core/log/set_log_scope.hpp b/source/core/inc/tactile/core/log/set_log_scope.hpp index 99ced7e61a..09b954f8f1 100644 --- a/source/core/inc/tactile/core/log/set_log_scope.hpp +++ b/source/core/inc/tactile/core/log/set_log_scope.hpp @@ -2,7 +2,8 @@ #pragma once -#include "tactile/base/container/string.hpp" +#include // string_view + #include "tactile/base/prelude.hpp" namespace tactile { @@ -17,7 +18,7 @@ class SetLogScope final * \param scope The new scope identifier. */ [[nodiscard]] - explicit SetLogScope(StringView scope) noexcept; + explicit SetLogScope(std::string_view scope) noexcept; /** Restores the previous logger scope identifier. */ ~SetLogScope() noexcept; @@ -26,7 +27,7 @@ class SetLogScope final TACTILE_DEFAULT_MOVE(SetLogScope); private: - StringView mPrevScope; + std::string_view mPrevScope; }; } // namespace tactile diff --git a/source/core/inc/tactile/core/log/terminal_log_sink.hpp b/source/core/inc/tactile/core/log/terminal_log_sink.hpp index 809979985b..b1ecb59e96 100644 --- a/source/core/inc/tactile/core/log/terminal_log_sink.hpp +++ b/source/core/inc/tactile/core/log/terminal_log_sink.hpp @@ -2,7 +2,8 @@ #pragma once -#include "tactile/base/container/string.hpp" +#include // string_view + #include "tactile/base/prelude.hpp" #include "tactile/core/log/log_sink.hpp" @@ -14,18 +15,18 @@ namespace tactile { class TerminalLogSink final : public ILogSink { public: - inline static constexpr StringView kAnsiColorReset = "\x1B[0m"; - inline static constexpr StringView kAnsiColorBold = "\x1B[1m"; - inline static constexpr StringView kAnsiColorFgBlack = "\x1B[30m"; - inline static constexpr StringView kAnsiColorFgBlackBold = "\x1B[30m\x1B[1m"; - inline static constexpr StringView kAnsiColorFgRed = "\x1B[31m"; - inline static constexpr StringView kAnsiColorFgRedBold = "\x1B[31m\x1B[1m"; - inline static constexpr StringView kAnsiColorFgGreen = "\x1B[32m"; - inline static constexpr StringView kAnsiColorFgYellow = "\x1B[33m"; - inline static constexpr StringView kAnsiColorFgBlue = "\x1B[34m"; - inline static constexpr StringView kAnsiColorFgMagenta = "\x1B[35m"; - inline static constexpr StringView kAnsiColorFgCyan = "\x1B[36m"; - inline static constexpr StringView kAnsiColorFgWhite = "\x1B[37m"; + static constexpr std::string_view kAnsiColorReset = "\x1B[0m"; + static constexpr std::string_view kAnsiColorBold = "\x1B[1m"; + static constexpr std::string_view kAnsiColorFgBlack = "\x1B[30m"; + static constexpr std::string_view kAnsiColorFgBlackBold = "\x1B[30m\x1B[1m"; + static constexpr std::string_view kAnsiColorFgRed = "\x1B[31m"; + static constexpr std::string_view kAnsiColorFgRedBold = "\x1B[31m\x1B[1m"; + static constexpr std::string_view kAnsiColorFgGreen = "\x1B[32m"; + static constexpr std::string_view kAnsiColorFgYellow = "\x1B[33m"; + static constexpr std::string_view kAnsiColorFgBlue = "\x1B[34m"; + static constexpr std::string_view kAnsiColorFgMagenta = "\x1B[35m"; + static constexpr std::string_view kAnsiColorFgCyan = "\x1B[36m"; + static constexpr std::string_view kAnsiColorFgWhite = "\x1B[37m"; void log(const LogMessage& msg) override; @@ -44,7 +45,7 @@ class TerminalLogSink final : public ILogSink * \param level The log level to query. */ [[nodiscard]] - static auto get_fg_ansi_color(LogLevel level) -> StringView; + static auto get_fg_ansi_color(LogLevel level) -> std::string_view; private: bool mUseAnsiColors {false}; diff --git a/source/core/inc/tactile/core/meta/attribute_type.hpp b/source/core/inc/tactile/core/meta/attribute_type.hpp index 9e2b7276bf..1dc8ca835c 100644 --- a/source/core/inc/tactile/core/meta/attribute_type.hpp +++ b/source/core/inc/tactile/core/meta/attribute_type.hpp @@ -4,9 +4,9 @@ #include // expected #include // ostream +#include // string_view #include // error_code -#include "tactile/base/container/string.hpp" #include "tactile/base/int.hpp" #include "tactile/base/meta/attribute_type.hpp" #include "tactile/base/prelude.hpp" @@ -22,7 +22,8 @@ namespace tactile { * An attribute type if successful; an error code otherwise. */ [[nodiscard]] -auto parse_attribute_type(StringView name) -> std::expected; +auto parse_attribute_type(std::string_view name) + -> std::expected; /** * Converts an attribute type to a string. @@ -36,7 +37,7 @@ auto parse_attribute_type(StringView name) -> std::expected StringView; +auto serialize(AttributeType type) -> std::string_view; /** * Outputs an attribute type to a stream for debugging purposes. diff --git a/source/core/inc/tactile/core/meta/color.hpp b/source/core/inc/tactile/core/meta/color.hpp index 7acfdb0441..d2be754843 100644 --- a/source/core/inc/tactile/core/meta/color.hpp +++ b/source/core/inc/tactile/core/meta/color.hpp @@ -6,9 +6,9 @@ #include // expected #include // ostream #include // span +#include // string #include // error_code -#include "tactile/base/container/string.hpp" #include "tactile/base/int.hpp" #include "tactile/base/meta/color.hpp" #include "tactile/base/prelude.hpp" @@ -46,7 +46,7 @@ auto make_color(const FColor& fcolor) -> UColor; * An RGB color code. */ [[nodiscard]] -auto to_string_rgb(const UColor& color) -> String; +auto to_string_rgb(const UColor& color) -> std::string; /** * Converts the color to a hexadecimal RGBA color code. @@ -55,7 +55,7 @@ auto to_string_rgb(const UColor& color) -> String; * An RGBA color code. */ [[nodiscard]] -auto to_string_rgba(const UColor& color) -> String; +auto to_string_rgba(const UColor& color) -> std::string; /** * Converts the color to a hexadecimal ARGB color code. @@ -64,7 +64,7 @@ auto to_string_rgba(const UColor& color) -> String; * An ARGB color code. */ [[nodiscard]] -auto to_string_argb(const UColor& color) -> String; +auto to_string_argb(const UColor& color) -> std::string; /** * Encodes the color as an ABGR color packed into a 32-bit integer. diff --git a/source/core/inc/tactile/core/meta/meta.hpp b/source/core/inc/tactile/core/meta/meta.hpp index dda5a0e6a8..1b6e37fe6f 100644 --- a/source/core/inc/tactile/core/meta/meta.hpp +++ b/source/core/inc/tactile/core/meta/meta.hpp @@ -2,9 +2,9 @@ #pragma once +#include // string #include // unordered_map -#include "tactile/base/container/string.hpp" #include "tactile/base/container/string_map.hpp" #include "tactile/base/meta/attribute.hpp" #include "tactile/base/prelude.hpp" @@ -34,7 +34,7 @@ using AttributeBundle = StringMap; struct CMeta final { /** The name associated with the context. */ - String name; + std::string name; /** The attached properties. */ StringMap properties; diff --git a/source/core/inc/tactile/core/platform/environment.hpp b/source/core/inc/tactile/core/platform/environment.hpp index 5f1822b9d4..f8ed6b2bb3 100644 --- a/source/core/inc/tactile/core/platform/environment.hpp +++ b/source/core/inc/tactile/core/platform/environment.hpp @@ -3,9 +3,9 @@ #pragma once #include // expected +#include // string #include // error_code -#include "tactile/base/container/string.hpp" #include "tactile/base/prelude.hpp" namespace tactile { @@ -19,6 +19,6 @@ namespace tactile { * The environment variable value; or an error code if something went wrong. */ [[nodiscard]] -auto get_env(const char* name) -> std::expected; +auto get_env(const char* name) -> std::expected; } // namespace tactile diff --git a/source/core/inc/tactile/core/platform/filesystem.hpp b/source/core/inc/tactile/core/platform/filesystem.hpp index 28324a8929..bc0f402719 100644 --- a/source/core/inc/tactile/core/platform/filesystem.hpp +++ b/source/core/inc/tactile/core/platform/filesystem.hpp @@ -4,9 +4,9 @@ #include // expected #include // path +#include // string #include // error_code -#include "tactile/base/container/string.hpp" #include "tactile/base/prelude.hpp" namespace tactile { @@ -40,7 +40,7 @@ auto get_persistent_storage_directory() * A directory path if successful; an error code otherwise. */ [[nodiscard]] -auto get_user_home_directory() -> std::expected; +auto get_user_home_directory() -> std::expected; /** * Returns the path to the associated \c imgui.ini file. @@ -66,7 +66,7 @@ auto get_imgui_ini_file_path() -> std::filesystem::path; * A file path string that uses forward slashes. */ [[nodiscard]] -auto normalize_path(const std::filesystem::path& path) -> String; +auto normalize_path(const std::filesystem::path& path) -> std::string; /** * Indicates whether a path features a given prefix. @@ -78,7 +78,7 @@ auto normalize_path(const std::filesystem::path& path) -> String; * True if the path features the specified prefix; false otherwise. */ [[nodiscard]] -auto has_prefix(const std::filesystem::path& path, StringView prefix) -> bool; +auto has_prefix(const std::filesystem::path& path, std::string_view prefix) -> bool; /** * Replaces the user home directory prefix in a file path with '~'. @@ -91,7 +91,7 @@ auto has_prefix(const std::filesystem::path& path, StringView prefix) -> bool; * applicable. */ [[nodiscard]] -auto strip_home_directory_prefix(const std::filesystem::path& path, StringView home_dir) - -> std::expected; +auto strip_home_directory_prefix(const std::filesystem::path& path, std::string_view home_dir) + -> std::expected; } // namespace tactile diff --git a/source/core/inc/tactile/core/ui/dialog/new_property_dialog.hpp b/source/core/inc/tactile/core/ui/dialog/new_property_dialog.hpp index b6f85ce30b..cec395ef30 100644 --- a/source/core/inc/tactile/core/ui/dialog/new_property_dialog.hpp +++ b/source/core/inc/tactile/core/ui/dialog/new_property_dialog.hpp @@ -2,7 +2,8 @@ #pragma once -#include "tactile/base/container/string.hpp" +#include // string + #include "tactile/base/meta/attribute.hpp" #include "tactile/base/prelude.hpp" #include "tactile/core/entity/entity.hpp" @@ -39,7 +40,7 @@ class NewPropertyDialog final private: EntityID mContextEntity {kInvalidEntity}; - String mName {}; + std::string mName {}; Attribute mValue {}; bool mShouldOpen {false}; }; diff --git a/source/core/inc/tactile/core/ui/dialog/new_tileset_dialog.hpp b/source/core/inc/tactile/core/ui/dialog/new_tileset_dialog.hpp index cf97db39d5..ea38471915 100644 --- a/source/core/inc/tactile/core/ui/dialog/new_tileset_dialog.hpp +++ b/source/core/inc/tactile/core/ui/dialog/new_tileset_dialog.hpp @@ -3,8 +3,8 @@ #pragma once #include // path +#include // string -#include "tactile/base/container/string.hpp" #include "tactile/base/numeric/vec.hpp" #include "tactile/base/prelude.hpp" #include "tactile/core/entity/entity.hpp" @@ -36,7 +36,7 @@ class NewTilesetDialog final void open(); private: - String mTexturePathPreview {}; + std::string mTexturePathPreview {}; std::filesystem::path mTexturePath {}; Int2 mTileSize {}; bool mShouldOpen {false}; diff --git a/source/core/inc/tactile/core/ui/dialog/rename_property_dialog.hpp b/source/core/inc/tactile/core/ui/dialog/rename_property_dialog.hpp index 3dfda9e2ea..a653121522 100644 --- a/source/core/inc/tactile/core/ui/dialog/rename_property_dialog.hpp +++ b/source/core/inc/tactile/core/ui/dialog/rename_property_dialog.hpp @@ -2,7 +2,8 @@ #pragma once -#include "tactile/base/container/string.hpp" +#include // string + #include "tactile/base/prelude.hpp" #include "tactile/core/entity/entity.hpp" @@ -35,12 +36,12 @@ class RenamePropertyDialog final * \param context_entity The associated meta context. * \param target_prop_name The target property in the context. */ - void open(EntityID context_entity, String target_prop_name); + void open(EntityID context_entity, std::string target_prop_name); private: EntityID mContextEntity {kInvalidEntity}; - String mTargetPropName {}; - String mNewPropName {}; + std::string mTargetPropName {}; + std::string mNewPropName {}; bool mShouldOpen {false}; }; diff --git a/source/core/inc/tactile/core/ui/i18n/language.hpp b/source/core/inc/tactile/core/ui/i18n/language.hpp index ad8e9bf3bd..9990d6b0ef 100644 --- a/source/core/inc/tactile/core/ui/i18n/language.hpp +++ b/source/core/inc/tactile/core/ui/i18n/language.hpp @@ -2,10 +2,10 @@ #pragma once +#include // string #include // to_underlying #include // vector -#include "tactile/base/container/string.hpp" #include "tactile/base/prelude.hpp" #include "tactile/core/debug/assert.hpp" #include "tactile/core/ui/i18n/language_id.hpp" @@ -63,9 +63,9 @@ class Language final private: LanguageID mID; - std::vector mStrings {}; + std::vector mStrings {}; - Language(LanguageID id, std::vector strings); + Language(LanguageID id, std::vector strings); }; } // namespace tactile::ui diff --git a/source/core/inc/tactile/core/ui/i18n/language_parser.hpp b/source/core/inc/tactile/core/ui/i18n/language_parser.hpp index 9eda8095e7..24ac4ebbee 100644 --- a/source/core/inc/tactile/core/ui/i18n/language_parser.hpp +++ b/source/core/inc/tactile/core/ui/i18n/language_parser.hpp @@ -4,10 +4,10 @@ #include // expected #include // path +#include // string_view #include // error_code #include // unordered_map -#include "tactile/base/container/string.hpp" #include "tactile/base/prelude.hpp" #include "tactile/core/ui/i18n/language.hpp" #include "tactile/core/ui/i18n/language_id.hpp" @@ -45,14 +45,14 @@ class LanguageParser final -> std::expected; private: - std::unordered_map mMiscNames {}; - std::unordered_map mVerbNames {}; - std::unordered_map mNounNames {}; - std::unordered_map mAdjectiveNames {}; - std::unordered_map mActionNames {}; - std::unordered_map mHintNames {}; - std::unordered_map mMenuNames {}; - std::unordered_map mWidgetNames {}; + std::unordered_map mMiscNames {}; + std::unordered_map mVerbNames {}; + std::unordered_map mNounNames {}; + std::unordered_map mAdjectiveNames {}; + std::unordered_map mActionNames {}; + std::unordered_map mHintNames {}; + std::unordered_map mMenuNames {}; + std::unordered_map mWidgetNames {}; }; /** diff --git a/source/core/inc/tactile/core/util/string_conv.hpp b/source/core/inc/tactile/core/util/string_conv.hpp index 0fdf341c70..a7c820f19b 100644 --- a/source/core/inc/tactile/core/util/string_conv.hpp +++ b/source/core/inc/tactile/core/util/string_conv.hpp @@ -4,11 +4,13 @@ #include // integral, signed_integral, unsigned_integral, floating_point #include // expected +#include // string +#include // string_view #include // error_code -#include "tactile/base/container/string.hpp" #include "tactile/base/int.hpp" #include "tactile/base/numeric/saturate_cast.hpp" +#include "tactile/base/platform/native_string.hpp" namespace tactile { @@ -21,7 +23,7 @@ namespace tactile { * A native string if successful; an error code otherwise. */ [[nodiscard]] -auto to_native_string(StringView str) -> std::expected; +auto to_native_string(std::string_view str) -> std::expected; /** * Converts a native string to a normal string. @@ -32,7 +34,7 @@ auto to_native_string(StringView str) -> std::expected std::expected; +auto from_native_string(NativeStringView str) -> std::expected; /** * Attempts to convert a string to a floating-point value. @@ -43,7 +45,7 @@ auto from_native_string(NativeStringView str) -> std::expected std::expected; +auto parse_float(std::string_view str) -> std::expected; /** * Attempts to convert a string to a float. @@ -56,7 +58,7 @@ auto parse_float(StringView str) -> std::expected; * A float if successful; an error code otherwise. */ template -[[nodiscard]] auto parse(const StringView str) -> std::expected +[[nodiscard]] auto parse(const std::string_view str) -> std::expected { return parse_float(str).transform([](double value) { return static_cast(value); }); } diff --git a/source/core/inc/tactile/core/util/string_ops.hpp b/source/core/inc/tactile/core/util/string_ops.hpp index 6cc5eb75ed..bd29260b75 100644 --- a/source/core/inc/tactile/core/util/string_ops.hpp +++ b/source/core/inc/tactile/core/util/string_ops.hpp @@ -2,7 +2,9 @@ #pragma once -#include "tactile/base/container/string.hpp" +#include // string +#include // string_view + #include "tactile/base/int.hpp" #include "tactile/base/prelude.hpp" #include "tactile/base/util/concepts.hpp" @@ -22,7 +24,7 @@ namespace tactile { * A trimmed string. */ [[nodiscard]] -auto trim_string(StringView str) -> String; +auto trim_string(std::string_view str) -> std::string; /** * Splits a string into a collection of tokens separated by a given character. @@ -38,8 +40,8 @@ auto trim_string(StringView str) -> String; * \return * True if the function completed without returning early; false otherwise. */ -template T> -auto split_string(const StringView str, const char separator, const T& callback) -> bool +template T> +auto split_string(const std::string_view str, const char separator, const T& callback) -> bool { usize pos = 0; const auto str_length = str.size(); @@ -47,7 +49,7 @@ auto split_string(const StringView str, const char separator, const T& callback) while (pos < str_length) { const auto separator_pos = str.find_first_of(separator, pos); - if (separator_pos == StringView::npos) { + if (separator_pos == std::string_view::npos) { const auto token = str.substr(pos); if (!callback(token)) { diff --git a/source/core/inc/tactile/core/util/uuid.hpp b/source/core/inc/tactile/core/util/uuid.hpp index da32f534f8..96e7103a08 100644 --- a/source/core/inc/tactile/core/util/uuid.hpp +++ b/source/core/inc/tactile/core/util/uuid.hpp @@ -8,8 +8,8 @@ #include // format, format_to, formattable #include // hash #include // ostream +#include // string -#include "tactile/base/container/string.hpp" #include "tactile/base/int.hpp" namespace tactile { @@ -70,7 +70,7 @@ class UUID final private: std::array mData {}; - friend auto to_string(const UUID& uuid) -> String; + friend auto to_string(const UUID& uuid) -> std::string; }; inline constexpr UUID kEmptyUuid = UUID {}; @@ -84,7 +84,7 @@ inline constexpr UUID kEmptyUuid = UUID {}; * A string with the format `HHHH-HH-HH-HH-HHHHHH`, using hexadecimal digits. */ [[nodiscard]] -auto to_string(const UUID& uuid) -> String; +auto to_string(const UUID& uuid) -> std::string; /** * Outputs a UUID value to a stream. diff --git a/source/core/src/tactile/core/cmd/meta/rename_property_command.cpp b/source/core/src/tactile/core/cmd/meta/rename_property_command.cpp index f37e1d5d41..f425a6864a 100644 --- a/source/core/src/tactile/core/cmd/meta/rename_property_command.cpp +++ b/source/core/src/tactile/core/cmd/meta/rename_property_command.cpp @@ -17,8 +17,8 @@ namespace tactile { RenamePropertyCommand::RenamePropertyCommand(IDocument* document, const EntityID context_id, - String old_name, - String new_name) : + std::string old_name, + std::string new_name) : m_document {require_not_null(document, "null document")}, m_context_id {context_id}, m_old_name {std::move(old_name)}, @@ -54,7 +54,7 @@ auto RenamePropertyCommand::merge_with(const ICommand* cmd) -> bool return true; } -void RenamePropertyCommand::_rename_property(const StringView from, String to) +void RenamePropertyCommand::_rename_property(const std::string_view from, std::string to) { TACTILE_LOG_TRACE("Renaming property '{}' to '{}'", from, to); diff --git a/source/core/src/tactile/core/debug/exception.cpp b/source/core/src/tactile/core/debug/exception.cpp index e497c363f1..2c0f9e4ddd 100644 --- a/source/core/src/tactile/core/debug/exception.cpp +++ b/source/core/src/tactile/core/debug/exception.cpp @@ -8,7 +8,7 @@ namespace tactile { -Exception::Exception(String message) : +Exception::Exception(std::string message) : mMessage {std::move(message)}, mTrace {get_stacktrace()} {} @@ -18,7 +18,7 @@ auto Exception::what() const noexcept -> const char* return mMessage.c_str(); } -auto Exception::trace() const -> const String& +auto Exception::trace() const -> const std::string& { return mTrace; } diff --git a/source/core/src/tactile/core/debug/stacktrace.cpp b/source/core/src/tactile/core/debug/stacktrace.cpp index d690b44b97..93c6590976 100644 --- a/source/core/src/tactile/core/debug/stacktrace.cpp +++ b/source/core/src/tactile/core/debug/stacktrace.cpp @@ -8,7 +8,7 @@ namespace tactile { -auto get_stacktrace() -> String +auto get_stacktrace() -> std::string { const boost::stacktrace::stacktrace trace {}; diff --git a/source/core/src/tactile/core/document/meta_view_impl.cpp b/source/core/src/tactile/core/document/meta_view_impl.cpp index 3362010650..f89cb6c0ef 100644 --- a/source/core/src/tactile/core/document/meta_view_impl.cpp +++ b/source/core/src/tactile/core/document/meta_view_impl.cpp @@ -17,7 +17,7 @@ MetaViewImpl::MetaViewImpl(const IDocument* document, const EntityID meta_id) : mMetaId {meta_id} {} -auto MetaViewImpl::get_name() const -> StringView +auto MetaViewImpl::get_name() const -> std::string_view { const auto& registry = mDocument->get_registry(); const auto& meta = registry.get(mMetaId); @@ -26,7 +26,7 @@ auto MetaViewImpl::get_name() const -> StringView } auto MetaViewImpl::get_property(const usize index) const - -> std::pair + -> std::pair { const auto& registry = mDocument->get_registry(); const auto& meta = registry.get(mMetaId); diff --git a/source/core/src/tactile/core/document/object_view_impl.cpp b/source/core/src/tactile/core/document/object_view_impl.cpp index d111a584c9..601b07d2c0 100644 --- a/source/core/src/tactile/core/document/object_view_impl.cpp +++ b/source/core/src/tactile/core/document/object_view_impl.cpp @@ -78,7 +78,7 @@ auto ObjectViewImpl::get_size() const -> Float2 return object.size; } -auto ObjectViewImpl::get_tag() const -> StringView +auto ObjectViewImpl::get_tag() const -> std::string_view { const auto& registry = mDocument->get_registry(); const auto& object = registry.get(mObjectId); diff --git a/source/core/src/tactile/core/document/tileset_view_impl.cpp b/source/core/src/tactile/core/document/tileset_view_impl.cpp index 082d805dfa..1b4ade5747 100644 --- a/source/core/src/tactile/core/document/tileset_view_impl.cpp +++ b/source/core/src/tactile/core/document/tileset_view_impl.cpp @@ -111,7 +111,7 @@ auto TilesetViewImpl::get_meta() const -> const IMetaView& return mMeta; } -auto TilesetViewImpl::get_filename() const -> String +auto TilesetViewImpl::get_filename() const -> std::string { return get_image_path().stem().string(); } diff --git a/source/core/src/tactile/core/entity/entity.cpp b/source/core/src/tactile/core/entity/entity.cpp index 1860dba1b7..06339cb935 100644 --- a/source/core/src/tactile/core/entity/entity.cpp +++ b/source/core/src/tactile/core/entity/entity.cpp @@ -6,7 +6,7 @@ namespace tactile { -auto entity_to_string(const EntityID entity) -> String +auto entity_to_string(const EntityID entity) -> std::string { return std::format("<{}v{}>", entt::to_entity(entity), entt::to_version(entity)); } diff --git a/source/core/src/tactile/core/io/ini.cpp b/source/core/src/tactile/core/io/ini.cpp index da9bb73838..7fab7ac0e8 100644 --- a/source/core/src/tactile/core/io/ini.cpp +++ b/source/core/src/tactile/core/io/ini.cpp @@ -23,8 +23,8 @@ inline constexpr char kSectionOpenToken = '['; inline constexpr char kSectionCloseToken = ']'; [[nodiscard]] -auto _parse_section_header_name(const StringView current_line, const int line_number) - -> std::expected +auto _parse_section_header_name(const std::string_view current_line, const int line_number) + -> std::expected { TACTILE_ASSERT(current_line.starts_with(kSectionOpenToken)); @@ -34,17 +34,17 @@ auto _parse_section_header_name(const StringView current_line, const int line_nu } TACTILE_ASSERT(current_line.size() >= 2); - return String {current_line.substr(1, current_line.size() - 2)}; + return std::string {current_line.substr(1, current_line.size() - 2)}; } [[nodiscard]] -auto _parse_key_value_pair(const StringView current_line, +auto _parse_key_value_pair(const std::string_view current_line, const int line_number, IniSection& section) -> std::expected { const auto eq_pos = current_line.find_first_of(kAssignmentToken); - if (eq_pos == String::npos || eq_pos == 0) { + if (eq_pos == std::string::npos || eq_pos == 0) { TACTILE_LOG_ERROR("Detected missing assignment ('{}') operator (line {})", kAssignmentToken, line_number); @@ -88,8 +88,8 @@ auto parse_ini(const std::filesystem::path& path) -> std::expected -[[nodiscard]] auto _deserialize_vec(const StringView str) +[[nodiscard]] auto _deserialize_vec(const std::string_view str) -> std::expected { VecType vec {}; usize index = 0; - const auto ok = split_string(str, ';', [&](const StringView token) { + const auto ok = split_string(str, ';', [&](const std::string_view token) { if (index >= vec.size()) { return false; } @@ -44,62 +44,62 @@ template } // namespace vec_serialization -auto serialize(const Int2& vec) -> String +auto serialize(const Int2& vec) -> std::string { return std::format("{};{}", vec.x(), vec.y()); } -auto serialize(const Float2& vec) -> String +auto serialize(const Float2& vec) -> std::string { return std::format("{};{}", vec.x(), vec.y()); } -auto serialize(const Int3& vec) -> String +auto serialize(const Int3& vec) -> std::string { return std::format("{};{};{}", vec.x(), vec.y(), vec.z()); } -auto serialize(const Float3& vec) -> String +auto serialize(const Float3& vec) -> std::string { return std::format("{};{};{}", vec.x(), vec.y(), vec.z()); } -auto serialize(const Int4& vec) -> String +auto serialize(const Int4& vec) -> std::string { return std::format("{};{};{};{}", vec.x(), vec.y(), vec.z(), vec.w()); } -auto serialize(const Float4& vec) -> String +auto serialize(const Float4& vec) -> std::string { return std::format("{};{};{};{}", vec.x(), vec.y(), vec.z(), vec.w()); } -auto deserialize_int2(const StringView str) -> std::expected +auto deserialize_int2(const std::string_view str) -> std::expected { return _deserialize_vec(str); } -auto deserialize_int3(const StringView str) -> std::expected +auto deserialize_int3(const std::string_view str) -> std::expected { return _deserialize_vec(str); } -auto deserialize_int4(const StringView str) -> std::expected +auto deserialize_int4(const std::string_view str) -> std::expected { return _deserialize_vec(str); } -auto deserialize_float2(const StringView str) -> std::expected +auto deserialize_float2(const std::string_view str) -> std::expected { return _deserialize_vec(str); } -auto deserialize_float3(const StringView str) -> std::expected +auto deserialize_float3(const std::string_view str) -> std::expected { return _deserialize_vec(str); } -auto deserialize_float4(const StringView str) -> std::expected +auto deserialize_float4(const std::string_view str) -> std::expected { return _deserialize_vec(str); } diff --git a/source/core/src/tactile/core/log/logger.cpp b/source/core/src/tactile/core/log/logger.cpp index 404c31407a..2ecf11a23a 100644 --- a/source/core/src/tactile/core/log/logger.cpp +++ b/source/core/src/tactile/core/log/logger.cpp @@ -16,7 +16,7 @@ constinit Logger* gDefaultLogger = nullptr; // NOLINT } // namespace logger void Logger::_log(const LogLevel level, - const StringView fmt_string, + const std::string_view fmt_string, const std::format_args args) noexcept { try { @@ -81,12 +81,12 @@ void Logger::set_reference_instant(const std::optional insta mReferenceInstant = instant; } -void Logger::set_scope(const StringView scope) noexcept +void Logger::set_scope(const std::string_view scope) noexcept { mScope = scope; } -auto Logger::get_scope() const noexcept -> StringView +auto Logger::get_scope() const noexcept -> std::string_view { return mScope; } @@ -101,7 +101,7 @@ auto Logger::would_flush(const LogLevel level) const noexcept -> bool return level >= mFlushLevel; } -auto Logger::get_acronym(const LogLevel level) noexcept -> StringView +auto Logger::get_acronym(const LogLevel level) noexcept -> std::string_view { switch (level) { case LogLevel::kTrace: return "TRC"; diff --git a/source/core/src/tactile/core/log/set_log_scope.cpp b/source/core/src/tactile/core/log/set_log_scope.cpp index 6dd9da8ca7..dbfd3de7a2 100644 --- a/source/core/src/tactile/core/log/set_log_scope.cpp +++ b/source/core/src/tactile/core/log/set_log_scope.cpp @@ -6,7 +6,7 @@ namespace tactile { -SetLogScope::SetLogScope(const StringView scope) noexcept +SetLogScope::SetLogScope(const std::string_view scope) noexcept { if (auto* logger = get_default_logger()) { mPrevScope = logger->get_scope(); diff --git a/source/core/src/tactile/core/log/terminal_log_sink.cpp b/source/core/src/tactile/core/log/terminal_log_sink.cpp index 7229c8432d..c38526fa78 100644 --- a/source/core/src/tactile/core/log/terminal_log_sink.cpp +++ b/source/core/src/tactile/core/log/terminal_log_sink.cpp @@ -38,7 +38,7 @@ void TerminalLogSink::use_ansi_colors(const bool enabled) mUseAnsiColors = enabled; } -auto TerminalLogSink::get_fg_ansi_color(const LogLevel level) -> StringView +auto TerminalLogSink::get_fg_ansi_color(const LogLevel level) -> std::string_view { switch (level) { case LogLevel::kTrace: return kAnsiColorFgMagenta; diff --git a/source/core/src/tactile/core/meta/attribute_type.cpp b/source/core/src/tactile/core/meta/attribute_type.cpp index 8bdf50868c..d1ab211205 100644 --- a/source/core/src/tactile/core/meta/attribute_type.cpp +++ b/source/core/src/tactile/core/meta/attribute_type.cpp @@ -7,7 +7,8 @@ namespace tactile { -auto parse_attribute_type(StringView name) -> std::expected +auto parse_attribute_type(std::string_view name) + -> std::expected { if (name == "string") { return AttributeType::kStr; @@ -52,7 +53,7 @@ auto parse_attribute_type(StringView name) -> std::expected StringView +auto serialize(const AttributeType type) -> std::string_view { switch (type) { case AttributeType::kStr: return "string"; diff --git a/source/core/src/tactile/core/meta/color.cpp b/source/core/src/tactile/core/meta/color.cpp index 1bcb73d4b8..8368cd2bc9 100644 --- a/source/core/src/tactile/core/meta/color.cpp +++ b/source/core/src/tactile/core/meta/color.cpp @@ -31,12 +31,12 @@ auto make_color(const FColor& fcolor) -> UColor return make_color(fcolor.red, fcolor.green, fcolor.blue, fcolor.alpha); } -auto to_string_rgb(const UColor& color) -> String +auto to_string_rgb(const UColor& color) -> std::string { return std::format("#{:02X}{:02X}{:02X}", color.red, color.green, color.blue); } -auto to_string_rgba(const UColor& color) -> String +auto to_string_rgba(const UColor& color) -> std::string { return std::format("#{:02X}{:02X}{:02X}{:02X}", color.red, @@ -45,7 +45,7 @@ auto to_string_rgba(const UColor& color) -> String color.alpha); } -auto to_string_argb(const UColor& color) -> String +auto to_string_argb(const UColor& color) -> std::string { return std::format("#{:02X}{:02X}{:02X}{:02X}", color.alpha, diff --git a/source/core/src/tactile/core/platform/environment.cpp b/source/core/src/tactile/core/platform/environment.cpp index a2932612dc..93532f1072 100644 --- a/source/core/src/tactile/core/platform/environment.cpp +++ b/source/core/src/tactile/core/platform/environment.cpp @@ -13,7 +13,7 @@ namespace tactile { -auto get_env(const char* name) -> std::expected +auto get_env(const char* name) -> std::expected { if (name) { #if TACTILE_OS_WINDOWS @@ -22,11 +22,11 @@ auto get_env(const char* name) -> std::expected if (value) { const ScopeGuard value_deleter {[=] { std::free(value); }}; - return String {value}; + return std::string {value}; } #else if (const auto* value = std::getenv(name)) { - return String {value}; + return std::string {value}; } #endif // TACTILE_OS_WINDOWS } diff --git a/source/core/src/tactile/core/platform/filesystem.cpp b/source/core/src/tactile/core/platform/filesystem.cpp index 9606543029..2f00dd9313 100644 --- a/source/core/src/tactile/core/platform/filesystem.cpp +++ b/source/core/src/tactile/core/platform/filesystem.cpp @@ -53,7 +53,7 @@ auto get_persistent_storage_directory() return std::unexpected {make_error(GenericError::kInvalidState)}; } -auto get_user_home_directory() -> std::expected +auto get_user_home_directory() -> std::expected { // On Unix platforms, HOME is something like '/Users/username'. // On Windows, USERPROFILE is something like 'C:\Users\username'. @@ -66,24 +66,25 @@ auto get_imgui_ini_file_path() -> std::filesystem::path return "imgui.ini"; } -auto normalize_path(const std::filesystem::path& path) -> String +auto normalize_path(const std::filesystem::path& path) -> std::string { auto str = path.string(); std::ranges::replace(str, '\\', '/'); return str; } -auto has_prefix(const std::filesystem::path& path, const StringView prefix) -> bool +auto has_prefix(const std::filesystem::path& path, const std::string_view prefix) -> bool { #if TACTILE_OS_WINDOWS - return StringView {path.string().c_str()}.starts_with(prefix); + return std::string_view {path.string().c_str()}.starts_with(prefix); #else - return StringView {path.c_str()}.starts_with(prefix); + return std::string_view {path.c_str()}.starts_with(prefix); #endif } -auto strip_home_directory_prefix(const std::filesystem::path& path, const StringView home_dir) - -> std::expected +auto strip_home_directory_prefix(const std::filesystem::path& path, + const std::string_view home_dir) + -> std::expected { if (has_prefix(path, home_dir)) { const NativeStringView path_view {path.c_str()}; diff --git a/source/core/src/tactile/core/ui/dialog/rename_property_dialog.cpp b/source/core/src/tactile/core/ui/dialog/rename_property_dialog.cpp index ce360e9a4d..6c728a0d99 100644 --- a/source/core/src/tactile/core/ui/dialog/rename_property_dialog.cpp +++ b/source/core/src/tactile/core/ui/dialog/rename_property_dialog.cpp @@ -63,7 +63,7 @@ void RenamePropertyDialog::push(const Model& model, EventDispatcher& dispatcher) } } -void RenamePropertyDialog::open(const EntityID context_entity, String target_prop_name) +void RenamePropertyDialog::open(const EntityID context_entity, std::string target_prop_name) { mContextEntity = context_entity; mTargetPropName = std::move(target_prop_name); diff --git a/source/core/src/tactile/core/ui/dock/property_dock.cpp b/source/core/src/tactile/core/ui/dock/property_dock.cpp index aa4e110974..66fc3a38c0 100644 --- a/source/core/src/tactile/core/ui/dock/property_dock.cpp +++ b/source/core/src/tactile/core/ui/dock/property_dock.cpp @@ -23,7 +23,7 @@ inline namespace property_dock { void _push_property_table_context_menu_content(const Language& language, const EntityID context_entity, - const String* prop_name, + const std::string* prop_name, EventDispatcher& dispatcher) { if (const DisabledScope disable_if {prop_name != nullptr}; diff --git a/source/core/src/tactile/core/ui/i18n/language.cpp b/source/core/src/tactile/core/ui/i18n/language.cpp index 4b1bf963e8..5cdc6216b9 100644 --- a/source/core/src/tactile/core/ui/i18n/language.cpp +++ b/source/core/src/tactile/core/ui/i18n/language.cpp @@ -6,7 +6,7 @@ namespace tactile::ui { -Language::Language(const LanguageID id, std::vector strings) : +Language::Language(const LanguageID id, std::vector strings) : mID {id}, mStrings {std::move(strings)} {} diff --git a/source/core/src/tactile/core/ui/i18n/language_parser.cpp b/source/core/src/tactile/core/ui/i18n/language_parser.cpp index f33c39eb72..2d9083a7c9 100644 --- a/source/core/src/tactile/core/ui/i18n/language_parser.cpp +++ b/source/core/src/tactile/core/ui/i18n/language_parser.cpp @@ -18,7 +18,7 @@ namespace tactile::ui { inline namespace language_parser { [[nodiscard]] -auto _get_misc_names() -> std::unordered_map +auto _get_misc_names() -> std::unordered_map { return { {"ok", StringID::kOK}, @@ -26,7 +26,7 @@ auto _get_misc_names() -> std::unordered_map } [[nodiscard]] -auto _get_verb_names() -> std::unordered_map +auto _get_verb_names() -> std::unordered_map { return { {"cancel", StringID::kCancel}, @@ -42,7 +42,7 @@ auto _get_verb_names() -> std::unordered_map } [[nodiscard]] -auto _get_noun_names() -> std::unordered_map +auto _get_noun_names() -> std::unordered_map { return { {"int", StringID::kInt}, @@ -76,7 +76,7 @@ auto _get_noun_names() -> std::unordered_map } [[nodiscard]] -auto _get_adjective_names() -> std::unordered_map +auto _get_adjective_names() -> std::unordered_map { return { {"orthogonal", StringID::kOrthogonal}, @@ -85,7 +85,7 @@ auto _get_adjective_names() -> std::unordered_map } [[nodiscard]] -auto _get_action_names() -> std::unordered_map +auto _get_action_names() -> std::unordered_map { return { {"create_map", StringID::kCreateMap}, @@ -148,7 +148,7 @@ auto _get_action_names() -> std::unordered_map } [[nodiscard]] -auto _get_hint_names() -> std::unordered_map +auto _get_hint_names() -> std::unordered_map { return { {"context_has_no_properties", StringID::kContextHasNoProperties}, @@ -160,7 +160,7 @@ auto _get_hint_names() -> std::unordered_map } [[nodiscard]] -auto _get_menu_names() -> std::unordered_map +auto _get_menu_names() -> std::unordered_map { return { {"file", StringID::kFileMenu}, @@ -178,7 +178,7 @@ auto _get_menu_names() -> std::unordered_map } [[nodiscard]] -auto _get_widget_names() -> std::unordered_map +auto _get_widget_names() -> std::unordered_map { return { {"document_dock", StringID::kDocumentDock}, @@ -193,9 +193,9 @@ auto _get_widget_names() -> std::unordered_map } void _parse_section(const StringMap& ini, - const StringView section_name, - const std::unordered_map& name_mapping, - std::vector& strings) + const std::string_view section_name, + const std::unordered_map& name_mapping, + std::vector& strings) { if (const auto* section = find_in(ini, section_name)) { for (const auto& [key, value] : *section) { @@ -207,7 +207,7 @@ void _parse_section(const StringMap& ini, } [[nodiscard]] -auto _validate_strings(std::vector& strings, +auto _validate_strings(std::vector& strings, const Language* fallback) -> std::expected { usize index {0}; @@ -220,7 +220,7 @@ auto _validate_strings(std::vector& strings, string = fallback->get(string_id); } else { - TACTILE_LOG_ERROR("String with ID {} ('{}') is not translated", + TACTILE_LOG_ERROR("std::string with ID {} ('{}') is not translated", index, magic_enum::enum_name(string_id)); return std::unexpected {make_error(GenericError::kInvalidFile)}; @@ -256,7 +256,7 @@ auto LanguageParser::parse(const LanguageID id, return parse_ini(path) .transform([this](const IniData& ini) { - std::vector strings {}; + std::vector strings {}; strings.resize(std::to_underlying(StringID::kMAX)); _parse_section(ini, "misc", mMiscNames, strings); @@ -270,7 +270,7 @@ auto LanguageParser::parse(const LanguageID id, return strings; }) - .and_then([id, fallback](std::vector&& strings) { + .and_then([id, fallback](std::vector&& strings) { return _validate_strings(strings, fallback).transform([id, &strings] { return Language {id, std::move(strings)}; }); diff --git a/source/core/src/tactile/core/util/string_conv.cpp b/source/core/src/tactile/core/util/string_conv.cpp index 2beec4c3fc..17a104b672 100644 --- a/source/core/src/tactile/core/util/string_conv.cpp +++ b/source/core/src/tactile/core/util/string_conv.cpp @@ -4,6 +4,7 @@ #include // from_chars #include // invocable, integral, floating_point, same_as +#include // path #include // errc #if TACTILE_OS_WINDOWS @@ -19,12 +20,12 @@ inline namespace string_conv { #if TACTILE_OS_WINDOWS // Windows is the only platform that we support that uses wchar_t paths. -static_assert(std::same_as); +static_assert(std::same_as); #endif // TACTILE_OS_WINDOWS template Parser> -[[nodiscard]] auto _parse_impl(const StringView str, - const Parser& parser) -> std::expected +[[nodiscard]] auto _parse_impl(const std::string_view str, const Parser& parser) + -> std::expected { const auto* begin = str.data(); const auto* end = begin + str.size(); @@ -40,8 +41,8 @@ template Parser> } template -[[nodiscard]] auto _parse_number(const StringView str, - const int base) -> std::expected +[[nodiscard]] auto _parse_number(const std::string_view str, const int base) + -> std::expected { return _parse_impl(str, [base](const char* begin, const char* end, T& number) { return std::from_chars(begin, end, number, base); @@ -49,7 +50,8 @@ template } template -[[nodiscard]] auto _parse_number(const StringView str) -> std::expected +[[nodiscard]] auto _parse_number(const std::string_view str) + -> std::expected { return _parse_impl(str, [](const char* begin, const char* end, T& number) { return fast_float::from_chars(begin, end, number); @@ -58,7 +60,8 @@ template } // namespace string_conv -auto to_native_string(const StringView str) -> std::expected +auto to_native_string(const std::string_view str) + -> std::expected { #if TACTILE_OS_WINDOWS if (str.empty()) { @@ -95,7 +98,8 @@ auto to_native_string(const StringView str) -> std::expected std::expected +auto from_native_string(const NativeStringView str) + -> std::expected { #if TACTILE_OS_WINDOWS if (str.empty()) { @@ -119,7 +123,7 @@ auto from_native_string(const NativeStringView str) -> std::expected(char_count)); if (WideCharToMultiByte(CP_UTF8, @@ -135,21 +139,23 @@ auto from_native_string(const NativeStringView str) -> std::expected std::expected +auto parse_int(const std::string_view str, const int base) + -> std::expected { return _parse_number(str, base); } -auto parse_uint(const StringView str, const int base) -> std::expected +auto parse_uint(const std::string_view str, const int base) + -> std::expected { return _parse_number(str, base); } -auto parse_float(const StringView str) -> std::expected +auto parse_float(const std::string_view str) -> std::expected { return _parse_number(str); } diff --git a/source/core/src/tactile/core/util/string_ops.cpp b/source/core/src/tactile/core/util/string_ops.cpp index 23d7c370fc..7350c22f66 100644 --- a/source/core/src/tactile/core/util/string_ops.cpp +++ b/source/core/src/tactile/core/util/string_ops.cpp @@ -8,9 +8,9 @@ namespace tactile { -auto trim_string(const StringView str) -> String +auto trim_string(const std::string_view str) -> std::string { - String copy {str}; + std::string copy {str}; const auto find_first_non_space = [](const auto begin, const auto end) { return std::find_if(begin, end, [](const char ch) { diff --git a/source/core/src/tactile/core/util/uuid.cpp b/source/core/src/tactile/core/util/uuid.cpp index abcc3ab0a3..d665c32ed5 100644 --- a/source/core/src/tactile/core/util/uuid.cpp +++ b/source/core/src/tactile/core/util/uuid.cpp @@ -39,7 +39,7 @@ auto UUID::is_null() const -> bool return std::ranges::all_of(mData, [](const uint8 byte) { return byte == 0; }); } -auto to_string(const UUID& uuid) -> String +auto to_string(const UUID& uuid) -> std::string { return std::format( "{:02X}{:02X}{:02X}{:02X}-{:02X}{:02X}-{:02X}{:02X}-{:02X}{:02X}-{:02X}{:02X}{:02X}{:02X}{:02X}{:02X}", diff --git a/source/core/test/src/cmd/meta/create_property_command_test.cpp b/source/core/test/src/cmd/meta/create_property_command_test.cpp index de264bb1b0..378813f6d8 100644 --- a/source/core/test/src/cmd/meta/create_property_command_test.cpp +++ b/source/core/test/src/cmd/meta/create_property_command_test.cpp @@ -27,7 +27,7 @@ TEST(CreatePropertyCommand, RedoUndo) ASSERT_EQ(meta.properties.size(), 0); ASSERT_EQ(meta.components.size(), 0); - const String property_name {"foo"}; + const std::string property_name {"foo"}; const Attribute property_value {42}; CreatePropertyCommand command {&document, map_entity, property_name, property_value}; diff --git a/source/core/test/src/cmd/meta/remove_property_command_test.cpp b/source/core/test/src/cmd/meta/remove_property_command_test.cpp index 78d102d7fd..7949c219c2 100644 --- a/source/core/test/src/cmd/meta/remove_property_command_test.cpp +++ b/source/core/test/src/cmd/meta/remove_property_command_test.cpp @@ -16,7 +16,7 @@ namespace tactile::test { // tactile::RemovePropertyCommand::undo TEST(RemovePropertyCommand, RedoUndo) { - const String name {"xyz"}; + const std::string name {"xyz"}; const Attribute value {123}; auto document = MapDocument::make(kOrthogonalMapSpec).value(); diff --git a/source/core/test/src/cmd/meta/rename_property_command_test.cpp b/source/core/test/src/cmd/meta/rename_property_command_test.cpp index bb187168b6..cb28253aed 100644 --- a/source/core/test/src/cmd/meta/rename_property_command_test.cpp +++ b/source/core/test/src/cmd/meta/rename_property_command_test.cpp @@ -16,8 +16,8 @@ namespace tactile::test { // tactile::RenamePropertyCommand::undo TEST(RenamePropertyCommand, RedoUndo) { - const String old_name {"foo"}; - const String new_name {"bar"}; + const std::string old_name {"foo"}; + const std::string new_name {"bar"}; auto document = MapDocument::make(kOrthogonalMapSpec).value(); @@ -45,9 +45,9 @@ TEST(RenamePropertyCommand, RedoUndo) // tactile::RenamePropertyCommand::merge_with TEST(RenamePropertyCommand, MergeWith) { - const String name1 {"A"}; - const String name2 {"B"}; - const String name3 {"C"}; + const std::string name1 {"A"}; + const std::string name2 {"B"}; + const std::string name3 {"C"}; auto document = MapDocument::make(kOrthogonalMapSpec).value(); diff --git a/source/core/test/src/cmd/meta/update_property_command_test.cpp b/source/core/test/src/cmd/meta/update_property_command_test.cpp index 5ba0ce6b1b..db62183b16 100644 --- a/source/core/test/src/cmd/meta/update_property_command_test.cpp +++ b/source/core/test/src/cmd/meta/update_property_command_test.cpp @@ -16,7 +16,7 @@ namespace tactile::test { // tactile::UpdatePropertyCommand::undo TEST(UpdatePropertyCommand, RedoUndo) { - const String name {"abc"}; + const std::string name {"abc"}; const Attribute old_value {42}; const Attribute new_value {43}; @@ -49,7 +49,7 @@ TEST(UpdatePropertyCommand, RedoUndo) // tactile::UpdatePropertyCommand::merge_with TEST(UpdatePropertyCommand, MergeWith) { - const String name {"abc"}; + const std::string name {"abc"}; const Attribute value0 {"0"}; const Attribute value1 {"1"}; diff --git a/source/core/test/src/platform/filesystem_test.cpp b/source/core/test/src/platform/filesystem_test.cpp index 286fe5ac1a..13a70f4852 100644 --- a/source/core/test/src/platform/filesystem_test.cpp +++ b/source/core/test/src/platform/filesystem_test.cpp @@ -35,8 +35,8 @@ TEST(Filesystem, StripHomeDirectoryPrefix) { const auto home_dir = get_user_home_directory().value(); - const String abc {"/a/b/c"}; - const String foobar {"/foobar"}; + const std::string abc {"/a/b/c"}; + const std::string foobar {"/foobar"}; EXPECT_EQ(strip_home_directory_prefix(home_dir + abc, home_dir), "~" + abc); EXPECT_EQ(strip_home_directory_prefix(home_dir + foobar, home_dir), "~" + foobar); diff --git a/source/core/test/src/util/lookup_test.cpp b/source/core/test/src/util/lookup_test.cpp index da4c882706..78aaed3ce7 100644 --- a/source/core/test/src/util/lookup_test.cpp +++ b/source/core/test/src/util/lookup_test.cpp @@ -4,11 +4,11 @@ #include // less #include // map +#include // string #include // unordered_map #include -#include "tactile/base/container/string.hpp" #include "tactile/base/container/string_map.hpp" #include "tactile/core/debug/exception.hpp" @@ -20,7 +20,7 @@ namespace tactile { TEST(Lookup, EmptyMap) { const StringMap hash_map {}; - const std::map> tree_map {}; + const std::map> tree_map {}; EXPECT_FALSE(exists_in(hash_map, "foo")); EXPECT_FALSE(exists_in(tree_map, "foo")); @@ -35,7 +35,7 @@ TEST(Lookup, EmptyMap) /// \trace tactile::find_in TEST(Lookup, FindIn) { - std::map map {}; + std::map map {}; map[0] = "0"; map[1] = "1"; @@ -52,7 +52,7 @@ TEST(Lookup, FindIn) /// \trace tactile::lookup_in TEST(Lookup, LookupIn) { - StringMap map {}; + StringMap map {}; map["A"] = "1"; map["B"] = "2"; diff --git a/source/core/test/src/util/string_conv_test.cpp b/source/core/test/src/util/string_conv_test.cpp index 34dab9b7ab..8905626905 100644 --- a/source/core/test/src/util/string_conv_test.cpp +++ b/source/core/test/src/util/string_conv_test.cpp @@ -20,7 +20,7 @@ TEST(StringConv, ToNativeString) EXPECT_EQ(to_native_string("foo/bar.txt"), TACTILE_NATIVE_STR("foo/bar.txt")); EXPECT_EQ(to_native_string("\0"), TACTILE_NATIVE_STR("\0")); - const StringView foo {"foobar", 3}; + const std::string_view foo {"foobar", 3}; EXPECT_EQ(to_native_string(foo), TACTILE_NATIVE_STR("foo")); } @@ -60,8 +60,8 @@ TEST(StringConv, ParseFloat) EXPECT_EQ(parse_float("1.0"), 1.0); EXPECT_EQ(parse_float("3.2"), 3.2); EXPECT_EQ(parse_float("-1.0"), -1.0); - EXPECT_EQ(parse_float(StringView {"1234"}.substr(0, 2)), 12.0); - EXPECT_EQ(parse_float(StringView {"1234"}.substr(2, 2)), 34.0); + EXPECT_EQ(parse_float(std::string_view {"1234"}.substr(0, 2)), 12.0); + EXPECT_EQ(parse_float(std::string_view {"1234"}.substr(2, 2)), 34.0); } } // namespace tactile diff --git a/source/core/test/src/util/string_ops_test.cpp b/source/core/test/src/util/string_ops_test.cpp index 531d5b7046..b189aa5cce 100644 --- a/source/core/test/src/util/string_ops_test.cpp +++ b/source/core/test/src/util/string_ops_test.cpp @@ -11,8 +11,8 @@ namespace tactile { /// \trace tactile::split_string TEST(StringOps, SplitStringEmpty) { - std::vector tokens {}; - split_string("", '!', [&tokens](const StringView token) { + std::vector tokens {}; + split_string("", '!', [&tokens](const std::string_view token) { tokens.emplace_back(token); return true; }); @@ -23,8 +23,8 @@ TEST(StringOps, SplitStringEmpty) /// \trace tactile::split_string TEST(StringOps, SplitStringLetters) { - std::vector tokens {}; - split_string("a:b:c:d", ':', [&tokens](const StringView token) { + std::vector tokens {}; + split_string("a:b:c:d", ':', [&tokens](const std::string_view token) { tokens.emplace_back(token); return true; }); @@ -39,8 +39,8 @@ TEST(StringOps, SplitStringLetters) /// \trace tactile::split_string TEST(StringOps, SplitStringNumbers) { - std::vector tokens {}; - split_string("1 200 30 4000", ' ', [&tokens](const StringView token) { + std::vector tokens {}; + split_string("1 200 30 4000", ' ', [&tokens](const std::string_view token) { tokens.emplace_back(token); return true; }); @@ -55,8 +55,8 @@ TEST(StringOps, SplitStringNumbers) /// \trace tactile::split_string TEST(StringOps, SplitStringWithLeadingSeparator) { - std::vector tokens {}; - split_string(".woah", '.', [&tokens](const StringView token) { + std::vector tokens {}; + split_string(".woah", '.', [&tokens](const std::string_view token) { tokens.emplace_back(token); return true; }); @@ -69,8 +69,8 @@ TEST(StringOps, SplitStringWithLeadingSeparator) /// \trace tactile::split_string TEST(StringOps, SplitStringWithTrailingSeparator) { - std::vector tokens {}; - split_string("foobar!", '!', [&tokens](const StringView token) { + std::vector tokens {}; + split_string("foobar!", '!', [&tokens](const std::string_view token) { tokens.emplace_back(token); return true; }); @@ -82,8 +82,8 @@ TEST(StringOps, SplitStringWithTrailingSeparator) /// \trace tactile::split_string TEST(StringOps, SplitStringWithEmptyTokens) { - std::vector tokens {}; - split_string("aaa::a:bb::c", ':', [&tokens](const StringView token) { + std::vector tokens {}; + split_string("aaa::a:bb::c", ':', [&tokens](const std::string_view token) { tokens.emplace_back(token); return true; }); diff --git a/source/runtime/lib/inc/tactile/runtime/logging.hpp b/source/runtime/lib/inc/tactile/runtime/logging.hpp index 7f29f0bd07..4236627c2f 100644 --- a/source/runtime/lib/inc/tactile/runtime/logging.hpp +++ b/source/runtime/lib/inc/tactile/runtime/logging.hpp @@ -2,9 +2,9 @@ #pragma once -#include // make_format_args, format_args +#include // make_format_args, format_args +#include // string_view -#include "tactile/base/container/string.hpp" #include "tactile/base/log/log_level.hpp" #include "tactile/base/prelude.hpp" #include "tactile/runtime/api.hpp" @@ -12,7 +12,7 @@ namespace tactile { namespace internal { -TACTILE_RUNTIME_API void log(LogLevel level, StringView fmt, std::format_args args); +TACTILE_RUNTIME_API void log(LogLevel level, std::string_view fmt, std::format_args args); } // namespace internal @@ -26,7 +26,7 @@ TACTILE_RUNTIME_API void log(LogLevel level, StringView fmt, std::format_args ar * \param args The format arguments. */ template -void log(const LogLevel level, const StringView fmt, const Args&... args) +void log(const LogLevel level, const std::string_view fmt, const Args&... args) { internal::log(level, fmt, std::make_format_args(args...)); } diff --git a/source/runtime/lib/inc/tactile/runtime/plugin_instance.hpp b/source/runtime/lib/inc/tactile/runtime/plugin_instance.hpp index a4f54f13e3..f82a384b34 100644 --- a/source/runtime/lib/inc/tactile/runtime/plugin_instance.hpp +++ b/source/runtime/lib/inc/tactile/runtime/plugin_instance.hpp @@ -2,10 +2,10 @@ #pragma once -#include // unique_ptr -#include // optional +#include // unique_ptr +#include // optional +#include // string_view -#include "tactile/base/container/string.hpp" #include "tactile/base/prelude.hpp" #include "tactile/runtime/api.hpp" #include "tactile/runtime/plugin.hpp" @@ -54,7 +54,8 @@ class TACTILE_RUNTIME_API PluginInstance final * A plugin instance if successful; an empty optional otherwise. */ [[nodiscard]] - static auto load(IRuntime* runtime, StringView plugin_name) -> std::optional; + static auto load(IRuntime* runtime, std::string_view plugin_name) + -> std::optional; private: IRuntime* mRuntime; diff --git a/source/runtime/lib/src/tactile/runtime/launcher.cpp b/source/runtime/lib/src/tactile/runtime/launcher.cpp index faa365ad7f..e51e9c1036 100644 --- a/source/runtime/lib/src/tactile/runtime/launcher.cpp +++ b/source/runtime/lib/src/tactile/runtime/launcher.cpp @@ -6,7 +6,6 @@ #include // move #include // vector -#include "tactile/base/container/string.hpp" #include "tactile/core/debug/exception.hpp" #include "tactile/core/engine/engine.hpp" #include "tactile/core/log/logger.hpp" @@ -19,9 +18,9 @@ namespace tactile { namespace launcher_impl { [[nodiscard]] -auto get_plugin_names() -> std::vector +auto get_plugin_names() -> std::vector { - std::vector plugin_names {}; + std::vector plugin_names {}; #ifdef TACTILE_ENABLE_ZLIB_COMPRESSION plugin_names.emplace_back("tactile-zlib-compression" TACTILE_DLL_EXT); diff --git a/source/runtime/lib/src/tactile/runtime/logging.cpp b/source/runtime/lib/src/tactile/runtime/logging.cpp index 51171bf092..687bd345ff 100644 --- a/source/runtime/lib/src/tactile/runtime/logging.cpp +++ b/source/runtime/lib/src/tactile/runtime/logging.cpp @@ -7,7 +7,7 @@ namespace tactile::internal { -void log(const LogLevel level, const StringView fmt, const std::format_args args) +void log(const LogLevel level, const std::string_view fmt, const std::format_args args) { Buffer buffer; // NOLINT uninitialized vformat_to_buffer(buffer, fmt, args); diff --git a/source/runtime/lib/src/tactile/runtime/plugin_instance.cpp b/source/runtime/lib/src/tactile/runtime/plugin_instance.cpp index 774f42615f..da328710ca 100644 --- a/source/runtime/lib/src/tactile/runtime/plugin_instance.cpp +++ b/source/runtime/lib/src/tactile/runtime/plugin_instance.cpp @@ -37,7 +37,7 @@ PluginInstance::PluginInstance(PluginInstance&& other) noexcept : mPrimed {std::exchange(other.mPrimed, false)} {} -auto PluginInstance::load(IRuntime* runtime, const StringView plugin_name) +auto PluginInstance::load(IRuntime* runtime, const std::string_view plugin_name) -> std::optional { auto dll = load_library(plugin_name); diff --git a/source/test_util/inc/tactile/test_util/document_view_mocks.hpp b/source/test_util/inc/tactile/test_util/document_view_mocks.hpp index 3f1febb3b9..d35737550b 100644 --- a/source/test_util/inc/tactile/test_util/document_view_mocks.hpp +++ b/source/test_util/inc/tactile/test_util/document_view_mocks.hpp @@ -28,9 +28,9 @@ class MetaViewMock : public IMetaView explicit MetaViewMock(ir::Metadata meta); - MOCK_METHOD(StringView, get_name, (), (const, override)); + MOCK_METHOD(std::string_view, get_name, (), (const, override)); - MOCK_METHOD((std::pair), + MOCK_METHOD((std::pair), get_property, (usize), (const, override)); @@ -64,7 +64,7 @@ class ObjectViewMock : public IObjectView MOCK_METHOD(Float2, get_size, (), (const, override)); - MOCK_METHOD(StringView, get_tag, (), (const, override)); + MOCK_METHOD(std::string_view, get_tag, (), (const, override)); MOCK_METHOD(bool, is_visible, (), (const, override)); @@ -150,7 +150,7 @@ class TilesetViewMock : public ITilesetView MOCK_METHOD(const IMetaView&, get_meta, (), (const, override)); - MOCK_METHOD(String, get_filename, (), (const, override)); + MOCK_METHOD(std::string, get_filename, (), (const, override)); [[nodiscard]] auto get_meta_view_mock() -> MetaViewMock& diff --git a/source/test_util/inc/tactile/test_util/ir.hpp b/source/test_util/inc/tactile/test_util/ir.hpp index 9611c0fe84..321fb14c6d 100644 --- a/source/test_util/inc/tactile/test_util/ir.hpp +++ b/source/test_util/inc/tactile/test_util/ir.hpp @@ -18,7 +18,7 @@ namespace tactile::test { auto make_ir_tile_matrix(const MatrixExtent& extent) -> std::vector>; [[nodiscard]] -auto make_ir_metadata(String name) -> ir::Metadata; +auto make_ir_metadata(std::string name) -> ir::Metadata; [[nodiscard]] auto make_ir_object(ObjectID id, diff --git a/source/test_util/inc/tactile/test_util/ir_presets.hpp b/source/test_util/inc/tactile/test_util/ir_presets.hpp index 94e7ca393d..ad673f22ff 100644 --- a/source/test_util/inc/tactile/test_util/ir_presets.hpp +++ b/source/test_util/inc/tactile/test_util/ir_presets.hpp @@ -2,7 +2,8 @@ #pragma once -#include "tactile/base/container/string.hpp" +#include // string + #include "tactile/base/id.hpp" #include "tactile/base/io/save/ir.hpp" #include "tactile/base/layer/object_type.hpp" @@ -12,7 +13,7 @@ namespace tactile::test { [[nodiscard]] -auto make_complex_ir_metadata(String name) -> ir::Metadata; +auto make_complex_ir_metadata(std::string name) -> ir::Metadata; [[nodiscard]] auto make_complex_ir_object(ObjectID id, ObjectType type) -> ir::Object; diff --git a/source/test_util/src/document_view_mocks.cpp b/source/test_util/src/document_view_mocks.cpp index 49c048bf7b..7c258114e2 100644 --- a/source/test_util/src/document_view_mocks.cpp +++ b/source/test_util/src/document_view_mocks.cpp @@ -14,13 +14,14 @@ MetaViewMock::MetaViewMock(ir::Metadata meta) : { using testing::Return; - ON_CALL(*this, get_name).WillByDefault([this]() -> StringView { return mMeta.name; }); + ON_CALL(*this, get_name).WillByDefault([this]() -> std::string_view { return mMeta.name; }); ON_CALL(*this, get_property) - .WillByDefault([this](const usize index) -> std::pair { - const auto& property = mMeta.properties.at(index); - return {property.name, property.value}; - }); + .WillByDefault( + [this](const usize index) -> std::pair { + const auto& property = mMeta.properties.at(index); + return {property.name, property.value}; + }); ON_CALL(*this, property_count).WillByDefault(testing::Return(mMeta.properties.size())); } diff --git a/source/test_util/src/ir.cpp b/source/test_util/src/ir.cpp index 57ec3e3888..ed82fffa0b 100644 --- a/source/test_util/src/ir.cpp +++ b/source/test_util/src/ir.cpp @@ -25,7 +25,7 @@ auto make_ir_tile_matrix(const MatrixExtent& extent) -> std::vector ir::Metadata +auto make_ir_metadata(std::string name) -> ir::Metadata { return { .name = std::move(name), diff --git a/source/test_util/src/ir_presets.cpp b/source/test_util/src/ir_presets.cpp index 6e49d691c7..e5e9f198d2 100644 --- a/source/test_util/src/ir_presets.cpp +++ b/source/test_util/src/ir_presets.cpp @@ -8,7 +8,7 @@ namespace tactile::test { -auto make_complex_ir_metadata(String name) -> ir::Metadata +auto make_complex_ir_metadata(std::string name) -> ir::Metadata { auto meta = make_ir_metadata(std::move(name)); diff --git a/source/tiled_tmj_format/lib/src/tmj_format_attribute_parser.cpp b/source/tiled_tmj_format/lib/src/tmj_format_attribute_parser.cpp index 42ffe7c6df..abfcda53f6 100644 --- a/source/tiled_tmj_format/lib/src/tmj_format_attribute_parser.cpp +++ b/source/tiled_tmj_format/lib/src/tmj_format_attribute_parser.cpp @@ -12,7 +12,8 @@ namespace tactile { namespace tmj_format_attribute_parser { [[nodiscard]] -auto parse_type(const StringView type) -> std::expected +auto parse_type(const std::string_view type) + -> std::expected { if (type == "string") { return AttributeType::kStr; @@ -152,7 +153,7 @@ auto parse_tiled_tmj_property(const nlohmann::json& property_json) name_iter->get_to(named_attribute.name); const auto property_type = - tmj_format_attribute_parser::parse_type(type_iter->get_ref()); + tmj_format_attribute_parser::parse_type(type_iter->get_ref()); if (!property_type.has_value()) { return std::unexpected {property_type.error()}; } diff --git a/source/tiled_tmj_format/lib/src/tmj_format_layer_parser.cpp b/source/tiled_tmj_format/lib/src/tmj_format_layer_parser.cpp index 34cd6d9277..18d67fbda8 100644 --- a/source/tiled_tmj_format/lib/src/tmj_format_layer_parser.cpp +++ b/source/tiled_tmj_format/lib/src/tmj_format_layer_parser.cpp @@ -28,7 +28,7 @@ auto parse_type(const nlohmann::json& layer_json) return std::unexpected {SaveFormatParseError::kNoLayerType}; } - const auto* type_name = type_iter->get_ptr(); + const auto* type_name = type_iter->get_ptr(); if (type_name == nullptr) { return std::unexpected {SaveFormatParseError::kBadLayerType}; } @@ -54,7 +54,7 @@ auto parse_base64_tile_data(const IRuntime& runtime, const std::optional compression, ir::Layer& layer) -> SaveFormatParseResult { - const auto& encoded_tile_data = data_json.get_ref(); + const auto& encoded_tile_data = data_json.get_ref(); auto decoded_bytes = base64::decode(encoded_tile_data); if (compression.has_value()) { @@ -133,7 +133,7 @@ auto parse_tile_layer(const IRuntime& runtime, return std::unexpected {SaveFormatParseError::kNoTileLayerHeight}; } - String encoding {"csv"}; + std::string encoding {"csv"}; if (const auto encoding_iter = layer_json.find("encoding"); encoding_iter != layer_json.end()) { encoding_iter->get_to(encoding); @@ -142,7 +142,7 @@ auto parse_tile_layer(const IRuntime& runtime, std::optional compression {}; if (const auto compression_iter = layer_json.find("compression"); compression_iter != layer_json.end()) { - const auto& compression_name = compression_iter->get_ref(); + const auto& compression_name = compression_iter->get_ref(); if (compression_name == "zlib") { compression = CompressionFormat::kZlib; } diff --git a/source/tiled_tmj_format/lib/src/tmj_format_map_parser.cpp b/source/tiled_tmj_format/lib/src/tmj_format_map_parser.cpp index cdd8d8416a..7b2e00ec88 100644 --- a/source/tiled_tmj_format/lib/src/tmj_format_map_parser.cpp +++ b/source/tiled_tmj_format/lib/src/tmj_format_map_parser.cpp @@ -16,7 +16,7 @@ void deduce_tile_format_from_layer(const nlohmann::json& layer_json, { if (const auto encoding_iter = layer_json.find("encoding"); encoding_iter != layer_json.end()) { - const auto& encoding = encoding_iter->get_ref(); + const auto& encoding = encoding_iter->get_ref(); if (encoding == "base64") { tile_format.encoding = TileEncoding::kBase64; @@ -28,7 +28,7 @@ void deduce_tile_format_from_layer(const nlohmann::json& layer_json, if (const auto compression_iter = layer_json.find("compression"); compression_iter != layer_json.end()) { - const auto& compression_name = compression_iter->get_ref(); + const auto& compression_name = compression_iter->get_ref(); if (compression_name == "zlib") { tile_format.compression = CompressionFormat::kZlib; @@ -53,7 +53,7 @@ auto parse_tiled_tmj_map(const IRuntime& runtime, if (const auto orientation_iter = map_json.find("orientation"); orientation_iter != map_json.end()) { - const auto& orientation = orientation_iter->get_ref(); + const auto& orientation = orientation_iter->get_ref(); if (orientation != "orthogonal") { return std::unexpected {SaveFormatParseError::kBadMapOrientation}; } diff --git a/source/tiled_tmj_format/lib/src/tmj_format_tileset_parser.cpp b/source/tiled_tmj_format/lib/src/tmj_format_tileset_parser.cpp index 138cf513ce..356a85d5a1 100644 --- a/source/tiled_tmj_format/lib/src/tmj_format_tileset_parser.cpp +++ b/source/tiled_tmj_format/lib/src/tmj_format_tileset_parser.cpp @@ -161,7 +161,7 @@ auto parse_tileset(const nlohmann::json& tileset_json) -> SaveFormatParseResult< return std::unexpected {SaveFormatParseError::kNoTilesetImageHeight}; } - String relative_image_path {}; + std::string relative_image_path {}; if (const auto image_path_iter = tileset_json.find("image"); image_path_iter != tileset_json.end()) { image_path_iter->get_to(relative_image_path); @@ -206,7 +206,7 @@ auto parse_tiled_tmj_tileset(const nlohmann::json& tileset_json, if (const auto source_iter = tileset_json.find("source"); source_iter != tileset_json.end()) { - const auto& source = source_iter->get_ref(); + const auto& source = source_iter->get_ref(); const auto tileset_path = options.base_dir / source; log(LogLevel::kDebug, "Loading external tileset: {}", tileset_path.string()); diff --git a/source/tiled_tmj_format/test/src/tmj_format_meta_emitter_test.cpp b/source/tiled_tmj_format/test/src/tmj_format_meta_emitter_test.cpp index 7525581b54..a78f09d831 100644 --- a/source/tiled_tmj_format/test/src/tmj_format_meta_emitter_test.cpp +++ b/source/tiled_tmj_format/test/src/tmj_format_meta_emitter_test.cpp @@ -31,9 +31,10 @@ TEST(TmjFormatMetaEmitter, EmitStringProperty) { MetaViewMock meta {}; - const String property_name {"s"}; + const std::string property_name {"s"}; const Attribute property_value {"foo"}; - const std::pair property {property_name, property_value}; + const std::pair property {property_name, + property_value}; EXPECT_CALL(meta, get_name); EXPECT_CALL(meta, get_property).WillOnce(testing::Return(property)); @@ -56,9 +57,10 @@ TEST(TmjFormatMetaEmitter, EmitIntProperty) { MetaViewMock meta {}; - const String property_name {"i"}; + const std::string property_name {"i"}; const Attribute property_value {42}; - const std::pair property {property_name, property_value}; + const std::pair property {property_name, + property_value}; EXPECT_CALL(meta, get_name); EXPECT_CALL(meta, get_property).WillOnce(testing::Return(property)); @@ -81,9 +83,10 @@ TEST(TmjFormatMetaEmitter, EmitInt2Property) { MetaViewMock meta {}; - const String property_name {"i2"}; + const std::string property_name {"i2"}; const Attribute property_value {Int2 {1, 2}}; - const std::pair property {property_name, property_value}; + const std::pair property {property_name, + property_value}; EXPECT_CALL(meta, get_name); EXPECT_CALL(meta, get_property).WillOnce(testing::Return(property)); @@ -106,9 +109,10 @@ TEST(TmjFormatMetaEmitter, EmitInt3Property) { MetaViewMock meta {}; - const String property_name {"i3"}; + const std::string property_name {"i3"}; const Attribute property_value {Int3 {1, 2, 3}}; - const std::pair property {property_name, property_value}; + const std::pair property {property_name, + property_value}; EXPECT_CALL(meta, get_name); EXPECT_CALL(meta, get_property).WillOnce(testing::Return(property)); @@ -131,9 +135,10 @@ TEST(TmjFormatMetaEmitter, EmitInt4Property) { MetaViewMock meta {}; - const String property_name {"i4"}; + const std::string property_name {"i4"}; const Attribute property_value {Int4 {1, 2, 3, 4}}; - const std::pair property {property_name, property_value}; + const std::pair property {property_name, + property_value}; EXPECT_CALL(meta, get_name); EXPECT_CALL(meta, get_property).WillOnce(testing::Return(property)); @@ -156,9 +161,10 @@ TEST(TmjFormatMetaEmitter, EmitFloatProperty) { MetaViewMock meta {}; - const String property_name {"f"}; + const std::string property_name {"f"}; const Attribute property_value {1.5f}; - const std::pair property {property_name, property_value}; + const std::pair property {property_name, + property_value}; EXPECT_CALL(meta, get_name); EXPECT_CALL(meta, get_property).WillOnce(testing::Return(property)); @@ -181,9 +187,10 @@ TEST(TmjFormatMetaEmitter, EmitFloat2Property) { MetaViewMock meta {}; - const String property_name {"f2"}; + const std::string property_name {"f2"}; const Attribute property_value {Float2 {1, 2}}; - const std::pair property {property_name, property_value}; + const std::pair property {property_name, + property_value}; EXPECT_CALL(meta, get_name); EXPECT_CALL(meta, get_property).WillOnce(testing::Return(property)); @@ -206,9 +213,10 @@ TEST(TmjFormatMetaEmitter, EmitFloat3Property) { MetaViewMock meta {}; - const String property_name {"f3"}; + const std::string property_name {"f3"}; const Attribute property_value {Float3 {1, 2, 3}}; - const std::pair property {property_name, property_value}; + const std::pair property {property_name, + property_value}; EXPECT_CALL(meta, get_name); EXPECT_CALL(meta, get_property).WillOnce(testing::Return(property)); @@ -231,9 +239,10 @@ TEST(TmjFormatMetaEmitter, EmitFloat4Property) { MetaViewMock meta {}; - const String property_name {"f4"}; + const std::string property_name {"f4"}; const Attribute property_value {Float4 {1, 2, 3, 4}}; - const std::pair property {property_name, property_value}; + const std::pair property {property_name, + property_value}; EXPECT_CALL(meta, get_name); EXPECT_CALL(meta, get_property).WillOnce(testing::Return(property)); @@ -256,9 +265,10 @@ TEST(TmjFormatMetaEmitter, EmitBoolProperty) { MetaViewMock meta {}; - const String property_name {"b"}; + const std::string property_name {"b"}; const Attribute property_value {true}; - const std::pair property {property_name, property_value}; + const std::pair property {property_name, + property_value}; EXPECT_CALL(meta, get_name); EXPECT_CALL(meta, get_property).WillOnce(testing::Return(property)); @@ -281,9 +291,10 @@ TEST(TmjFormatMetaEmitter, EmitColorProperty) { MetaViewMock meta {}; - const String property_name {"c"}; + const std::string property_name {"c"}; const Attribute property_value {UColor {0x1A, 0x3B, 0x5C, 0x7D}}; - const std::pair property {property_name, property_value}; + const std::pair property {property_name, + property_value}; EXPECT_CALL(meta, get_name); EXPECT_CALL(meta, get_property).WillOnce(testing::Return(property)); @@ -306,9 +317,10 @@ TEST(TmjFormatMetaEmitter, EmitPathProperty) { MetaViewMock meta {}; - const String property_name {"p"}; + const std::string property_name {"p"}; const Attribute property_value {std::filesystem::path {"a/b/c"}}; - const std::pair property {property_name, property_value}; + const std::pair property {property_name, + property_value}; EXPECT_CALL(meta, get_name); EXPECT_CALL(meta, get_property).WillOnce(testing::Return(property)); @@ -331,9 +343,10 @@ TEST(TmjFormatMetaEmitter, EmitObjectProperty) { MetaViewMock meta {}; - const String property_name {"o"}; + const std::string property_name {"o"}; const Attribute property_value {ObjectRef {99}}; - const std::pair property {property_name, property_value}; + const std::pair property {property_name, + property_value}; EXPECT_CALL(meta, get_name); EXPECT_CALL(meta, get_property).WillOnce(testing::Return(property)); diff --git a/source/tiled_tmj_format/test/src/tmj_format_object_emitter_test.cpp b/source/tiled_tmj_format/test/src/tmj_format_object_emitter_test.cpp index 8d7890d2e9..f220e3d3df 100644 --- a/source/tiled_tmj_format/test/src/tmj_format_object_emitter_test.cpp +++ b/source/tiled_tmj_format/test/src/tmj_format_object_emitter_test.cpp @@ -66,8 +66,8 @@ TEST(TmjFormatObjectEmitter, EmitEllipseObject) .visible = true, }; - const String prop1_name {"P1"}; - const String prop2_name {"P2"}; + const std::string prop1_name {"P1"}; + const std::string prop2_name {"P2"}; const Attribute prop1_value {42}; const Attribute prop2_value {"demo"}; diff --git a/source/tiled_tmj_format/test/src/tmj_format_roundtrip_test.cpp b/source/tiled_tmj_format/test/src/tmj_format_roundtrip_test.cpp index 9b20ed5225..abca8d35be 100644 --- a/source/tiled_tmj_format/test/src/tmj_format_roundtrip_test.cpp +++ b/source/tiled_tmj_format/test/src/tmj_format_roundtrip_test.cpp @@ -1,13 +1,13 @@ // Copyright (C) 2024 Albin Johansson (GNU General Public License v3.0) -#include // current_path -#include // optional -#include // ostream +#include // current_path +#include // optional +#include // ostream +#include // string_view #include #include -#include "tactile/base/container/string.hpp" #include "tactile/runtime/runtime.hpp" #include "tactile/test_util/document_view_mocks.hpp" #include "tactile/test_util/ir.hpp" @@ -27,7 +27,7 @@ namespace tactile::test { struct TmjRoundtripConfig final { - StringView map_filename; + std::string_view map_filename; TileEncoding encoding; std::optional compression; bool use_external_tilesets; diff --git a/source/vulkan_renderer/lib/inc/tactile/vulkan_renderer/vulkan_util.hpp b/source/vulkan_renderer/lib/inc/tactile/vulkan_renderer/vulkan_util.hpp index f1f949311a..4531eccef2 100644 --- a/source/vulkan_renderer/lib/inc/tactile/vulkan_renderer/vulkan_util.hpp +++ b/source/vulkan_renderer/lib/inc/tactile/vulkan_renderer/vulkan_util.hpp @@ -2,15 +2,16 @@ #pragma once +#include // string_view + #include -#include "tactile/base/container/string.hpp" #include "tactile/base/prelude.hpp" #include "tactile/vulkan_renderer/api.hpp" namespace tactile { [[nodiscard]] -TACTILE_VULKAN_API auto to_string(VkResult result) noexcept -> StringView; +TACTILE_VULKAN_API auto to_string(VkResult result) noexcept -> std::string_view; } // namespace tactile diff --git a/source/vulkan_renderer/lib/src/vulkan_util.cpp b/source/vulkan_renderer/lib/src/vulkan_util.cpp index a8ad192ba7..a75654ec49 100644 --- a/source/vulkan_renderer/lib/src/vulkan_util.cpp +++ b/source/vulkan_renderer/lib/src/vulkan_util.cpp @@ -6,7 +6,7 @@ namespace tactile { -auto to_string(const VkResult result) noexcept -> StringView +auto to_string(const VkResult result) noexcept -> std::string_view { return magic_enum::enum_name(result); } diff --git a/source/zlib_compression/lib/src/tactile/zlib_compression/zlib_compressor.cpp b/source/zlib_compression/lib/src/tactile/zlib_compression/zlib_compressor.cpp index 903dc0e1ee..d889616b34 100644 --- a/source/zlib_compression/lib/src/tactile/zlib_compression/zlib_compressor.cpp +++ b/source/zlib_compression/lib/src/tactile/zlib_compression/zlib_compressor.cpp @@ -3,13 +3,12 @@ #include "tactile/zlib_compression/zlib_compressor.hpp" #include // array +#include // expected #include // errc, make_error_code +#include // error_code #include // move #define Z_PREFIX_SET -#include // expected -#include // error_code - #include #include "tactile/base/io/byte_stream.hpp" diff --git a/source/zlib_compression/test/src/zlib_compressor_test.cpp b/source/zlib_compression/test/src/zlib_compressor_test.cpp index f8ff3b2701..d5a6e1410c 100644 --- a/source/zlib_compression/test/src/zlib_compressor_test.cpp +++ b/source/zlib_compression/test/src/zlib_compressor_test.cpp @@ -3,12 +3,11 @@ #include "tactile/zlib_compression/zlib_compressor.hpp" #include // iota +#include // string #include #include -#include "tactile/base/container/string.hpp" - namespace tactile::test { // tactile::ZlibCompressor::compress @@ -35,7 +34,7 @@ TEST(ZlibCompressor, CompressAndDecompressString) { const ZlibCompressor compressor {}; - const StringView original_string = + const std::string_view original_string = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Mi bibendum neque egestas congue quisque egestas diam in arcu. Varius duis at consectetur lorem. Ultricies tristique nulla aliquet enim tortor at auctor. Nibh nisl condimentum id venenatis a condimentum vitae sapien pellentesque. Venenatis urna cursus eget nunc scelerisque. Mattis molestie a iaculis at erat pellentesque adipiscing commodo elit. Commodo ullamcorper a lacus vestibulum sed arcu non odio euismod. Vivamus arcu felis bibendum ut. Libero enim sed faucibus turpis in eu mi bibendum neque. Blandit volutpat maecenas volutpat blandit aliquam etiam."; const auto compressed_bytes = compressor.compress(make_byte_span(original_string)); @@ -44,7 +43,7 @@ TEST(ZlibCompressor, CompressAndDecompressString) const auto decompressed_bytes = compressor.decompress(*compressed_bytes); ASSERT_TRUE(decompressed_bytes.has_value()); - const String restored_string {decompressed_bytes->begin(), decompressed_bytes->end()}; + const std::string restored_string {decompressed_bytes->begin(), decompressed_bytes->end()}; EXPECT_EQ(restored_string, original_string); } diff --git a/source/zstd_compression/test/src/zstd_compressor_test.cpp b/source/zstd_compression/test/src/zstd_compressor_test.cpp index 8ebaf383fa..39b061574f 100644 --- a/source/zstd_compression/test/src/zstd_compressor_test.cpp +++ b/source/zstd_compression/test/src/zstd_compressor_test.cpp @@ -3,12 +3,11 @@ #include "tactile/zstd_compression/zstd_compressor.hpp" #include // iota +#include // string #include #include -#include "tactile/base/container/string.hpp" - namespace tactile::test { // tactile::ZstdCompressor::compress @@ -35,7 +34,7 @@ TEST(ZstdCompressor, CompressAndDecompressString) { const ZstdCompressor compressor {}; - const StringView original_string = + const std::string_view original_string = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Mi bibendum neque egestas congue quisque egestas diam in arcu. Varius duis at consectetur lorem. Ultricies tristique nulla aliquet enim tortor at auctor. Nibh nisl condimentum id venenatis a condimentum vitae sapien pellentesque. Venenatis urna cursus eget nunc scelerisque. Mattis molestie a iaculis at erat pellentesque adipiscing commodo elit. Commodo ullamcorper a lacus vestibulum sed arcu non odio euismod. Vivamus arcu felis bibendum ut. Libero enim sed faucibus turpis in eu mi bibendum neque. Blandit volutpat maecenas volutpat blandit aliquam etiam."; const auto compressed_bytes = compressor.compress(make_byte_span(original_string)); @@ -44,7 +43,7 @@ TEST(ZstdCompressor, CompressAndDecompressString) const auto decompressed_bytes = compressor.decompress(*compressed_bytes); ASSERT_TRUE(decompressed_bytes.has_value()); - const String restored_string {decompressed_bytes->begin(), decompressed_bytes->end()}; + const std::string restored_string {decompressed_bytes->begin(), decompressed_bytes->end()}; EXPECT_EQ(restored_string, original_string); }