GCC Code Coverage Report


Directory: cvmfs/
File: cvmfs/json_document.h
Date: 2026-03-22 02:40:38
Exec Total Coverage
Lines: 3 3 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 /**
2 * This file is part of the CernVM File System.
3 */
4
5 #ifndef CVMFS_JSON_DOCUMENT_H_
6 #define CVMFS_JSON_DOCUMENT_H_
7
8 #include <nlohmann/json.hpp>
9 #include <string>
10
11 #include "util/single_copy.h"
12
13 typedef nlohmann::json JSON;
14
15 static constexpr JSON::value_t JSON_NULL = JSON::value_t::null;
16 static constexpr JSON::value_t JSON_OBJECT = JSON::value_t::object;
17 static constexpr JSON::value_t JSON_ARRAY = JSON::value_t::array;
18 static constexpr JSON::value_t JSON_STRING = JSON::value_t::string;
19 static constexpr JSON::value_t JSON_INT = JSON::value_t::number_integer;
20 static constexpr JSON::value_t JSON_FLOAT = JSON::value_t::number_float;
21 static constexpr JSON::value_t JSON_BOOL = JSON::value_t::boolean;
22
23 class JsonDocument : SingleCopy {
24 public:
25 static JsonDocument *Create(const std::string &text);
26 1007 ~JsonDocument() { }
27
28 std::string PrintCanonical();
29
30 1594 inline const JSON *root() const { return &root_; }
31 102 inline bool IsValid() const { return !root_.is_null(); }
32
33 static const JSON *SearchInObject(const JSON *json_object,
34 const std::string &name,
35 const JSON::value_t type);
36
37 private:
38 JsonDocument();
39 bool Parse(const std::string &text);
40
41 JSON root_;
42 };
43
44 template<typename T>
45 bool GetFromJSON(const JSON *object, const std::string &name, T *value);
46
47 #endif // CVMFS_JSON_DOCUMENT_H_
48