28 virtual std::string
write()
const = 0;
33 virtual void read(
const std::string& source) = 0;
37 std::string
quoted(
const std::string& value);
40 std::string
unquoted(
const std::string& value);
47 template <
typename Type>
58 virtual std::string
write()
const override {
64 virtual void read(
const std::string& source)
override {
65 std::stringstream ss(
trim(source));
68 if (!ss || !ss.eof()) {
92 virtual std::string
write()
const override {
98 virtual void read(
const std::string& source)
override {
99 std::stringstream ss(source);
100 ss >> value[
X] >> value[
Y] >> value[
Z];
122 virtual std::string
write()
const override {
123 std::stringstream ss;
128 virtual void read(
const std::string& source)
override {
129 std::stringstream ss(source);
131 ss >> lower >> upper;
154 virtual std::string
write()
const override {
158 virtual void read(
const std::string& source)
override {
162 const std::string&
get()
const {
181 virtual std::string
write()
const override {
185 virtual void read(
const std::string& source)
override {
210 template <
typename Type>
211 void set(
const std::string& name,
const Type& value) {
219 template <
typename Type>
220 Type
get(
const std::string& name) {
231 template <
typename Type>
233 auto value = entries.
tryGet(name);
238 reader.
read(value.value());
263 void write(
const std::string& padding, std::stringstream& source);
266 void read(std::stringstream& source);
292 void read(std::stringstream& source);
std::string unquoted(const std::string &value)
Removes leading and trailing quote from a string.
Exception ConfigException
std::string quoted(const std::string &value)
Helper function wrapping a string by quotes.
Generic wrappers of lambdas, functors and other callables.
uint32_t Size
Integral type used to index arrays (by default).
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
#define NAMESPACE_SPH_END
const NothingType NOTHING
Object representing a path on a filesystem, similar to std::filesystem::path in c++17.
std::string trim(const std::string &s)
Removes all leading and trailing spaces from a string.
Key-value associative container.
Basic vector algebra. Computations are accelerated using SIMD.
Represents a single node in the hierarchy written into config file.
void enumerateChildren(Function< void(std::string name, ConfigNode &node)> func)
Calls the provided functor for each child node.
Optional< Type > tryGet(const std::string &name)
Tries to return a value stored in the node.
Type get(const std::string &name)
Returns a value stored in the node.
Size size() const
Returns the number of entries stored in the node.
bool contains(const std::string &name)
Checks if the node contains an entry of given name.
void set(const std::string &name, const Type &value)
Adds a new value into the node.
SharedPtr< ConfigNode > getChild(const std::string &name)
Returns a child node.
SharedPtr< ConfigNode > addChild(const std::string &name)
Adds a new child node to this node.
virtual void read(const std::string &source) override
Reads the value from string and stores it internally.
virtual std::string write() const override
Writes the value into a string.
ConfigValue(const Interval &value)
ConfigValue(const Path &value)
virtual std::string write() const override
Writes the value into a string.
virtual void read(const std::string &source) override
Reads the value from string and stores it internally.
ConfigValue(const Vector &value)
virtual void read(const std::string &source) override
Reads the value from string and stores it internally.
virtual std::string write() const override
Writes the value into a string.
const std::string & get() const
virtual std::string write() const override
Writes the value into a string.
virtual void read(const std::string &source) override
Reads the value from string and stores it internally.
ConfigValue(const std::string &value)
Generic implementation of IConfigValue, using std::stringstream for the (de)serialization.
virtual void read(const std::string &source) override
Reads the value from string and stores it internally.
ConfigValue(const Type &value)
virtual std::string write() const override
Writes the value into a string.
Provides functionality for reading and writing configuration files.
void read(std::stringstream &source)
Deserializes the input string stream into nodes.
SharedPtr< ConfigNode > addNode(const std::string &name)
Adds a new node to the config.
SharedPtr< ConfigNode > getNode(const std::string &name)
Returns a node with given name.
void save(const Path &path)
Serializes all nodes in the config into a file.
SharedPtr< ConfigNode > tryGetNode(const std::string &name)
Returns a node with given name or nullptr if no such node exists.
std::string write()
Serializes all nodes in the config into a string.
void load(const Path &path)
Reads content of given file and deserializes the config from the loaded string.
void enumerate(Function< void(std::string, ConfigNode &)> func)
Calls the provided functor for all nodes in the config.
Interface for value written to the config file.
virtual void read(const std::string &source)=0
Reads the value from string and stores it internally.
virtual std::string write() const =0
Writes the value into a string.
Object representing a 1D interval of real numbers.
Wrapper of type value of which may or may not be present.
INLINE Type & value()
Returns the reference to the stored value.
Object representing a path on a filesystem.
std::string native() const
Returns the native version of the path.
INLINE bool contains(const TKey &key) const
Returns true if the map contains element of given key.
INLINE TValue & insert(const TKey &key, const TValue &value)
Adds a new element into the map or sets new value of element with the same key.
INLINE Optional< TValue & > tryGet(const TKey &key)
Returns a reference to the value matching the given key, or NOTHING if no such value exists.
Overload of std::swap for Sph::Array.
Base class for all polymorphic objects.