Snipper¶
-
namespace
tnt
-
class
Snipper
¶ - #include <Snipper.hpp>
A basic file watcher. Useful for asset hotloading and other stuff.
The file that should be watched.
Watch
name
to check if it has been modified.-
constexpr std::size_t
msvc_size
= {96}¶
-
constexpr std::size_t
other_size
= {88}¶
-
std::conditional_t<is_msvc_v, pimpl<impl, msvc_size, 8>, pimpl<impl, other_size, 8>>
data
¶
-
void
watchFile
(std::string_view name)¶
-
template<detail::callable<> Func> void onModify (std::string_view file, Func &&func) noexcept(detail::safe_callable< Func >)
Call a function if
file
has been modified.- Note
The file watcher silently adds
file
to it’s watch list if the file isn’t there already.- Note
The function is
noexcept
only if Func() isnoexcept
.- Template Parameters
Func
: A generic function representation.
- Parameters
file
: The file that should be checked if it is modified or not.func
: The function that should be called iffile
has been modified.
-
void
unwatchFile
(std::string_view filename) noexcept¶ Stops watching a file if it was already watching it.
- Note
If the file wasn’t being watched, the file watcher doesn’r report anything.
-
bool
isModified
(std::string_view file) noexcept¶ Check if
file
has been modified since the last check.- Return
bool
- Parameters
file
: The name of the file to check.
-
constexpr std::size_t
-
namespace
detail
¶ Variables
-
template<typename T, typename... Args> concept callable = std::is_invocable_v<T, Args...>
-
template<typename T, typename... Args> concept safe_callable = std::is_nothrow_invocable_v<T, Args...>
-
-
class