diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/crepe/api/Asset.cpp | 15 | ||||
| -rw-r--r-- | src/crepe/api/Asset.h | 8 | ||||
| -rw-r--r-- | src/crepe/types.h | 4 | ||||
| -rw-r--r-- | src/crepe/util/OptionalRef.h | 13 | ||||
| -rw-r--r-- | src/crepe/util/OptionalRef.hpp | 3 | ||||
| -rw-r--r-- | src/example/rendering.cpp | 5 | ||||
| -rw-r--r-- | src/test/AssetTest.cpp | 13 | ||||
| -rw-r--r-- | src/test/OptionalRefTest.cpp | 1 | 
8 files changed, 23 insertions, 39 deletions
diff --git a/src/crepe/api/Asset.cpp b/src/crepe/api/Asset.cpp index 5271cf7..3fe3ceb 100644 --- a/src/crepe/api/Asset.cpp +++ b/src/crepe/api/Asset.cpp @@ -8,8 +8,8 @@  using namespace crepe;  using namespace std; -Asset::Asset(const string & src) : src(find_asset(src)) { } -Asset::Asset(const char * src) : src(find_asset(src)) { } +Asset::Asset(const string & src) : src(find_asset(src)) {} +Asset::Asset(const char * src) : src(find_asset(src)) {}  const string & Asset::get_path() const noexcept { return this->src; } @@ -22,14 +22,12 @@ string Asset::find_asset(const string & src) const {  	// absolute paths do not need to be resolved, only canonicalized  	filesystem::path path = src; -	if (path.is_absolute()) -		return filesystem::canonical(path); +	if (path.is_absolute()) return filesystem::canonical(path);  	// find directory matching root_pattern  	filesystem::path root = this->whereami();  	while (1) { -		if (filesystem::exists(root / root_pattern)) -			break; +		if (filesystem::exists(root / root_pattern)) break;  		if (!root.has_parent_path())  			throw runtime_error(format("Asset: Cannot find root pattern ({})", root_pattern));  		root = root.parent_path(); @@ -48,11 +46,8 @@ string Asset::whereami() const noexcept {  	return path;  } -bool Asset::operator==(const Asset & other) const noexcept { -	return this->src == other.src; -} +bool Asset::operator==(const Asset & other) const noexcept { return this->src == other.src; }  size_t std::hash<const Asset>::operator()(const Asset & asset) const noexcept {  	return std::hash<string>{}(asset.get_path());  }; - diff --git a/src/crepe/api/Asset.h b/src/crepe/api/Asset.h index 685dd3a..77596ac 100644 --- a/src/crepe/api/Asset.h +++ b/src/crepe/api/Asset.h @@ -33,7 +33,7 @@ public:  	 * \param other Possibly different instance of \c Asset to test equality against  	 * \return True if \c this and \c other are equal  	 */ -	bool operator == (const Asset & other) const noexcept; +	bool operator==(const Asset & other) const noexcept;  private:  	//! path to asset @@ -52,7 +52,8 @@ private:  namespace std {  //! Hash helper struct -template<> struct hash<const crepe::Asset> { +template <> +struct hash<const crepe::Asset> {  	/**  	 * \brief Hash operator for crepe::Asset  	 * @@ -64,5 +65,4 @@ template<> struct hash<const crepe::Asset> {  	size_t operator()(const crepe::Asset & asset) const noexcept;  }; -} - +} // namespace std diff --git a/src/crepe/types.h b/src/crepe/types.h index 86730cc..914c76c 100644 --- a/src/crepe/types.h +++ b/src/crepe/types.h @@ -1,8 +1,8 @@  #pragma once  #include <cstdint> -#include <vector>  #include <functional> +#include <vector>  namespace crepe { @@ -13,4 +13,4 @@ typedef uint32_t game_object_id_t;  template <typename T>  using RefVector = std::vector<std::reference_wrapper<T>>; -} +} // namespace crepe diff --git a/src/crepe/util/OptionalRef.h b/src/crepe/util/OptionalRef.h index 8417a25..0a94ae5 100644 --- a/src/crepe/util/OptionalRef.h +++ b/src/crepe/util/OptionalRef.h @@ -23,7 +23,7 @@ public:  	 *  	 * \return Reference to this (required for operator)  	 */ -  OptionalRef<T> & operator=(T & ref); +	OptionalRef<T> & operator=(T & ref);  	/**  	 * \brief Check if this reference is not empty  	 * @@ -51,13 +51,13 @@ public:  	void clear() noexcept;  	//! Copy constructor -  OptionalRef(const OptionalRef<T> &); +	OptionalRef(const OptionalRef<T> &);  	//! Move constructor -  OptionalRef(OptionalRef<T> &&); +	OptionalRef(OptionalRef<T> &&);  	//! Copy assignment -  OptionalRef<T> & operator=(const OptionalRef<T> &); +	OptionalRef<T> & operator=(const OptionalRef<T> &);  	//! Move assignment -  OptionalRef<T> & operator=(OptionalRef<T> &&); +	OptionalRef<T> & operator=(OptionalRef<T> &&);  private:  	/** @@ -68,7 +68,6 @@ private:  	T * ref = nullptr;  }; -} +} // namespace crepe  #include "OptionalRef.hpp" - diff --git a/src/crepe/util/OptionalRef.hpp b/src/crepe/util/OptionalRef.hpp index 7b201b0..ee41f61 100644 --- a/src/crepe/util/OptionalRef.hpp +++ b/src/crepe/util/OptionalRef.hpp @@ -63,5 +63,4 @@ OptionalRef<T>::operator bool() const noexcept {  	return this->ref != nullptr;  } -} - +} // namespace crepe diff --git a/src/example/rendering.cpp b/src/example/rendering.cpp index 522ec0f..01794f8 100644 --- a/src/example/rendering.cpp +++ b/src/example/rendering.cpp @@ -30,9 +30,8 @@ int main() {  	// Normal adding components  	{  		Color color(0, 0, 0, 0); -		Sprite & sprite -			= obj.add_component<Sprite>(make_shared<Texture>("asset/texture/img.png"), -										color, FlipSettings{false, false}); +		Sprite & sprite = obj.add_component<Sprite>( +			make_shared<Texture>("asset/texture/img.png"), color, FlipSettings{false, false});  		sprite.sorting_in_layer = 2;  		sprite.order_in_layer = 1;  		obj.add_component<Camera>(Color::RED); diff --git a/src/test/AssetTest.cpp b/src/test/AssetTest.cpp index 563a253..8aa7629 100644 --- a/src/test/AssetTest.cpp +++ b/src/test/AssetTest.cpp @@ -10,18 +10,12 @@ using namespace testing;  class AssetTest : public Test {  public:  	Config & cfg = Config::get_instance(); -	void SetUp() override { -		this->cfg.asset.root_pattern = ".crepe-root"; -	} +	void SetUp() override { this->cfg.asset.root_pattern = ".crepe-root"; }  }; -TEST_F(AssetTest, Existant) { -	ASSERT_NO_THROW(Asset{"asset/texture/img.png"}); -} +TEST_F(AssetTest, Existant) { ASSERT_NO_THROW(Asset{"asset/texture/img.png"}); } -TEST_F(AssetTest, Nonexistant) { -	ASSERT_ANY_THROW(Asset{"asset/nonexistant"}); -} +TEST_F(AssetTest, Nonexistant) { ASSERT_ANY_THROW(Asset{"asset/nonexistant"}); }  TEST_F(AssetTest, Rootless) {  	cfg.asset.root_pattern.clear(); @@ -30,4 +24,3 @@ TEST_F(AssetTest, Rootless) {  	Asset asset{arbitrary};  	ASSERT_EQ(arbitrary, asset.get_path());  } - diff --git a/src/test/OptionalRefTest.cpp b/src/test/OptionalRefTest.cpp index 219ccca..2072d56 100644 --- a/src/test/OptionalRefTest.cpp +++ b/src/test/OptionalRefTest.cpp @@ -35,4 +35,3 @@ TEST(OptionalRefTest, Implicit) {  	EXPECT_TRUE(ref);  	ASSERT_NO_THROW(ref.get());  } -  |