#include <rll/savefile.h>
template <typename F, typename T, typename = std:: enable_if_t<is_ serializable<T, F>::value>>
savefile class
Base classes
- class filedevice
Public static variables
- static auto write_permissions constexpr
Public static functions
-
static auto read_from(std::
filesystem:: path const& path) → std:: string -
static auto try_read_from(std::
filesystem:: path const& path) → result<std:: string> noexcept -
static auto try_write_to(std::
filesystem:: path const& path, std:: string_view content) → result noexcept -
static void write_to(std::
filesystem:: path const& path, std:: string_view content) noexcept(…)
Constructors, destructors, conversion operators
- operator bool() const explicit noexcept
- Returns whether the savefile is valid or not.
-
savefile(std::
filesystem:: path path) explicit -
savefile(std::
string_view filename, std:: filesystem:: path const& folder) explicit - savefile(savefile const&) defaulted
- savefile(savefile&&) defaulted
- ~savefile() virtual noexcept
- Closes the savefile.
Public functions
-
auto backing_path() const → std::
filesystem:: path const& - Path to the savefile's backing file.
- auto exists() const → bool
- auto has_backup() const → bool noexcept
- auto invalidate() const → result noexcept
- Swaps the current savefile with its backup.
- auto is_regular_file() const → bool
- auto load() → result noexcept
- auto operator()() const → T const&
- Constant reference to the current values of the savefile.
- auto operator()() → T&
- Mutable reference to the current values of the savefile.
- auto operator=(savefile const&) → savefile& defaulted
- Default copy assignment.
- auto operator=(savefile&&) → savefile& defaulted
- Default move assignment.
-
auto path() const → std::
filesystem:: path const& -
auto read() const → std::
string - auto save() const → result
-
auto suffixed_path(std::
string_view const suffix) const → std:: filesystem:: path - auto try_commit() const → result noexcept
- Removes previous backup and replaces it with the current one.
-
auto try_read() const → result<std::
string> noexcept -
auto try_write(std::
string_view content) const → result noexcept - auto valid() const → bool
- Returns whether savefile is valid or not.
- auto values() const → T const&
- Constant reference to the current values of savefile.
- auto values_mut() → T&
- Mutable reference to the current values of savefile.
-
void write(std::
string_view content) const noexcept(…)
Function documentation
#include <rll/io/filedevice.h>
template <typename F, typename T, typename _3>
static std:: string rll::savefile::read_from(std:: filesystem:: path const& path)
#include <rll/io/filedevice.h>
template <typename F, typename T, typename _3>
static result<std:: string> rll::savefile::try_read_from(std:: filesystem:: path const& path) noexcept
#include <rll/io/filedevice.h>
template <typename F, typename T, typename _3>
static result rll::savefile::try_write_to(std:: filesystem:: path const& path,
std:: string_view content) noexcept
#include <rll/io/filedevice.h>
template <typename F, typename T, typename _3>
static void rll::savefile::write_to(std:: filesystem:: path const& path,
std:: string_view content) noexcept(…)
template <typename F, typename T, typename _3>
rll::savefile::operator bool() const explicit noexcept
Returns whether the savefile is valid or not.
template <typename F, typename T, typename _3>
rll::savefile::~savefile() virtual noexcept
Closes the savefile.
File will be saved automatically on closing.
#include <rll/io/filedevice.h>
template <typename F, typename T, typename _3>
bool rll::savefile::exists() const
#include <rll/io/filedevice.h>
template <typename F, typename T, typename _3>
bool rll::savefile::is_regular_file() const
template <typename F, typename T, typename _3>
T const& rll::savefile::operator()() const
Constant reference to the current values of the savefile.
template <typename F, typename T, typename _3>
T& rll::savefile::operator()()
Mutable reference to the current values of the savefile.