OSSIA
Open Scenario System for Interactive Application
preset.hpp
1 #pragma once
2 
3 #include <ossia/detail/config.hpp>
4 
5 #include <ossia/detail/string_view.hpp>
6 #include <ossia/preset/exception.hpp>
7 
8 #include <fstream>
9 #include <functional>
10 #include <memory>
11 #include <regex>
12 #include <string>
13 
14 namespace ossia
15 {
16 namespace net
17 {
18 class device_base;
19 class node_base;
20 class parameter_base;
21 }
22 class value;
23 }
24 
25 namespace ossia::presets
26 {
27 using preset = std::vector<std::pair<std::string, ossia::value>>;
28 
29 using instance_functions = std::vector<
30  std::pair<std::regex, std::function<void(const ossia::net::node_base&)>>>;
31 
32 using preset_pair = std::pair<std::string, ossia::value>;
33 
34 OSSIA_EXPORT preset read_json(const std::string&, bool skip_first_level = true);
35 OSSIA_EXPORT std::string write_json(const std::string& devicename, const preset&);
36 
37 OSSIA_EXPORT std::string to_string(const preset&);
38 OSSIA_EXPORT preset from_string(const std::string_view& str);
39 
40 enum keep_arch_type
41 {
42  keep_arch_on,
43  keep_arch_off
44 };
45 
46 struct preset_save_options
47 {
48  bool save_get{false};
49  bool save_set{false};
50  bool save_bi{true};
51 };
52 
58 OSSIA_EXPORT std::string write_json(const ossia::net::device_base& deviceBase);
59 
65 OSSIA_EXPORT void write_file(std::string_view string, std::string_view filename);
66 
67 OSSIA_EXPORT const std::string read_file(const std::string& filename);
68 
76 OSSIA_EXPORT const std::string
77 make_json_preset(const ossia::net::node_base& node, preset_save_options = {});
78 
79 typedef void (*func_t)(ossia::net::node_base* n);
80 
88 OSSIA_EXPORT bool
89 apply_json(const std::string& json, ossia::net::node_base& node, func_t fn = nullptr);
90 
99 OSSIA_EXPORT void
100 apply_preset(const std::string& kiss, ossia::net::node_base& node, func_t fn = nullptr);
101 
102 // DEPRECATED keep it for backward compatibility
103 OSSIA_EXPORT void apply_preset(
104  ossia::net::node_base&, const presets::preset&, keep_arch_type t = keep_arch_on,
105  presets::instance_functions = {}, bool allow_nonterminal = false,
106  bool remove_first = true);
107 
108 OSSIA_EXPORT presets::preset
109 make_preset(ossia::net::node_base&, preset_save_options = {});
110 
111 OSSIA_EXPORT ossia::net::node_base* get_node(ossia::net::node_base&, const std::string&);
112 
113 OSSIA_EXPORT std::string to_string(const ossia::net::device_base& ossiadev);
114 
115 } // namespace ossia
Root of a device tree.
Definition: ossia/network/base/device.hpp:58
The node_base class.
Definition: network/base/node.hpp:48
Definition: git_info.h:7