From 970f87792d52b74e14641d05b4440291b674fd1b Mon Sep 17 00:00:00 2001 From: BlackMATov Date: Thu, 30 May 2019 14:13:08 +0700 Subject: [PATCH] utils to c++17 --- headers/enduro2d/math/unit.hpp | 4 +- headers/enduro2d/utils/_all.hpp | 1 + headers/enduro2d/utils/_utils.hpp | 2 + headers/enduro2d/utils/color.hpp | 10 +-- headers/enduro2d/utils/color32.hpp | 10 +-- headers/enduro2d/utils/filesystem.hpp | 15 ++-- headers/enduro2d/utils/filesystem.inl | 8 +-- headers/enduro2d/utils/image.hpp | 4 +- headers/enduro2d/utils/mesh.hpp | 4 +- headers/enduro2d/utils/module.hpp | 4 +- headers/enduro2d/utils/path.hpp | 4 +- headers/enduro2d/utils/shape.hpp | 4 +- headers/enduro2d/utils/streams.hpp | 15 ++-- headers/enduro2d/utils/streams.inl | 4 -- headers/enduro2d/utils/strfmts.hpp | 70 +++++++++---------- headers/enduro2d/utils/strings.hpp | 65 ++++++++--------- headers/enduro2d/utils/strings.inl | 42 ++++++----- headers/enduro2d/utils/time.hpp | 14 ++-- headers/enduro2d/utils/url.hpp | 25 +------ headers/enduro2d/utils/xml_utils.hpp | 4 +- sources/enduro2d/utils/color.cpp | 8 +-- sources/enduro2d/utils/color32.cpp | 8 +-- sources/enduro2d/utils/filesystem.cpp | 4 +- .../enduro2d/utils/filesystem_impl/files.hpp | 4 +- .../utils/filesystem_impl/files_posix.cpp | 4 +- .../utils/filesystem_impl/files_winapi.cpp | 4 +- .../utils/filesystem_impl/filesystem.hpp | 4 +- .../utils/filesystem_impl/filesystem_ios.mm | 4 +- .../filesystem_impl/filesystem_linux.cpp | 4 +- .../filesystem_impl/filesystem_macosx.mm | 4 +- .../filesystem_impl/filesystem_windows.cpp | 4 +- sources/enduro2d/utils/image.cpp | 4 +- .../enduro2d/utils/image_impl/image_impl.hpp | 4 +- .../utils/image_impl/image_reader_dds.cpp | 4 +- .../utils/image_impl/image_reader_pvr.cpp | 4 +- .../utils/image_impl/image_reader_stb.cpp | 10 +-- .../utils/image_impl/image_writer_dds.cpp | 4 +- .../utils/image_impl/image_writer_pvr.cpp | 4 +- .../utils/image_impl/image_writer_stb.cpp | 10 +-- sources/enduro2d/utils/json_utils.cpp | 18 ++--- sources/enduro2d/utils/mesh.cpp | 4 +- .../enduro2d/utils/mesh_impl/mesh_impl.hpp | 4 +- .../utils/mesh_impl/mesh_reader_e2d.cpp | 7 +- sources/enduro2d/utils/path.cpp | 4 +- sources/enduro2d/utils/shape.cpp | 4 +- .../enduro2d/utils/shape_impl/shape_impl.hpp | 4 +- .../utils/shape_impl/shape_reader_e2d.cpp | 7 +- sources/enduro2d/utils/streams.cpp | 4 +- sources/enduro2d/utils/strings.cpp | 4 +- sources/enduro2d/utils/url.cpp | 10 +-- sources/enduro2d/utils/xml_utils.cpp | 4 +- untests/sources/untests_core/vfs.cpp | 4 +- 52 files changed, 226 insertions(+), 257 deletions(-) diff --git a/headers/enduro2d/math/unit.hpp b/headers/enduro2d/math/unit.hpp index 4b951de3..5fa03184 100644 --- a/headers/enduro2d/math/unit.hpp +++ b/headers/enduro2d/math/unit.hpp @@ -226,7 +226,7 @@ namespace e2d } } -namespace e2d { namespace math +namespace e2d::math { // // approximately @@ -279,4 +279,4 @@ namespace e2d { namespace math bool contains_nan(const unit& u) noexcept { return !math::is_finite(u.value); } -}} +} diff --git a/headers/enduro2d/utils/_all.hpp b/headers/enduro2d/utils/_all.hpp index baf63f6f..4c0362f4 100644 --- a/headers/enduro2d/utils/_all.hpp +++ b/headers/enduro2d/utils/_all.hpp @@ -23,6 +23,7 @@ #include "path.hpp" #include "shape.hpp" #include "streams.hpp" +#include "streams.inl" #include "strfmts.hpp" #include "strings.hpp" #include "strings.inl" diff --git a/headers/enduro2d/utils/_utils.hpp b/headers/enduro2d/utils/_utils.hpp index 401cadb1..d0d848e6 100644 --- a/headers/enduro2d/utils/_utils.hpp +++ b/headers/enduro2d/utils/_utils.hpp @@ -15,6 +15,8 @@ namespace e2d class buffer_view; class color; class color32; + class read_file; + class write_file; class image; class mesh; class shape; diff --git a/headers/enduro2d/utils/color.hpp b/headers/enduro2d/utils/color.hpp index 39dc886b..b2b1801a 100644 --- a/headers/enduro2d/utils/color.hpp +++ b/headers/enduro2d/utils/color.hpp @@ -38,7 +38,7 @@ namespace e2d const f32* data() const noexcept; f32& operator[](std::size_t index) noexcept; - f32 operator[](std::size_t index) const noexcept; + f32 operator[](std::size_t index) const noexcept; color& operator+=(f32 v) noexcept; color& operator-=(f32 v) noexcept; @@ -74,7 +74,7 @@ namespace e2d color operator/(color l, const color& r) noexcept; } -namespace e2d { namespace math +namespace e2d::math { bool approximately(const color& l, const color& r) noexcept; bool approximately(const color& l, const color& r, f32 precision) noexcept; @@ -88,10 +88,10 @@ namespace e2d { namespace math color saturated(const color& c) noexcept; bool contains_nan(const color& c) noexcept; -}} +} -namespace e2d { namespace colors +namespace e2d::colors { u32 pack_color(const color& c) noexcept; color unpack_color(u32 argb) noexcept; -}} +} diff --git a/headers/enduro2d/utils/color32.hpp b/headers/enduro2d/utils/color32.hpp index 1937e6c9..c7f9b91b 100644 --- a/headers/enduro2d/utils/color32.hpp +++ b/headers/enduro2d/utils/color32.hpp @@ -38,7 +38,7 @@ namespace e2d const u8* data() const noexcept; u8& operator[](std::size_t index) noexcept; - u8 operator[](std::size_t index) const noexcept; + u8 operator[](std::size_t index) const noexcept; color32& operator+=(u8 v) noexcept; color32& operator-=(u8 v) noexcept; @@ -74,7 +74,7 @@ namespace e2d color32 operator/(color32 l, const color32& r) noexcept; } -namespace e2d { namespace math +namespace e2d::math { bool approximately(const color32& l, const color32& r) noexcept; bool approximately(const color32& l, const color32& r, u8 precision) noexcept; @@ -85,10 +85,10 @@ namespace e2d { namespace math color32 minimized(const color32& c, const color32& cmin) noexcept; color32 maximized(const color32& c, const color32& cmax) noexcept; color32 clamped(const color32& c, const color32& cmin, const color32& cmax) noexcept; -}} +} -namespace e2d { namespace colors +namespace e2d::colors { u32 pack_color32(const color32& c) noexcept; color32 unpack_color32(u32 argb) noexcept; -}} +} diff --git a/headers/enduro2d/utils/filesystem.hpp b/headers/enduro2d/utils/filesystem.hpp index c42e1bd4..8b84dfe6 100644 --- a/headers/enduro2d/utils/filesystem.hpp +++ b/headers/enduro2d/utils/filesystem.hpp @@ -4,8 +4,6 @@ * Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com) ******************************************************************************/ -#ifndef E2D_INCLUDE_GUARD_B13171AF5FD34D6284271BD2F4B1F6DD -#define E2D_INCLUDE_GUARD_B13171AF5FD34D6284271BD2F4B1F6DD #pragma once #include "_utils.hpp" @@ -13,17 +11,21 @@ namespace e2d { + class read_file; + using read_file_uptr = std::unique_ptr; + class read_file : public input_stream { public: virtual const str& path() const noexcept = 0; }; - using read_file_uptr = std::unique_ptr; + + class write_file; + using write_file_uptr = std::unique_ptr; class write_file : public output_stream { public: virtual const str& path() const noexcept = 0; }; - using write_file_uptr = std::unique_ptr; } namespace e2d @@ -32,7 +34,7 @@ namespace e2d write_file_uptr make_write_file(str_view path, bool append) noexcept; } -namespace e2d { namespace filesystem +namespace e2d::filesystem { bool remove(str_view path); bool exists(str_view path); @@ -86,7 +88,6 @@ namespace e2d { namespace filesystem }; bool extract_predef_path(str& dst, predef_path path_type); -}} +} #include "filesystem.inl" -#endif diff --git a/headers/enduro2d/utils/filesystem.inl b/headers/enduro2d/utils/filesystem.inl index 6da5cafd..f9b72004 100644 --- a/headers/enduro2d/utils/filesystem.inl +++ b/headers/enduro2d/utils/filesystem.inl @@ -4,14 +4,12 @@ * Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com) ******************************************************************************/ -#ifndef E2D_INCLUDE_GUARD_ADA6066FA64F4B30BE65FE6AFB3D887F -#define E2D_INCLUDE_GUARD_ADA6066FA64F4B30BE65FE6AFB3D887F #pragma once #include "_utils.hpp" #include "filesystem.hpp" -namespace e2d { namespace filesystem +namespace e2d::filesystem { template < typename Iter > bool extract_directory(str_view path, Iter result_iter) { @@ -28,6 +26,4 @@ namespace e2d { namespace filesystem return true; }); } -}} - -#endif +} diff --git a/headers/enduro2d/utils/image.hpp b/headers/enduro2d/utils/image.hpp index 9a06bbb5..877bdaa8 100644 --- a/headers/enduro2d/utils/image.hpp +++ b/headers/enduro2d/utils/image.hpp @@ -93,7 +93,7 @@ namespace e2d bool operator!=(const image& l, const image& r) noexcept; } -namespace e2d { namespace images +namespace e2d::images { bool try_load_image( image& dst, @@ -112,4 +112,4 @@ namespace e2d { namespace images const image& src, image_file_format format, const output_stream_uptr& dst) noexcept; -}} +} diff --git a/headers/enduro2d/utils/mesh.hpp b/headers/enduro2d/utils/mesh.hpp index d2be19d2..7aaa7dda 100644 --- a/headers/enduro2d/utils/mesh.hpp +++ b/headers/enduro2d/utils/mesh.hpp @@ -97,7 +97,7 @@ namespace e2d bool operator!=(const mesh& l, const mesh& r) noexcept; } -namespace e2d { namespace meshes +namespace e2d::meshes { bool try_load_mesh( mesh& dst, @@ -106,4 +106,4 @@ namespace e2d { namespace meshes bool try_load_mesh( mesh& dst, const input_stream_uptr& src) noexcept; -}} +} diff --git a/headers/enduro2d/utils/module.hpp b/headers/enduro2d/utils/module.hpp index aa0b6ca0..75aa3772 100644 --- a/headers/enduro2d/utils/module.hpp +++ b/headers/enduro2d/utils/module.hpp @@ -72,7 +72,7 @@ namespace e2d std::unique_ptr module::instance_; } -namespace e2d { namespace modules +namespace e2d::modules { template < typename ImplT, typename... Args > ImplT& initialize(Args&&... args) { @@ -97,4 +97,4 @@ namespace e2d { namespace modules using BaseT = typename ImplT::base_type; return static_cast(module::instance()); } -}} +} diff --git a/headers/enduro2d/utils/path.hpp b/headers/enduro2d/utils/path.hpp index 7314fa99..00f2ef78 100644 --- a/headers/enduro2d/utils/path.hpp +++ b/headers/enduro2d/utils/path.hpp @@ -8,7 +8,7 @@ #include "_utils.hpp" -namespace e2d { namespace path +namespace e2d::path { str combine(str_view lhs, str_view rhs); @@ -25,4 +25,4 @@ namespace e2d { namespace path bool is_absolute(str_view path) noexcept; bool is_relative(str_view path) noexcept; -}} +} diff --git a/headers/enduro2d/utils/shape.hpp b/headers/enduro2d/utils/shape.hpp index 909d3d5a..859a5aa6 100644 --- a/headers/enduro2d/utils/shape.hpp +++ b/headers/enduro2d/utils/shape.hpp @@ -77,7 +77,7 @@ namespace e2d bool operator!=(const shape& l, const shape& r) noexcept; } -namespace e2d { namespace shapes +namespace e2d::shapes { bool try_load_shape( shape& dst, @@ -86,4 +86,4 @@ namespace e2d { namespace shapes bool try_load_shape( shape& dst, const input_stream_uptr& src) noexcept; -}} +} diff --git a/headers/enduro2d/utils/streams.hpp b/headers/enduro2d/utils/streams.hpp index 63369117..dc0775a8 100644 --- a/headers/enduro2d/utils/streams.hpp +++ b/headers/enduro2d/utils/streams.hpp @@ -4,8 +4,6 @@ * Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com) ******************************************************************************/ -#ifndef E2D_INCLUDE_GUARD_271E0872955E4A59980866CBF737BDC1 -#define E2D_INCLUDE_GUARD_271E0872955E4A59980866CBF737BDC1 #pragma once #include "_utils.hpp" @@ -19,6 +17,9 @@ namespace e2d } }; + class input_stream; + using input_stream_uptr = std::unique_ptr; + class input_stream : private noncopyable { public: virtual ~input_stream() noexcept = default; @@ -27,7 +28,9 @@ namespace e2d virtual std::size_t tell() const = 0; virtual std::size_t length() const noexcept = 0; }; - using input_stream_uptr = std::unique_ptr; + + class output_stream; + using output_stream_uptr = std::unique_ptr; class output_stream : private noncopyable { public: @@ -37,7 +40,6 @@ namespace e2d virtual std::size_t tell() const = 0; virtual void flush() const = 0; }; - using output_stream_uptr = std::unique_ptr; } namespace e2d @@ -99,7 +101,7 @@ namespace e2d input_stream_uptr make_memory_stream(buffer data) noexcept; } -namespace e2d { namespace streams +namespace e2d::streams { bool try_read_tail( str& dst, @@ -116,7 +118,6 @@ namespace e2d { namespace streams bool try_write_tail( const buffer& src, const output_stream_uptr& stream) noexcept; -}} +} #include "streams.inl" -#endif diff --git a/headers/enduro2d/utils/streams.inl b/headers/enduro2d/utils/streams.inl index 7cd6dce7..f26500bb 100644 --- a/headers/enduro2d/utils/streams.inl +++ b/headers/enduro2d/utils/streams.inl @@ -4,8 +4,6 @@ * Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com) ******************************************************************************/ -#ifndef E2D_INCLUDE_GUARD_8B0A2CAB69114FA69A716D2CC7F64DD4 -#define E2D_INCLUDE_GUARD_8B0A2CAB69114FA69A716D2CC7F64DD4 #pragma once #include "_utils.hpp" @@ -41,5 +39,3 @@ namespace e2d : *this; } } - -#endif diff --git a/headers/enduro2d/utils/strfmts.hpp b/headers/enduro2d/utils/strfmts.hpp index cf79c8c8..d185bf02 100644 --- a/headers/enduro2d/utils/strfmts.hpp +++ b/headers/enduro2d/utils/strfmts.hpp @@ -13,14 +13,14 @@ #include "color32.hpp" #include "strings.hpp" -namespace e2d { namespace strings +namespace e2d::strings { // // vec2 // template < typename T > - class format_arg, std::enable_if_t::value>> { + class format_arg, std::enable_if_t>> { vec2 value_; u8 width_; public: @@ -37,7 +37,7 @@ namespace e2d { namespace strings }; template < typename T > - class format_arg, std::enable_if_t::value>> { + class format_arg, std::enable_if_t>> { vec2 value_; u8 width_; u8 precision_; @@ -59,7 +59,7 @@ namespace e2d { namespace strings // template < typename T > - class format_arg, std::enable_if_t::value>> { + class format_arg, std::enable_if_t>> { vec3 value_; u8 width_; public: @@ -77,7 +77,7 @@ namespace e2d { namespace strings }; template < typename T > - class format_arg, std::enable_if_t::value>> { + class format_arg, std::enable_if_t>> { vec3 value_; u8 width_; u8 precision_; @@ -100,7 +100,7 @@ namespace e2d { namespace strings // template < typename T > - class format_arg, std::enable_if_t::value>> { + class format_arg, std::enable_if_t>> { vec4 value_; u8 width_; public: @@ -119,7 +119,7 @@ namespace e2d { namespace strings }; template < typename T > - class format_arg, std::enable_if_t::value>> { + class format_arg, std::enable_if_t>> { vec4 value_; u8 width_; u8 precision_; @@ -143,7 +143,7 @@ namespace e2d { namespace strings // template < typename T > - class format_arg, std::enable_if_t::value>> { + class format_arg, std::enable_if_t>> { quat value_; u8 width_; public: @@ -162,7 +162,7 @@ namespace e2d { namespace strings }; template < typename T > - class format_arg, std::enable_if_t::value>> { + class format_arg, std::enable_if_t>> { quat value_; u8 width_; u8 precision_; @@ -186,7 +186,7 @@ namespace e2d { namespace strings // template < typename T > - class format_arg, std::enable_if_t::value>> { + class format_arg, std::enable_if_t>> { rect value_; u8 width_; public: @@ -205,7 +205,7 @@ namespace e2d { namespace strings }; template < typename T > - class format_arg, std::enable_if_t::value>> { + class format_arg, std::enable_if_t>> { rect value_; u8 width_; u8 precision_; @@ -229,7 +229,7 @@ namespace e2d { namespace strings // template < typename T > - class format_arg, std::enable_if_t::value>> { + class format_arg, std::enable_if_t>> { aabb value_; u8 width_; public: @@ -250,7 +250,7 @@ namespace e2d { namespace strings }; template < typename T > - class format_arg, std::enable_if_t::value>> { + class format_arg, std::enable_if_t>> { aabb value_; u8 width_; u8 precision_; @@ -276,7 +276,7 @@ namespace e2d { namespace strings // template < typename T > - class format_arg, std::enable_if_t::value>> { + class format_arg, std::enable_if_t>> { mat2 value_; u8 width_; public: @@ -293,7 +293,7 @@ namespace e2d { namespace strings }; template < typename T > - class format_arg, std::enable_if_t::value>> { + class format_arg, std::enable_if_t>> { mat2 value_; u8 width_; u8 precision_; @@ -315,7 +315,7 @@ namespace e2d { namespace strings // template < typename T > - class format_arg, std::enable_if_t::value>> { + class format_arg, std::enable_if_t>> { mat3 value_; u8 width_; public: @@ -333,7 +333,7 @@ namespace e2d { namespace strings }; template < typename T > - class format_arg, std::enable_if_t::value>> { + class format_arg, std::enable_if_t>> { mat3 value_; u8 width_; u8 precision_; @@ -356,7 +356,7 @@ namespace e2d { namespace strings // template < typename T > - class format_arg, std::enable_if_t::value>> { + class format_arg, std::enable_if_t>> { mat4 value_; u8 width_; public: @@ -375,7 +375,7 @@ namespace e2d { namespace strings }; template < typename T > - class format_arg, std::enable_if_t::value>> { + class format_arg, std::enable_if_t>> { mat4 value_; u8 width_; u8 precision_; @@ -399,7 +399,7 @@ namespace e2d { namespace strings // template < typename T > - class format_arg, std::enable_if_t::value>> { + class format_arg, std::enable_if_t>> { rad value_; u8 width_; public: @@ -415,7 +415,7 @@ namespace e2d { namespace strings }; template < typename T > - class format_arg, std::enable_if_t::value>> { + class format_arg, std::enable_if_t>> { rad value_; u8 width_; u8 precision_; @@ -436,7 +436,7 @@ namespace e2d { namespace strings // template < typename T > - class format_arg, std::enable_if_t::value>> { + class format_arg, std::enable_if_t>> { deg value_; u8 width_; public: @@ -452,7 +452,7 @@ namespace e2d { namespace strings }; template < typename T > - class format_arg, std::enable_if_t::value>> { + class format_arg, std::enable_if_t>> { deg value_; u8 width_; u8 precision_; @@ -478,7 +478,7 @@ namespace e2d { namespace strings public: template < typename U > explicit format_arg(U&& value) - noexcept(noexcept(std::is_nothrow_constructible::value)) + noexcept(noexcept(std::is_nothrow_constructible_v)) : value_(std::forward(value)) {} std::ptrdiff_t write(char* dst, size_t size) const { @@ -499,7 +499,7 @@ namespace e2d { namespace strings public: template < typename U > explicit format_arg(U&& value, u8 width = 0) - noexcept(noexcept(std::is_nothrow_constructible::value)) + noexcept(noexcept(std::is_nothrow_constructible_v)) : value_(std::forward(value)), width_(width) {} std::ptrdiff_t write(char* dst, size_t size) const { @@ -527,7 +527,7 @@ namespace e2d { namespace strings public: template < typename U > explicit format_arg(U&& value, u8 width = 0) - noexcept(noexcept(std::is_nothrow_constructible::value)) + noexcept(noexcept(std::is_nothrow_constructible_v)) : value_(std::forward(value)), width_(width) {} std::ptrdiff_t write(char* dst, size_t size) const { @@ -555,7 +555,7 @@ namespace e2d { namespace strings public: template < typename U > explicit format_arg(U&& value, u8 width = 0) - noexcept(noexcept(std::is_nothrow_constructible::value)) + noexcept(noexcept(std::is_nothrow_constructible_v)) : value_(std::forward(value)), width_(width) {} std::ptrdiff_t write(char* dst, size_t size) const { @@ -583,7 +583,7 @@ namespace e2d { namespace strings public: template < typename U > explicit format_arg(U&& value, u8 width = 0) - noexcept(noexcept(std::is_nothrow_constructible::value)) + noexcept(noexcept(std::is_nothrow_constructible_v)) : value_(std::forward(value)), width_(width) {} std::ptrdiff_t write(char* dst, size_t size) const { @@ -652,7 +652,7 @@ namespace e2d { namespace strings // template < typename T > - class format_arg, std::enable_if_t::value>> { + class format_arg, std::enable_if_t>> { seconds value_; u8 width_; public: @@ -668,7 +668,7 @@ namespace e2d { namespace strings }; template < typename T > - class format_arg, std::enable_if_t::value>> { + class format_arg, std::enable_if_t>> { seconds value_; u8 width_; u8 precision_; @@ -689,7 +689,7 @@ namespace e2d { namespace strings // template < typename T > - class format_arg, std::enable_if_t::value>> { + class format_arg, std::enable_if_t>> { milliseconds value_; u8 width_; public: @@ -705,7 +705,7 @@ namespace e2d { namespace strings }; template < typename T > - class format_arg, std::enable_if_t::value>> { + class format_arg, std::enable_if_t>> { milliseconds value_; u8 width_; u8 precision_; @@ -726,7 +726,7 @@ namespace e2d { namespace strings // template < typename T > - class format_arg, std::enable_if_t::value>> { + class format_arg, std::enable_if_t>> { microseconds value_; u8 width_; public: @@ -742,7 +742,7 @@ namespace e2d { namespace strings }; template < typename T > - class format_arg, std::enable_if_t::value>> { + class format_arg, std::enable_if_t>> { microseconds value_; u8 width_; u8 precision_; @@ -757,4 +757,4 @@ namespace e2d { namespace strings make_format_arg(value_.value, width_, precision_))); } }; -}} +} diff --git a/headers/enduro2d/utils/strings.hpp b/headers/enduro2d/utils/strings.hpp index 084e8516..ce195c36 100644 --- a/headers/enduro2d/utils/strings.hpp +++ b/headers/enduro2d/utils/strings.hpp @@ -4,8 +4,6 @@ * Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com) ******************************************************************************/ -#ifndef E2D_INCLUDE_GUARD_4540A3A22AD942D8A6B0C77A3346E73A -#define E2D_INCLUDE_GUARD_4540A3A22AD942D8A6B0C77A3346E73A #pragma once #include "_utils.hpp" @@ -15,8 +13,8 @@ namespace e2d template < typename Char > class basic_string_hash final { public: - basic_string_hash() noexcept; - ~basic_string_hash() noexcept; + basic_string_hash() noexcept = default; + ~basic_string_hash() noexcept = default; basic_string_hash(basic_string_hash&& other) noexcept; basic_string_hash& operator=(basic_string_hash&& other) noexcept; @@ -84,45 +82,44 @@ namespace e2d wstr_hash make_hash(wstr_view src) noexcept; str16_hash make_hash(str16_view src) noexcept; str32_hash make_hash(str32_view src) noexcept; +} - namespace strings - { - class format_error; - class bad_format; - class bad_format_buffer; - class bad_format_argument; +namespace e2d::strings +{ + class format_error; + class bad_format; + class bad_format_buffer; + class bad_format_argument; - template < typename T, typename = void > - class format_arg; + template < typename T, typename = void > + class format_arg; - template < typename T, typename... Args > - format_arg> make_format_arg(T&& v, Args&&... args); + template < typename T, typename... Args > + format_arg> make_format_arg(T&& v, Args&&... args); - template < typename... Args > - std::size_t format( - char* dst, std::size_t size, - str_view fmt, Args&&... args); + template < typename... Args > + std::size_t format( + char* dst, std::size_t size, + str_view fmt, Args&&... args); - template < typename... Args > - bool format_nothrow( - char* dst, std::size_t dst_size, std::size_t* length, - str_view fmt, Args&&... args) noexcept; + template < typename... Args > + bool format_nothrow( + char* dst, std::size_t dst_size, std::size_t* length, + str_view fmt, Args&&... args) noexcept; - template < typename... Args > - str rformat( - str_view fmt, Args&&... args); + template < typename... Args > + str rformat( + str_view fmt, Args&&... args); - template < typename... Args > - bool rformat_nothrow( - str& dst, - str_view fmt, Args&&... args) noexcept; + template < typename... Args > + bool rformat_nothrow( + str& dst, + str_view fmt, Args&&... args) noexcept; - bool wildcard_match(str_view string, str_view pattern); + bool wildcard_match(str_view string, str_view pattern); - bool starts_with(str_view input, str_view test) noexcept; - bool ends_with(str_view input, str_view test) noexcept; - } + bool starts_with(str_view input, str_view test) noexcept; + bool ends_with(str_view input, str_view test) noexcept; } #include "strings.inl" -#endif diff --git a/headers/enduro2d/utils/strings.inl b/headers/enduro2d/utils/strings.inl index 99749a3c..12c97fc2 100644 --- a/headers/enduro2d/utils/strings.inl +++ b/headers/enduro2d/utils/strings.inl @@ -4,8 +4,6 @@ * Copyright (C) 2018-2019, by Matvey Cherevko (blackmatov@gmail.com) ******************************************************************************/ -#ifndef E2D_INCLUDE_GUARD_5BC5A803A3694674845E9953209E8CBE -#define E2D_INCLUDE_GUARD_5BC5A803A3694674845E9953209E8CBE #pragma once #include "_utils.hpp" @@ -13,12 +11,6 @@ namespace e2d { - template < typename Char > - basic_string_hash::basic_string_hash() noexcept = default; - - template < typename Char > - basic_string_hash::~basic_string_hash() noexcept = default; - template < typename Char > basic_string_hash::basic_string_hash( basic_string_hash&& other) noexcept @@ -189,7 +181,7 @@ namespace std }; } -namespace e2d { namespace strings +namespace e2d::strings { // // exceptions @@ -268,7 +260,7 @@ namespace e2d { namespace strings template < typename T > class format_arg::value && std::is_signed::value>> + std::is_integral_v && std::is_signed_v>> { T value_; u8 width_; @@ -292,7 +284,7 @@ namespace e2d { namespace strings template < typename T > class format_arg::value && std::is_unsigned::value>> + std::is_integral_v && std::is_unsigned_v>> { T value_; u8 width_; @@ -316,7 +308,7 @@ namespace e2d { namespace strings template < typename T > class format_arg::value>> + std::is_floating_point_v>> { T value_; u8 width_; @@ -404,20 +396,28 @@ namespace e2d { namespace strings namespace impl { template < typename T > - struct is_arg_impl : std::false_type {}; - template < typename U > - struct is_arg_impl> : std::true_type {}; - template < typename T > - struct is_arg : is_arg_impl> {}; + struct is_arg_impl + : std::false_type {}; template < typename T > - std::enable_if_t>::value, T> + struct is_arg_impl> + : std::true_type {}; + + template < typename T > + struct is_arg + : is_arg_impl> {}; + + template < typename T > + inline constexpr bool is_arg_v = is_arg::value; + + template < typename T > + std::enable_if_t>, T> wrap_arg(T&& arg) { return std::forward(arg); } template < typename T > - std::enable_if_t>::value, format_arg>> + std::enable_if_t>, format_arg>> wrap_arg(T&& value) { return make_format_arg(std::forward(value)); } @@ -602,6 +602,4 @@ namespace e2d { namespace strings return false; } } -}} - -#endif +} diff --git a/headers/enduro2d/utils/time.hpp b/headers/enduro2d/utils/time.hpp index 7ca8ee04..70b41cc7 100644 --- a/headers/enduro2d/utils/time.hpp +++ b/headers/enduro2d/utils/time.hpp @@ -86,7 +86,7 @@ namespace e2d }; } -namespace e2d { namespace time +namespace e2d::time { template < typename T > std::chrono::duration> @@ -120,9 +120,9 @@ namespace e2d { namespace time microseconds to_microseconds(const unit& u) noexcept { return u.template convert_to(); } -}} +} -namespace e2d { namespace time +namespace e2d::time { template < typename T > const seconds& second() noexcept { @@ -177,9 +177,9 @@ namespace e2d { namespace time static microseconds hour_us = to_microseconds(hour()); return hour_us; } -}} +} -namespace e2d { namespace time +namespace e2d::time { template < typename TimeTag, typename T = i64 > unit now() noexcept { @@ -196,7 +196,7 @@ namespace e2d { namespace time } template < typename T = i64 > - inline unit now_ms() noexcept { + unit now_ms() noexcept { return now(); } @@ -204,4 +204,4 @@ namespace e2d { namespace time unit now_us() noexcept { return now(); } -}} +} diff --git a/headers/enduro2d/utils/url.hpp b/headers/enduro2d/utils/url.hpp index aa048d39..457f6427 100644 --- a/headers/enduro2d/utils/url.hpp +++ b/headers/enduro2d/utils/url.hpp @@ -21,19 +21,13 @@ namespace e2d url& operator=(const url& other); explicit url(str_view schemepath); - url(str_view scheme, str_view path) noexcept; - - template < typename T, typename U > - url(T&& scheme, U&& path) noexcept; + url(str scheme, str path) noexcept; url& assign(url&& other) noexcept; url& assign(const url& other); url& assign(str_view schemepath); - url& assign(str_view scheme, str_view path) noexcept; - - template < typename T, typename U > - url& assign(T&& scheme, U&& path) noexcept; + url& assign(str scheme, str path) noexcept; url& concat(str_view path); url& append(str_view path); @@ -53,21 +47,6 @@ namespace e2d }; } -namespace e2d -{ - template < typename T, typename U > - url::url(T&& scheme, U&& path) noexcept { - assign(std::forward(scheme), std::forward(path)); - } - - template < typename T, typename U > - url& url::assign(T&& scheme, U&& path) noexcept { - scheme_ = std::forward(scheme); - path_ = std::forward(path); - return *this; - } -} - namespace e2d { void swap(url& l, url& r) noexcept; diff --git a/headers/enduro2d/utils/xml_utils.hpp b/headers/enduro2d/utils/xml_utils.hpp index cf47e61a..dbd187ec 100644 --- a/headers/enduro2d/utils/xml_utils.hpp +++ b/headers/enduro2d/utils/xml_utils.hpp @@ -10,6 +10,6 @@ #include <3rdparty/pugixml/pugixml.hpp> -namespace e2d { namespace xml_utils +namespace e2d::xml_utils { -}} +} diff --git a/sources/enduro2d/utils/color.cpp b/sources/enduro2d/utils/color.cpp index 355e7d7a..55a2cf72 100644 --- a/sources/enduro2d/utils/color.cpp +++ b/sources/enduro2d/utils/color.cpp @@ -238,7 +238,7 @@ namespace e2d } } -namespace e2d { namespace math +namespace e2d::math { // // approximately @@ -312,9 +312,9 @@ namespace e2d { namespace math || !math::is_finite(c.b) || !math::is_finite(c.a); } -}} +} -namespace e2d { namespace colors +namespace e2d::colors { u32 pack_color(const color& c) noexcept { return @@ -331,4 +331,4 @@ namespace e2d { namespace colors math::numeric_cast((argb >> 0) & 0xFF) / 255.f, math::numeric_cast((argb >> 24) & 0xFF) / 255.f); } -}} +} diff --git a/sources/enduro2d/utils/color32.cpp b/sources/enduro2d/utils/color32.cpp index 95909ae0..a75bb62d 100644 --- a/sources/enduro2d/utils/color32.cpp +++ b/sources/enduro2d/utils/color32.cpp @@ -238,7 +238,7 @@ namespace e2d } } -namespace e2d { namespace math +namespace e2d::math { // // approximately @@ -297,9 +297,9 @@ namespace e2d { namespace math math::clamp(c.b, cmin.b, cmax.b), math::clamp(c.a, cmin.a, cmax.a)); } -}} +} -namespace e2d { namespace colors +namespace e2d::colors { u32 pack_color32(const color32& c) noexcept { return @@ -316,4 +316,4 @@ namespace e2d { namespace colors math::numeric_cast((argb >> 0) & 0xFF), math::numeric_cast((argb >> 24) & 0xFF)); } -}} +} diff --git a/sources/enduro2d/utils/filesystem.cpp b/sources/enduro2d/utils/filesystem.cpp index e6728f7f..de7fa535 100644 --- a/sources/enduro2d/utils/filesystem.cpp +++ b/sources/enduro2d/utils/filesystem.cpp @@ -18,7 +18,7 @@ namespace e2d } } -namespace e2d { namespace filesystem +namespace e2d::filesystem { bool remove(str_view path) { return remove_file(path) @@ -118,4 +118,4 @@ namespace e2d { namespace filesystem bool extract_predef_path(str& dst, predef_path path_type) { return impl::extract_predef_path(dst, path_type); } -}} +} diff --git a/sources/enduro2d/utils/filesystem_impl/files.hpp b/sources/enduro2d/utils/filesystem_impl/files.hpp index ebca21e1..f9753645 100644 --- a/sources/enduro2d/utils/filesystem_impl/files.hpp +++ b/sources/enduro2d/utils/filesystem_impl/files.hpp @@ -29,8 +29,8 @@ # error E2D_FILES_MODE not detected #endif -namespace e2d { namespace impl +namespace e2d::impl { read_file_uptr make_read_file(str_view path) noexcept; write_file_uptr make_write_file(str_view path, bool append) noexcept; -}} +} diff --git a/sources/enduro2d/utils/filesystem_impl/files_posix.cpp b/sources/enduro2d/utils/filesystem_impl/files_posix.cpp index 2deea908..e6ee5ba5 100644 --- a/sources/enduro2d/utils/filesystem_impl/files_posix.cpp +++ b/sources/enduro2d/utils/filesystem_impl/files_posix.cpp @@ -183,7 +183,7 @@ namespace }; } -namespace e2d { namespace impl +namespace e2d::impl { read_file_uptr make_read_file(str_view path) noexcept { try { @@ -200,6 +200,6 @@ namespace e2d { namespace impl return nullptr; } } -}} +} #endif diff --git a/sources/enduro2d/utils/filesystem_impl/files_winapi.cpp b/sources/enduro2d/utils/filesystem_impl/files_winapi.cpp index 01e0eddd..3d916a4c 100644 --- a/sources/enduro2d/utils/filesystem_impl/files_winapi.cpp +++ b/sources/enduro2d/utils/filesystem_impl/files_winapi.cpp @@ -222,7 +222,7 @@ namespace }; } -namespace e2d { namespace impl +namespace e2d::impl { read_file_uptr make_read_file(str_view path) noexcept { try { @@ -239,6 +239,6 @@ namespace e2d { namespace impl return nullptr; } } -}} +} #endif diff --git a/sources/enduro2d/utils/filesystem_impl/filesystem.hpp b/sources/enduro2d/utils/filesystem_impl/filesystem.hpp index 901453a0..e30a894f 100644 --- a/sources/enduro2d/utils/filesystem_impl/filesystem.hpp +++ b/sources/enduro2d/utils/filesystem_impl/filesystem.hpp @@ -10,7 +10,7 @@ #include #include -namespace e2d { namespace filesystem { namespace impl +namespace e2d::filesystem::impl { bool remove_file(str_view path); bool remove_directory(str_view path); @@ -23,4 +23,4 @@ namespace e2d { namespace filesystem { namespace impl bool trace_directory(str_view path, const trace_func& func); bool extract_predef_path(str& dst, predef_path path_type); -}}} +} diff --git a/sources/enduro2d/utils/filesystem_impl/filesystem_ios.mm b/sources/enduro2d/utils/filesystem_impl/filesystem_ios.mm index deb74a85..e7f26ebd 100644 --- a/sources/enduro2d/utils/filesystem_impl/filesystem_ios.mm +++ b/sources/enduro2d/utils/filesystem_impl/filesystem_ios.mm @@ -88,7 +88,7 @@ namespace } } -namespace e2d { namespace filesystem { namespace impl +namespace e2d::filesystem::impl { bool remove_file(str_view path) { return 0 == ::unlink(make_utf8(path).c_str()) @@ -155,6 +155,6 @@ namespace e2d { namespace filesystem { namespace impl return false; } } -}}} +} #endif diff --git a/sources/enduro2d/utils/filesystem_impl/filesystem_linux.cpp b/sources/enduro2d/utils/filesystem_impl/filesystem_linux.cpp index 65bc8a14..3ed94dc5 100644 --- a/sources/enduro2d/utils/filesystem_impl/filesystem_linux.cpp +++ b/sources/enduro2d/utils/filesystem_impl/filesystem_linux.cpp @@ -78,7 +78,7 @@ namespace } } -namespace e2d { namespace filesystem { namespace impl +namespace e2d::filesystem::impl { bool remove_file(str_view path) { return 0 == ::unlink(make_utf8(path).c_str()) @@ -145,6 +145,6 @@ namespace e2d { namespace filesystem { namespace impl return false; } } -}}} +} #endif diff --git a/sources/enduro2d/utils/filesystem_impl/filesystem_macosx.mm b/sources/enduro2d/utils/filesystem_impl/filesystem_macosx.mm index 0c35303d..b41e0106 100644 --- a/sources/enduro2d/utils/filesystem_impl/filesystem_macosx.mm +++ b/sources/enduro2d/utils/filesystem_impl/filesystem_macosx.mm @@ -88,7 +88,7 @@ namespace } } -namespace e2d { namespace filesystem { namespace impl +namespace e2d::filesystem::impl { bool remove_file(str_view path) { return 0 == ::unlink(make_utf8(path).c_str()) @@ -155,6 +155,6 @@ namespace e2d { namespace filesystem { namespace impl return false; } } -}}} +} #endif diff --git a/sources/enduro2d/utils/filesystem_impl/filesystem_windows.cpp b/sources/enduro2d/utils/filesystem_impl/filesystem_windows.cpp index a19b5c25..632a6efd 100644 --- a/sources/enduro2d/utils/filesystem_impl/filesystem_windows.cpp +++ b/sources/enduro2d/utils/filesystem_impl/filesystem_windows.cpp @@ -92,7 +92,7 @@ namespace } } -namespace e2d { namespace filesystem { namespace impl +namespace e2d::filesystem::impl { bool remove_file(str_view path) { const wstr wide_path = make_wide(path); @@ -169,6 +169,6 @@ namespace e2d { namespace filesystem { namespace impl return false; } } -}}} +} #endif diff --git a/sources/enduro2d/utils/image.cpp b/sources/enduro2d/utils/image.cpp index f7ac6308..13681e72 100644 --- a/sources/enduro2d/utils/image.cpp +++ b/sources/enduro2d/utils/image.cpp @@ -207,7 +207,7 @@ namespace e2d } } -namespace e2d { namespace images +namespace e2d::images { bool try_load_image( image& dst, @@ -258,4 +258,4 @@ namespace e2d { namespace images return try_save_image(src, format, file_data) && streams::try_write_tail(file_data, dst); } -}} +} diff --git a/sources/enduro2d/utils/image_impl/image_impl.hpp b/sources/enduro2d/utils/image_impl/image_impl.hpp index c36c1616..c9786f1a 100644 --- a/sources/enduro2d/utils/image_impl/image_impl.hpp +++ b/sources/enduro2d/utils/image_impl/image_impl.hpp @@ -9,7 +9,7 @@ #include #include -namespace e2d { namespace images { namespace impl +namespace e2d::images::impl { bool try_load_image_dds(image& dst, const buffer& src) noexcept; bool try_load_image_pvr(image& dst, const buffer& src) noexcept; @@ -20,4 +20,4 @@ namespace e2d { namespace images { namespace impl bool try_save_image_png(const image& src, buffer& dst) noexcept; bool try_save_image_pvr(const image& src, buffer& dst) noexcept; bool try_save_image_tga(const image& src, buffer& dst) noexcept; -}}} +} diff --git a/sources/enduro2d/utils/image_impl/image_reader_dds.cpp b/sources/enduro2d/utils/image_impl/image_reader_dds.cpp index 49548705..3ce8c356 100644 --- a/sources/enduro2d/utils/image_impl/image_reader_dds.cpp +++ b/sources/enduro2d/utils/image_impl/image_reader_dds.cpp @@ -6,11 +6,11 @@ #include "image_impl.hpp" -namespace e2d { namespace images { namespace impl +namespace e2d::images::impl { bool try_load_image_dds(image& dst, const buffer& src) noexcept { //TODO(BlackMat): implme E2D_UNUSED(dst, src); return false; } -}}} +} diff --git a/sources/enduro2d/utils/image_impl/image_reader_pvr.cpp b/sources/enduro2d/utils/image_impl/image_reader_pvr.cpp index e151c84a..e39c438b 100644 --- a/sources/enduro2d/utils/image_impl/image_reader_pvr.cpp +++ b/sources/enduro2d/utils/image_impl/image_reader_pvr.cpp @@ -6,11 +6,11 @@ #include "image_impl.hpp" -namespace e2d { namespace images { namespace impl +namespace e2d::images::impl { bool try_load_image_pvr(image& dst, const buffer& src) noexcept { //TODO(BlackMat): implme E2D_UNUSED(dst, src); return false; } -}}} +} diff --git a/sources/enduro2d/utils/image_impl/image_reader_stb.cpp b/sources/enduro2d/utils/image_impl/image_reader_stb.cpp index ada3252c..c20e73b4 100644 --- a/sources/enduro2d/utils/image_impl/image_reader_stb.cpp +++ b/sources/enduro2d/utils/image_impl/image_reader_stb.cpp @@ -16,11 +16,11 @@ #define STBI_ONLY_TGA #define STBI_ONLY_JPEG -#define STBI_FREE(ptr) std::free(ptr) -#define STBI_MALLOC(size) std::malloc(size) +#define STBI_FREE(ptr) std::free(ptr) +#define STBI_MALLOC(size) std::malloc(size) #define STBI_REALLOC(ptr,nsize) std::realloc(ptr, nsize) -#define STBI_ASSERT(expr) E2D_ASSERT(expr) +#define STBI_ASSERT(expr) E2D_ASSERT(expr) #define STB_IMAGE_IMPLEMENTATION #include <3rdparty/stb/stb_image.h> @@ -77,7 +77,7 @@ namespace } } -namespace e2d { namespace images { namespace impl +namespace e2d::images::impl { bool try_load_image_stb(image& dst, const buffer& src) noexcept { v2u img_size; @@ -86,4 +86,4 @@ namespace e2d { namespace images { namespace impl return img_ptr && image_from_stb_description(dst, img_ptr, img_size, img_channels); } -}}} +} diff --git a/sources/enduro2d/utils/image_impl/image_writer_dds.cpp b/sources/enduro2d/utils/image_impl/image_writer_dds.cpp index 33e025f8..e8ec7e2e 100644 --- a/sources/enduro2d/utils/image_impl/image_writer_dds.cpp +++ b/sources/enduro2d/utils/image_impl/image_writer_dds.cpp @@ -27,7 +27,7 @@ namespace } } -namespace e2d { namespace images { namespace impl +namespace e2d::images::impl { bool try_save_image_dds(const image& src, buffer& dst) noexcept { E2D_UNUSED(src, dst); @@ -37,4 +37,4 @@ namespace e2d { namespace images { namespace impl } return false; } -}}} +} diff --git a/sources/enduro2d/utils/image_impl/image_writer_pvr.cpp b/sources/enduro2d/utils/image_impl/image_writer_pvr.cpp index cc271e58..011190a6 100644 --- a/sources/enduro2d/utils/image_impl/image_writer_pvr.cpp +++ b/sources/enduro2d/utils/image_impl/image_writer_pvr.cpp @@ -33,7 +33,7 @@ namespace } } -namespace e2d { namespace images { namespace impl +namespace e2d::images::impl { bool try_save_image_pvr(const image& src, buffer& dst) noexcept { E2D_UNUSED(src, dst); @@ -43,4 +43,4 @@ namespace e2d { namespace images { namespace impl } return false; } -}}} +} diff --git a/sources/enduro2d/utils/image_impl/image_writer_stb.cpp b/sources/enduro2d/utils/image_impl/image_writer_stb.cpp index 2cffa5fa..6fdb258b 100644 --- a/sources/enduro2d/utils/image_impl/image_writer_stb.cpp +++ b/sources/enduro2d/utils/image_impl/image_writer_stb.cpp @@ -8,11 +8,11 @@ #define STBI_WRITE_NO_STDIO -#define STBIW_FREE(ptr) std::free(ptr) -#define STBIW_MALLOC(size) std::malloc(size) +#define STBIW_FREE(ptr) std::free(ptr) +#define STBIW_MALLOC(size) std::malloc(size) #define STBIW_REALLOC(ptr,nsize) std::realloc(ptr, nsize) -#define STBIW_ASSERT(expr) E2D_ASSERT(expr) +#define STBIW_ASSERT(expr) E2D_ASSERT(expr) #define STB_IMAGE_WRITE_IMPLEMENTATION #include <3rdparty/stb/stb_image_write.h> @@ -41,7 +41,7 @@ namespace } } -namespace e2d { namespace images { namespace impl +namespace e2d::images::impl { bool try_save_image_jpg(const image& src, buffer& dst) noexcept { int img_w = math::numeric_cast(src.size().x); @@ -96,4 +96,4 @@ namespace e2d { namespace images { namespace impl } return false; } -}}} +} diff --git a/sources/enduro2d/utils/json_utils.cpp b/sources/enduro2d/utils/json_utils.cpp index d55a2ee6..2fe767b6 100644 --- a/sources/enduro2d/utils/json_utils.cpp +++ b/sources/enduro2d/utils/json_utils.cpp @@ -638,7 +638,7 @@ namespace } } -namespace e2d { namespace json_utils +namespace e2d::json_utils { void add_common_schema_definitions(rapidjson::Document& schema) { schema.AddMember( @@ -648,9 +648,9 @@ namespace e2d { namespace json_utils schema.GetAllocator()).Move(), schema.GetAllocator()); } -}} +} -namespace e2d { namespace json_utils +namespace e2d::json_utils { bool try_parse_value(const rapidjson::Value& root, v2i& v) noexcept { v2i tv; @@ -868,10 +868,10 @@ namespace e2d { namespace json_utils } try { s = make_utf8(root.GetString()); + return true; } catch (...) { return false; } - return true; } bool try_parse_value(const rapidjson::Value& root, wstr& s) noexcept { @@ -880,10 +880,10 @@ namespace e2d { namespace json_utils } try { s = make_wide(root.GetString()); + return true; } catch (...) { return false; } - return true; } bool try_parse_value(const rapidjson::Value& root, str16& s) noexcept { @@ -892,10 +892,10 @@ namespace e2d { namespace json_utils } try { s = make_utf16(root.GetString()); + return true; } catch (...) { return false; } - return true; } bool try_parse_value(const rapidjson::Value& root, str32& s) noexcept { @@ -904,10 +904,10 @@ namespace e2d { namespace json_utils } try { s = make_utf32(root.GetString()); + return true; } catch (...) { return false; } - return true; } bool try_parse_value(const rapidjson::Value& root, str_hash& s) noexcept { @@ -916,9 +916,9 @@ namespace e2d { namespace json_utils } try { s = make_hash(root.GetString()); + return true; } catch (...) { return false; } - return true; } -}} +} diff --git a/sources/enduro2d/utils/mesh.cpp b/sources/enduro2d/utils/mesh.cpp index 5950b88d..393447aa 100644 --- a/sources/enduro2d/utils/mesh.cpp +++ b/sources/enduro2d/utils/mesh.cpp @@ -295,7 +295,7 @@ namespace e2d } } -namespace e2d { namespace meshes +namespace e2d::meshes { bool try_load_mesh( mesh& dst, @@ -312,4 +312,4 @@ namespace e2d { namespace meshes return streams::try_read_tail(file_data, src) && try_load_mesh(dst, file_data); } -}} +} diff --git a/sources/enduro2d/utils/mesh_impl/mesh_impl.hpp b/sources/enduro2d/utils/mesh_impl/mesh_impl.hpp index 8563b410..2b93aeb5 100644 --- a/sources/enduro2d/utils/mesh_impl/mesh_impl.hpp +++ b/sources/enduro2d/utils/mesh_impl/mesh_impl.hpp @@ -9,7 +9,7 @@ #include #include -namespace e2d { namespace meshes { namespace impl +namespace e2d::meshes::impl { bool try_load_mesh_e2d(mesh& dst, const buffer& src) noexcept; -}}} +} diff --git a/sources/enduro2d/utils/mesh_impl/mesh_reader_e2d.cpp b/sources/enduro2d/utils/mesh_impl/mesh_reader_e2d.cpp index d6217aee..be9d5fe7 100644 --- a/sources/enduro2d/utils/mesh_impl/mesh_reader_e2d.cpp +++ b/sources/enduro2d/utils/mesh_impl/mesh_reader_e2d.cpp @@ -112,7 +112,7 @@ namespace } } -namespace e2d { namespace meshes { namespace impl +namespace e2d::meshes::impl { bool try_load_mesh_e2d(mesh& dst, const buffer& src) noexcept { try { @@ -121,8 +121,7 @@ namespace e2d { namespace meshes { namespace impl && check_signature(stream) && load_mesh(dst, stream); } catch (...) { - // nothing + return false; } - return false; } -}}} +} diff --git a/sources/enduro2d/utils/path.cpp b/sources/enduro2d/utils/path.cpp index 9cf9d264..df1a0923 100644 --- a/sources/enduro2d/utils/path.cpp +++ b/sources/enduro2d/utils/path.cpp @@ -37,7 +37,7 @@ namespace } } -namespace e2d { namespace path +namespace e2d::path { str combine(str_view lhs, str_view rhs) { if ( lhs.empty() || is_absolute(rhs) ) { @@ -132,4 +132,4 @@ namespace e2d { namespace path bool is_relative(str_view path) noexcept { return !is_absolute(path); } -}} +} diff --git a/sources/enduro2d/utils/shape.cpp b/sources/enduro2d/utils/shape.cpp index a16525ab..baf4958c 100644 --- a/sources/enduro2d/utils/shape.cpp +++ b/sources/enduro2d/utils/shape.cpp @@ -220,7 +220,7 @@ namespace e2d } } -namespace e2d { namespace shapes +namespace e2d::shapes { bool try_load_shape( shape& dst, @@ -237,4 +237,4 @@ namespace e2d { namespace shapes return streams::try_read_tail(file_data, src) && try_load_shape(dst, file_data); } -}} +} diff --git a/sources/enduro2d/utils/shape_impl/shape_impl.hpp b/sources/enduro2d/utils/shape_impl/shape_impl.hpp index b3016927..e5e4affa 100644 --- a/sources/enduro2d/utils/shape_impl/shape_impl.hpp +++ b/sources/enduro2d/utils/shape_impl/shape_impl.hpp @@ -9,7 +9,7 @@ #include #include -namespace e2d { namespace shapes { namespace impl +namespace e2d::shapes::impl { bool try_load_shape_e2d(shape& dst, const buffer& src) noexcept; -}}} +} diff --git a/sources/enduro2d/utils/shape_impl/shape_reader_e2d.cpp b/sources/enduro2d/utils/shape_impl/shape_reader_e2d.cpp index c6f85a0a..ae9e8b63 100644 --- a/sources/enduro2d/utils/shape_impl/shape_reader_e2d.cpp +++ b/sources/enduro2d/utils/shape_impl/shape_reader_e2d.cpp @@ -94,7 +94,7 @@ namespace } } -namespace e2d { namespace shapes { namespace impl +namespace e2d::shapes::impl { bool try_load_shape_e2d(shape& dst, const buffer& src) noexcept { try { @@ -103,8 +103,7 @@ namespace e2d { namespace shapes { namespace impl && check_signature(stream) && load_shape(dst, stream); } catch (...) { - // nothing + return false; } - return false; } -}}} +} diff --git a/sources/enduro2d/utils/streams.cpp b/sources/enduro2d/utils/streams.cpp index 91baa1b8..820e10b8 100644 --- a/sources/enduro2d/utils/streams.cpp +++ b/sources/enduro2d/utils/streams.cpp @@ -211,7 +211,7 @@ namespace e2d } } -namespace e2d { namespace streams +namespace e2d::streams { bool try_read_tail(str& dst, const input_stream_uptr& stream) noexcept { return stream @@ -244,4 +244,4 @@ namespace e2d { namespace streams .success() : false; } -}} +} diff --git a/sources/enduro2d/utils/strings.cpp b/sources/enduro2d/utils/strings.cpp index 812d3b31..b3152aaa 100644 --- a/sources/enduro2d/utils/strings.cpp +++ b/sources/enduro2d/utils/strings.cpp @@ -260,7 +260,7 @@ namespace e2d } } -namespace e2d { namespace strings +namespace e2d::strings { namespace impl { @@ -337,4 +337,4 @@ namespace e2d { namespace strings return input.length() >= test.length() && 0 == input.compare(input.length() - test.length(), test.length(), test); } -}} +} diff --git a/sources/enduro2d/utils/url.cpp b/sources/enduro2d/utils/url.cpp index c4e37250..b44139ef 100644 --- a/sources/enduro2d/utils/url.cpp +++ b/sources/enduro2d/utils/url.cpp @@ -72,8 +72,8 @@ namespace e2d assign(schemepath); } - url::url(str_view scheme, str_view path) noexcept { - assign(scheme, path); + url::url(str scheme, str path) noexcept { + assign(std::move(scheme), std::move(path)); } url& url::assign(url&& other) noexcept { @@ -96,9 +96,9 @@ namespace e2d return assign(std::move(nscheme), std::move(npath)); } - url& url::assign(str_view scheme, str_view path) noexcept { - scheme_ = scheme; - path_ = path; + url& url::assign(str scheme, str path) noexcept { + scheme_ = std::move(scheme); + path_ = std::move(path); return *this; } diff --git a/sources/enduro2d/utils/xml_utils.cpp b/sources/enduro2d/utils/xml_utils.cpp index 86ca9132..dd921661 100644 --- a/sources/enduro2d/utils/xml_utils.cpp +++ b/sources/enduro2d/utils/xml_utils.cpp @@ -11,6 +11,6 @@ namespace using namespace e2d; } -namespace e2d { namespace xml_utils +namespace e2d::xml_utils { -}} +} diff --git a/untests/sources/untests_core/vfs.cpp b/untests/sources/untests_core/vfs.cpp index 0cfd8d91..8309297f 100644 --- a/untests/sources/untests_core/vfs.cpp +++ b/untests/sources/untests_core/vfs.cpp @@ -8,8 +8,8 @@ using namespace e2d; TEST_CASE("vfs"){ - const str_view file_path = "vfs_file_name"; - const str_view nofile_path = "vfs_file_name2"; + const str file_path = "vfs_file_name"; + const str nofile_path = "vfs_file_name2"; { REQUIRE(filesystem::remove_file(nofile_path)); REQUIRE(filesystem::create_file(file_path));