Unravel Engine C++ Reference
Loading...
Searching...
No Matches
script.cpp
Go to the documentation of this file.
1#include "script.hpp"
2
3#include <fstream>
7
8namespace unravel
9{
10
12{
13 entt::meta_factory<script>{}
14 .type("script"_hs)
16 entt::attribute{"name", "script"},
17 entt::attribute{"pretty_name", "Script"},
18 });
19}
20
22{
23
24}
27
29{
30
31}
34
35void save_to_file(const std::string& absolute_path, const script::sptr& obj)
36{
37 std::ofstream stream(absolute_path);
38 if(stream.good())
39 {
40 auto ar = ser20::create_oarchive_associative(stream);
41 try_save(ar, ser20::make_nvp("script", *obj));
42 }
43}
44
45void save_to_file_bin(const std::string& absolute_path, const script::sptr& obj)
46{
47 std::ofstream stream(absolute_path, std::ios::binary);
48 if(stream.good())
49 {
50 ser20::oarchive_binary_t ar(stream);
51 try_save(ar, ser20::make_nvp("script", *obj));
52 }
53}
54
55void load_from_file(const std::string& absolute_path, script::sptr& obj)
56{
57 fs::file_istream input(absolute_path);
58 if(!input.is_open())
59 {
60 return;
61 }
63 try_load(ar, ser20::make_nvp("script", *obj));
64}
65
66void load_from_file_bin(const std::string& absolute_path, script::sptr& obj)
67{
68 fs::file_istream input(absolute_path, std::ios::binary);
69 if(!input.is_open())
70 {
71 return;
72 }
74 try_load(ar, ser20::make_nvp("script", *obj));
75}
76} // namespace unravel
stdio-backed input stream. Accepts std::ios open flags (e.g. std::ios::binary) when opening a
attributes::value_type attribute
Definition reflection.h:19
std::map< std::string, meta_any > attributes
Definition reflection.h:18
auto create_oarchive_associative(std::ostream &stream)
BinaryInputArchive iarchive_binary_t
auto create_iarchive_associative(std::istream &stream)
simd::JSONOutputArchive oarchive_associative_t
BinaryOutputArchive oarchive_binary_t
simd::JSONInputArchive iarchive_associative_t
void save_to_file_bin(const std::string &absolute_path, const animation_clip &obj)
void load_from_file(const std::string &absolute_path, animation_clip &obj)
void save_to_file(const std::string &absolute_path, const animation_clip &obj)
void load_from_file_bin(const std::string &absolute_path, animation_clip &obj)
#define REFLECT(cls)
Definition reflection.h:149
#define SAVE_INSTANTIATE(cls, Archive)
#define LOAD(cls)
auto try_save(Archive &ar, ser20::NameValuePair< T > &&t, const hpp::source_location &loc=hpp::source_location::current()) -> bool
#define LOAD_INSTANTIATE(cls, Archive)
#define SAVE(cls)
auto try_load(Archive &ar, ser20::NameValuePair< T > &&t, const hpp::source_location &loc=hpp::source_location::current()) -> bool
std::shared_ptr< script > sptr
Shared pointer to a physics material.
Definition script.h:13