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>
6
7namespace unravel
8{
9
11{
12 entt::meta_factory<script>{}
13 .type("script"_hs)
15 entt::attribute{"name", "script"},
16 entt::attribute{"pretty_name", "Script"},
17 });
18}
19
21{
22
23}
26
28{
29
30}
33
34void save_to_file(const std::string& absolute_path, const script::sptr& obj)
35{
36 std::ofstream stream(absolute_path);
37 if(stream.good())
38 {
39 auto ar = ser20::create_oarchive_associative(stream);
40 try_save(ar, ser20::make_nvp("script", *obj));
41 }
42}
43
44void save_to_file_bin(const std::string& absolute_path, const script::sptr& obj)
45{
46 std::ofstream stream(absolute_path, std::ios::binary);
47 if(stream.good())
48 {
49 ser20::oarchive_binary_t ar(stream);
50 try_save(ar, ser20::make_nvp("script", *obj));
51 }
52}
53
54void load_from_file(const std::string& absolute_path, script::sptr& obj)
55{
56 std::ifstream stream(absolute_path);
57 if(stream.good())
58 {
59 auto ar = ser20::create_iarchive_associative(stream);
60 try_load(ar, ser20::make_nvp("script", *obj));
61 }
62}
63
64void load_from_file_bin(const std::string& absolute_path, script::sptr& obj)
65{
66 std::ifstream stream(absolute_path, std::ios::binary);
67 if(stream.good())
68 {
69 ser20::iarchive_binary_t ar(stream);
70 try_load(ar, ser20::make_nvp("script", *obj));
71 }
72}
73} // namespace unravel
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:133
#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