Skip to content

Commit

Permalink
Remove path header
Browse files Browse the repository at this point in the history
  • Loading branch information
albin-johansson committed Aug 23, 2024
1 parent 9cca4d5 commit 47d1a52
Show file tree
Hide file tree
Showing 59 changed files with 182 additions and 175 deletions.
1 change: 0 additions & 1 deletion source/base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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/path.hpp"
"inc/tactile/base/container/smart_ptr.hpp"
"inc/tactile/base/container/string.hpp"
"inc/tactile/base/container/string_map.hpp"
Expand Down
13 changes: 0 additions & 13 deletions source/base/inc/tactile/base/container/path.hpp

This file was deleted.

2 changes: 1 addition & 1 deletion source/base/inc/tactile/base/container/string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

#pragma once

#include <filesystem> // path
#include <string> // basic_string, string
#include <string_view> // basic_string_view, string_view, wstring_view
#include <type_traits> // conditional_t

#include "tactile/base/container/path.hpp"
#include "tactile/base/prelude.hpp"

#if TACTILE_OS_WINDOWS
Expand Down
6 changes: 3 additions & 3 deletions source/base/inc/tactile/base/document/document.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#pragma once

#include <expected> // expected
#include <filesystem> // path
#include <system_error> // error_code

#include "tactile/base/container/path.hpp"
#include "tactile/base/io/save/save_format_id.hpp"
#include "tactile/base/numeric/vec.hpp"
#include "tactile/base/prelude.hpp"
Expand Down Expand Up @@ -53,7 +53,7 @@ class IDocument
*
* \param path A save file path.
*/
virtual void set_path(Path path) = 0;
virtual void set_path(std::filesystem::path path) = 0;

/**
* Sets the save format used by the document.
Expand All @@ -69,7 +69,7 @@ class IDocument
* The associated file path, if any.
*/
[[nodiscard]]
virtual auto get_path() const -> const Path* = 0;
virtual auto get_path() const -> const std::filesystem::path* = 0;

/**
* Returns the save format used by the document.
Expand Down
4 changes: 2 additions & 2 deletions source/base/inc/tactile/base/document/map_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
#pragma once

#include <expected> // expected
#include <filesystem> // path
#include <optional> // optional
#include <system_error> // error_code

#include "tactile/base/container/path.hpp"
#include "tactile/base/id.hpp"
#include "tactile/base/int.hpp"
#include "tactile/base/io/compress/compression_format.hpp"
Expand Down Expand Up @@ -46,7 +46,7 @@ class IMapView
* A possibly null file path.
*/
[[nodiscard]]
virtual auto get_path() const -> const Path* = 0;
virtual auto get_path() const -> const std::filesystem::path* = 0;

/**
* Returns the logical size of tiles in the map.
Expand Down
4 changes: 2 additions & 2 deletions source/base/inc/tactile/base/document/tileset_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#pragma once

#include <expected> // expected
#include <filesystem> // path
#include <system_error> // error_code

#include "tactile/base/container/path.hpp"
#include "tactile/base/container/string.hpp"
#include "tactile/base/id.hpp"
#include "tactile/base/numeric/vec.hpp"
Expand Down Expand Up @@ -102,7 +102,7 @@ class ITilesetView
* An image path.
*/
[[nodiscard]]
virtual auto get_image_path() const -> const Path& = 0;
virtual auto get_image_path() const -> const std::filesystem::path& = 0;

