Decentralised Art Server
High-performance C++ backend that exposes HTML interface and a secure REST API for managing Performative Transactions entities
 
Loading...
Searching...
No Matches
parser.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <string_view>
5
6#include <nlohmann/json.hpp>
7using json = nlohmann::json;
8
9#include <google/protobuf/util/json_util.h>
10
11#include "parse_error.hpp"
12
13namespace dcn::parse
14{
21
27 struct use_json_t{};
28
34 static constexpr use_protobuf_t use_protobuf{};
35
41 static constexpr use_json_t use_json{};
42
49 template<class T>
51
58 template<class T>
59 Result<T> parseFromJson(std::string json_str, use_protobuf_t);
60
67 template<class T>
69
76 template<class T>
78
79
80 template<class T>
81 Result<T> decodeBytes(const std::vector<uint8_t> & bytes);
82
83 // Parse decimal uint32 and reject malformed input.
84 Result<std::uint32_t> parseUint32Decimal(std::string_view value);
85}
Definition http.hpp:190
Result< json > parseToJson(T message, use_json_t)
Converts a T to a JSON object using JSON.
std::expected< T, ParseError > Result
Definition parse_error.hpp:26
Result< T > parseFromJson(json json, use_json_t)
Converts a JSON string to a T using JSON.
Result< T > decodeBytes(const std::vector< uint8_t > &bytes)
Result< std::uint32_t > parseUint32Decimal(std::string_view value)
Definition parser.cpp:7
nlohmann::json json
Definition parser.hpp:7
A tag type to indicate whether to use Protobuf or JSON for parsing.
Definition parser.hpp:27
A tag type to indicate whether to use Protobuf or JSON for parsing.
Definition parser.hpp:20