OdbDesign
OdbDesign ODB++ Parser - C++ library, gRPC/REST server, CLI, tests
 
Loading...
Searching...
No Matches
JsonCrowReturnable.h
Go to the documentation of this file.
1#pragma once
2
3#include "IJsonable.h"
4#include "CrowReturnable.h"
5#include <string>
6
7namespace Utils
8{
9 template<typename TJsonable>
10 class JsonCrowReturnable : public Utils::CrowReturnable<TJsonable>
11 {
12 public:
13 JsonCrowReturnable(const TJsonable& odbObject)
14 : Utils::CrowReturnable<TJsonable>(odbObject, CONTENT_TYPE)
15 {}
16
17 inline constexpr static const char* CONTENT_TYPE = "application/json";
18
19 protected:
20 std::string to_string() const override;
21
22 // TJsonable MUST derive from IJsonConvertable (must use this until template type contraints support is added)
23 static_assert(std::is_base_of<Utils::IJsonable, TJsonable>::value, "template parameter type TJsonable must derive from IJsonConvertable interface class");
24
25 };
26
27 template<typename TJsonable>
29 {
30 return this->m_t.to_json();
31 }
32}
static constexpr const char * CONTENT_TYPE
JsonCrowReturnable(const TJsonable &odbObject)
std::string to_string() const override