caosdb/utility.h

namespace caosdb
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 CaosDB clients.

template<>
auto getEnumNameFromValue<caosdb::entity::AtomicDataType>(caosdb::entity::AtomicDataType v) -> std::string
template<>
auto getEnumNameFromValue<caosdb::entity::Importance>(caosdb::entity::Importance v) -> std::string
template<>
auto getEnumNameFromValue<caosdb::entity::Role>(caosdb::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 CaosDB clients and only makes sense if specialized.

template<>
auto getEnumValueFromName<caosdb::entity::AtomicDataType>(const std::string &name) -> caosdb::entity::AtomicDataType
template<>
auto getEnumValueFromName<caosdb::entity::Importance>(const std::string &name) -> caosdb::entity::Importance
template<>
auto getEnumValueFromName<caosdb::entity::Role>(const std::string &name) -> caosdb::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.

JsonValue(const JsonValue &other)

Copy Constructor.

Also copies the wrapped object.

auto operator=(const JsonValue &other) -> JsonValue&

Copy Assigment.

Also copies the wrapped object.

JsonValue(JsonValue &&other) noexcept

Move Constructor.

Also moves 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.