Class basic_resource¶
Defined in File resource.hpp
Class Documentation¶
-
class
legion::core::filesystem
::
basic_resource
¶ A handle for a basic resource type from which elements can serialize and deserialize from ideal for storing elements loaded from disk.
Public Functions
-
inline explicit
basic_resource
(std::nullptr_t placeholder)¶ Constructor that keeps the container empty.
- Parameters
[in] placeholder
: Must be nullptr, used to signal that the resource should be kept empty.
-
inline explicit
basic_resource
(byte_vec v)¶ Constructs a basic resource from a legion::core::byte_vec.
- Parameters
[in] v
: The resource from which the resource is created (copy operation/move).
-
inline explicit
basic_resource
(std::string_view v)¶ Constructs a basic resource from a std::string.
- Parameters
[in] v
: The resource from which the resource is created (copy-assign operation)
-
basic_resource
(const basic_resource &other) = default¶
-
basic_resource
(basic_resource &&other) noexcept = default¶
-
basic_resource &
operator=
(const basic_resource &other) = default¶
-
basic_resource &
operator=
(basic_resource &&other) noexcept = default¶
-
inline auto
begin
() noexcept¶ Gets an iterator to the first element of the container.
- Return
iterator to first element
-
inline auto
begin
() const noexcept¶ Gets an iterator to the first element of the container.
- Return
iterator to first element
-
inline auto
end
() noexcept¶ Gets an iterator to the last element + 1 of the container.
- Return
iterator to first element
-
inline auto
end
() const noexcept¶ Gets an iterator to the last element + 1 of the container.
- Return
iterator to first element
-
inline auto
data
() noexcept¶ Gets a pointer to the data of the container.
- Return
byte* to raw data
-
inline auto
data
() const noexcept¶ Gets a pointer to the data of the container.
- Return
byte* to raw data
-
inline auto
size
() const noexcept¶ Gets the size of the container.
- Return
size_t to the size of container
-
inline auto
empty
() const noexcept¶ Checks if the container is empty.
- Return
bool, true when empty
-
inline void
clear
() noexcept¶
-
inline const byte_vec &
get
() const noexcept¶ Gets the container element.
- Return
legion::core::byte_vec
-
inline basic_resource &
operator=
(const std::string_view &value)¶ String assignment operator.
- Return
basic_resource& *this
- Parameters
value
: The string you want to assign to the byte_vec.
-
inline std::string
to_string
() const¶ String conversion.
- Return
std::string, The container converted to const char *.
-
template<typename
T
, class ...Args
>
Tto
(Args&&... args) const¶ Generic conversion to T.
- Note
Tries to convert a basic resource, for this to work T must implement a static method with signature T::from_resource(basic_resource&,const T&) and must be, A: trivially constructable or B: constructable via Args&&… and must be move or copy assignable.
- Return
T Created from this resources data.
- Template Parameters
T
: The class you want to convert to.
- Parameters
args
: Additional construction parameters required to create T.
-
template<class
T
>
voidfrom
(const T &v)¶ Generic conversion from T.
- Note
Tries to convert T to a basic resource, for this to work T must implement a static method with signature T::to_resource(basic_resource*).
- Parameters
v
: The T you want to convert into a basic_resource.
-
inline explicit