linkahead/utility.h
-
namespace linkahead
-
namespace utility
Functions
-
template<typename Enum>
auto getEnumNameFromValue(Enum v) -> std::string Get the name of the enum value. May be useful for higher-order LinkAhead clients.
-
template<>
auto getEnumNameFromValue<linkahead::entity::AtomicDataType>(linkahead::entity::AtomicDataType v) -> std::string
-
template<>
auto getEnumNameFromValue<linkahead::entity::Importance>(linkahead::entity::Importance v) -> std::string
-
template<>
auto getEnumNameFromValue<linkahead::entity::Role>(linkahead::entity::Role v) -> std::string
-
template<typename Enum>
auto getEnumValueFromName(const std::string &name) -> Enum Get the enum value from a string.
@detail May be useful for higher-order LinkAhead clients and only makes sense if specialized.
-
template<>
auto getEnumValueFromName<linkahead::entity::AtomicDataType>(const std::string &name) -> linkahead::entity::AtomicDataType
-
template<>
auto getEnumValueFromName<linkahead::entity::Importance>(const std::string &name) -> linkahead::entity::Importance
-
template<>
auto getEnumValueFromName<linkahead::entity::Role>(const std::string &name) -> linkahead::entity::Role
-
auto load_string_file(const path &file_path) -> std::string
Read a text file into a string and return the file’s content.
-
inline auto get_env_fallback(const char *key, const char *fallback) -> const char*
Return the environment variable KEY, or FALLBACK if it does not exist.
-
inline auto get_env_fallback(const std::string &key, const std::string &fallback) -> const std::string
Return the value of an environment variable or - if undefined - the fallback value.
-
auto load_json_file(const path &json_file) -> JsonValue
Load json object from a json file and return it.
-
auto base64_encode(const std::string &plain) -> std::string
Encode string as base64.
-
inline auto get_home_directory() -> const path
-
class JsonValue
- #include <utility.h>
JsonValue is a thin wrapper around a implementation specific third-party json object (e.g. boost).
Public Functions
-
inline JsonValue()
Default Constructor.
Creates an empty wrapper where
wrapped
is nullptr.
-
JsonValue(void *wrapped)
Constructor.
By calling this constructor the ownership of the
wrapped
parameter is transferred to this object.
-
~JsonValue()
Destructor.
Also deletes the
wrapped
object.
-
auto operator=(const JsonValue &other) -> JsonValue&
Copy Assigment.
Also copies the
wrapped
object.
-
auto operator=(JsonValue &&other) noexcept -> JsonValue&
Move Assigment.
Also moves the
wrapped
object.
-
auto Reset() -> void
Reset this object.
Also deletes
wrapped
sets it to the nullptr.
Public Members
-
std::shared_ptr<void> wrapped
An object which represents a JSON value. The object’s class is an implementation detail.
-
inline JsonValue()
-
template<typename Enum>
-
namespace utility