/**
* Returns a view of the associated metadata.
Expand Down
12 changes: 6 additions & 6 deletions source/base/inc/tactile/base/io/file_io.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

#pragma once

#include <fstream> // ifstream
#include <ios> // ios
#include <iterator> // istreambuf_iterator
#include <optional> // optional
#include <filesystem> // path
#include <fstream> // ifstream
#include <ios> // ios
#include <iterator> // istreambuf_iterator
#include <optional> // optional

#include "tactile/base/container/path.hpp"
#include "tactile/base/container/string.hpp"
#include "tactile/base/prelude.hpp"

Expand All @@ -21,7 +21,7 @@ namespace tactile {
* \return
* The file content if successful; an empty optional otherwise.
*/
inline auto read_binary_file(const Path& path) -> std::optional<String>
inline auto read_binary_file(const std::filesystem::path& path) -> std::optional<String>
{
std::ifstream stream {path, std::ios::in | std::ios::binary};

Expand Down
8 changes: 4 additions & 4 deletions source/base/inc/tactile/base/io/save/ir.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

#pragma once

#include <optional> // optional
#include <vector> // vector
#include <filesystem> // path
#include <optional> // optional
#include <vector> // vector

#include "tactile/base/container/path.hpp"
#include "tactile/base/container/string.hpp"
#include "tactile/base/id.hpp"
#include "tactile/base/io/compress/compression_format.hpp"
Expand Down Expand Up @@ -209,7 +209,7 @@ struct Tileset final
Int2 image_size;

/** The file path to the associated image. */
Path image_path;
std::filesystem::path image_path;

/** The associated tile descriptors. */
std::vector<Tile> tiles;
Expand Down
9 changes: 5 additions & 4 deletions source/base/inc/tactile/base/io/save/save_format.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#pragma once

#include <expected> // expected
#include <filesystem> // path
#include <system_error> // error_code

#include "tactile/base/container/path.hpp"
#include "tactile/base/io/save/ir.hpp"
#include "tactile/base/prelude.hpp"

Expand All @@ -19,7 +19,7 @@ class IMapView;
struct SaveFormatReadOptions final
{
/** The parent directory of the map or tileset file. */
Path base_dir;
std::filesystem::path base_dir;

/** Whether strict parsing is to be enforced. */
bool strict_mode : 1;
Expand All @@ -31,7 +31,7 @@ struct SaveFormatReadOptions final
struct SaveFormatWriteOptions final
{
/** The parent directory of the map or tileset file. */
Path base_dir;
std::filesystem::path base_dir;

/** Whether tilesets are saved in separate files. */
bool use_external_tilesets : 1;
Expand Down Expand Up @@ -66,7 +66,8 @@ class ISaveFormat
* An intermediate map if successful; an error code otherwise.
*/
[[nodiscard]]
virtual auto load_map(const Path& map_path, const SaveFormatReadOptions& options) const
virtual auto load_map(const std::filesystem::path& map_path,
const SaveFormatReadOptions& options) const
-> std::expected<ir::Map, std::error_code> = 0;

/**
Expand Down
28 changes: 14 additions & 14 deletions source/base/inc/tactile/base/meta/attribute.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

#include <cassert> // assert
#include <concepts> // same_as, convertible_to
#include <filesystem> // path
#include <stdexcept> // logic_error
#include <type_traits> // decay_t
#include <utility> // move
#include <variant> // variant, visit

#include "tactile/base/container/path.hpp"
#include "tactile/base/container/string.hpp"
#include "tactile/base/id.hpp"
#include "tactile/base/meta/attribute_type.hpp"
Expand All @@ -21,18 +21,18 @@
namespace tactile {

template <typename T>
concept AttributeValueType = std::same_as<T, bool> || //
std::convertible_to<T, String> || //
std::convertible_to<T, int32> || //
std::convertible_to<T, Int2> || //
std::convertible_to<T, Int3> || //
std::convertible_to<T, Int4> || //
std::convertible_to<T, float> || //
std::convertible_to<T, Float2> || //
std::convertible_to<T, Float3> || //
std::convertible_to<T, Float4> || //
std::convertible_to<T, UColor> || //
std::convertible_to<T, Path> || //
concept AttributeValueType = std::same_as<T, bool> || //
std::convertible_to<T, String> || //
std::convertible_to<T, int32> || //
std::convertible_to<T, Int2> || //
std::convertible_to<T, Int3> || //
std::convertible_to<T, Int4> || //
std::convertible_to<T, float> || //
std::convertible_to<T, Float2> || //
std::convertible_to<T, Float3> || //
std::convertible_to<T, Float4> || //
std::convertible_to<T, UColor> || //
std::convertible_to<T, std::filesystem::path> || //
std::convertible_to<T, ObjectRef>;

/**
Expand Down Expand Up @@ -66,7 +66,7 @@ class Attribute final
using float3_type = Float3;
using float4_type = Float4;
using color_type = UColor;
using path_type = Path;
using path_type = std::filesystem::path;
using objref_type = ObjectRef;

// Remember to update the type indices if the type order changes.
Expand Down
10 changes: 5 additions & 5 deletions source/base/inc/tactile/base/platform/filesystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

#pragma once

#include <algorithm> // replace
#include <algorithm> // replace
#include <filesystem> // path

#include "tactile/base/container/path.hpp"
#include "tactile/base/container/string.hpp"
#include "tactile/base/prelude.hpp"

Expand All @@ -19,12 +19,12 @@ namespace tactile {
* A string that represents the provided path but using forward slashes.
*/
[[nodiscard]]
inline auto normalize_path_separators(const Path& path) -> String
inline auto normalize_path_separators(const std::filesystem::path& path) -> String
{
auto path_str = path.string();

if constexpr (Path::preferred_separator != '/') {
std::ranges::replace(path_str, Path::preferred_separator, '/');
if constexpr (std::filesystem::path::preferred_separator != '/') {
std::ranges::replace(path_str, std::filesystem::path::preferred_separator, '/');
}

return path_str;
Expand Down
5 changes: 3 additions & 2 deletions source/base/inc/tactile/base/render/texture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

#pragma once

#include "tactile/base/container/path.hpp"
#include <filesystem> // path

#include "tactile/base/prelude.hpp"

namespace tactile {
Expand Down Expand Up @@ -45,7 +46,7 @@ class ITexture
* A file path.
*/
[[nodiscard]]
virtual auto get_path() const -> const Path& = 0;
virtual auto get_path() const -> const std::filesystem::path& = 0;
};

} // namespace tactile
8 changes: 4 additions & 4 deletions source/base/test/src/meta/attribute_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ TEST(Attribute, ExplicitTypeConstructor)
EXPECT_EQ(Attribute {AttributeType::kFloat4}, Attribute {Float4 {}});
EXPECT_EQ(Attribute {AttributeType::kBool}, Attribute {bool {}});
EXPECT_EQ(Attribute {AttributeType::kColor}, Attribute {UColor {}});
EXPECT_EQ(Attribute {AttributeType::kPath}, Attribute {Path {}});
EXPECT_EQ(Attribute {AttributeType::kPath}, Attribute {std::filesystem::path {}});
EXPECT_EQ(Attribute {AttributeType::kObject}, Attribute {ObjectRef {}});
}

Expand Down Expand Up @@ -76,7 +76,7 @@ TEST(Attribute, ImplicitValueConstructor)
}

{
const Attribute path {Path {"foo/bar"}};
const Attribute path {std::filesystem::path {"foo/bar"}};
EXPECT_EQ(path.get_type(), AttributeType::kPath);
EXPECT_EQ(path.as_path(), "foo/bar");
}
Expand Down Expand Up @@ -150,7 +150,7 @@ TEST(Attribute, Reset)

attribute.reset(AttributeType::kPath);
EXPECT_TRUE(attribute.has_default_value());
EXPECT_EQ(attribute, Attribute {Path {}});
EXPECT_EQ(attribute, Attribute {std::filesystem::path {}});

attribute.reset(AttributeType::kObject);
EXPECT_TRUE(attribute.has_default_value());
Expand Down Expand Up @@ -259,7 +259,7 @@ TEST(Attribute, AsColor)
// tactile::Attribute::as_path
TEST(Attribute, AsPath)
{
EXPECT_EQ(Attribute {AttributeType::kPath}.as_path(), Path {});
EXPECT_EQ(Attribute {AttributeType::kPath}.as_path(), std::filesystem::path {});
EXPECT_ANY_THROW((void) Attribute {AttributeType::kStr}.as_path());
}

Expand Down
2 changes: 1 addition & 1 deletion source/base/test/src/platform/filesystem_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace tactile::test {
// tactile::normalize_path_separators
TEST(Filesystem, NormalizePathSeparators)
{
const auto path = Path {"f"} / "o" / "o" / "b" / "a" / "r";
const auto path = std::filesystem::path {"f"} / "o" / "o" / "b" / "a" / "r";
EXPECT_EQ(normalize_path_separators(path), "f/o/o/b/a/r");
}

Expand Down
3 changes: 1 addition & 2 deletions source/base/test/src/util/buffer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
#include <algorithm> // fill_n
#include <array> // array
#include <iterator> // distance, back_inserter
#include <vector> // vector

#include <gmock/gmock.h>
#include <gtest/gtest.h>

#include <vector> // vector

namespace tactile::test {

using testing::Const;
Expand Down
4 changes: 2 additions & 2 deletions source/core/inc/tactile/core/document/map_document.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ class MapDocument final : public IDocument

void update() override;

void set_path(Path path) override;
void set_path(std::filesystem::path path) override;

void set_format(SaveFormatId format_id) override;

[[nodiscard]]
auto get_path() const -> const Path* override;
auto get_path() const -> const std::filesystem::path* override;

[[nodiscard]]
auto get_format() const -> SaveFormatId override;
Expand Down
2 changes: 1 addition & 1 deletion source/core/inc/tactile/core/document/map_view_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class MapViewImpl final : public IMapView
-> std::expected<void, std::error_code> override;

[[nodiscard]]
auto get_path() const -> const Path* override;
auto get_path() const -> const std::filesystem::path* override;

[[nodiscard]]
auto get_tile_size() const -> Int2 override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class TilesetViewImpl final : public ITilesetView
auto get_image_size() const -> Int2 override;

[[nodiscard]]
auto get_image_path() const -> const Path& override;
auto get_image_path() const -> const std::filesystem::path& override;

[[nodiscard]]
auto get_meta() const -> const IMetaView& override;
Expand Down
Loading

0 comments on commit 47d1a52

Please sign in to comment.