Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ find_package(OpenSSL 1.0.0 REQUIRED)
find_package(PkgConfig REQUIRED)
find_package(spdlog REQUIRED)
find_package(Threads REQUIRED)
find_package(nlohmann_json REQUIRED)
find_package(OpenMP)
find_package(IBVerbs)
find_package(RDMACM)
Expand Down
32 changes: 32 additions & 0 deletions common/include/villas/json.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#pragma once

#include <fmt/ostream.h>
#include <nlohmann/json_fwd.hpp>

#include <villas/fs.hpp>

namespace villas {

using Json = nlohmann::json;
using JsonPointer = nlohmann::json_pointer<std::string>;

// forward declaration for villas/jansson.hpp compatibility header
class JanssonPtr;
void to_json(Json &json, JanssonPtr const &jansson);
void from_json(Json const &json, JanssonPtr &jansson);

// load a configuration file
Json load_config_deprecated(fs::path const &path, bool resolve_inc,
bool resolve_env);

}; // namespace villas

// forward declaration for libjansson's json_t
struct json_t;
void to_json(villas::Json &json, json_t const *jansson);

template <> // format config_json using operator<<
struct fmt::formatter<villas::Json> : ostream_formatter {};

template <> // format config_json_pointer using operator<<
struct fmt::formatter<villas::JsonPointer> : ostream_formatter {};
4 changes: 4 additions & 0 deletions common/include/villas/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ template <class... Ts> struct overloaded : Ts... {
// Explicit deduction guide (not needed as of C++20)
template <class... Ts> overloaded(Ts...) -> overloaded<Ts...>;

// glob-style filesystem pattern matching
std::vector<fs::path> glob(fs::path const &pattern,
std::span<const fs::path> searchDirectories);

void write_to_file(std::string data, const fs::path file);

namespace base64 {
Expand Down
2 changes: 2 additions & 0 deletions common/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ add_library(villas-common SHARED
cpuset.cpp
dsp/pid.cpp
hist.cpp
json.cpp
kernel/kernel.cpp
kernel/rt.cpp
list.cpp
Expand Down Expand Up @@ -55,6 +56,7 @@ target_include_directories(villas-common PUBLIC
)

target_link_libraries(villas-common PUBLIC
nlohmann_json::nlohmann_json
PkgConfig::JANSSON
PkgConfig::UUID
${OPENSSL_LIBRARIES}
Expand Down
Loading
Loading