Zserio C++ runtime library  1.3.0
Built for Zserio 2.18.0
JsonEncoder.h
Go to the documentation of this file.
1 #ifndef ZSERIO_JSON_ENCODER_H_INC
2 #define ZSERIO_JSON_ENCODER_H_INC
3 
4 #include <type_traits>
5 
7 #include "zserio/String.h"
9 #include "zserio/StringView.h"
10 #include "zserio/Types.h"
11 #include "zserio/Vector.h"
12 
13 namespace zserio
14 {
15 
20 {
21 public:
27  static void encodeNull(std::ostream& stream);
28 
35  static void encodeBool(std::ostream& stream, bool value);
36 
43  template <typename T>
44  static void encodeIntegral(std::ostream& stream, T value);
45 
52  static void encodeFloatingPoint(std::ostream& stream, double value);
53 
62  static void encodeString(std::ostream& stream, StringView value);
63 };
64 
65 template <typename T>
66 void JsonEncoder::encodeIntegral(std::ostream& stream, T value)
67 {
68  using U = typename std::conditional<std::is_signed<T>::value, int64_t, uint64_t>::type;
69  stream << static_cast<U>(value);
70 }
71 
72 } // namespace zserio
73 
74 #endif // ZSERIO_JSON_ENCODER_H_INC
static void encodeFloatingPoint(std::ostream &stream, double value)
Definition: JsonEncoder.cpp:21
static void encodeNull(std::ostream &stream)
Definition: JsonEncoder.cpp:11
static void encodeBool(std::ostream &stream, bool value)
Definition: JsonEncoder.cpp:16
static void encodeString(std::ostream &stream, StringView value)
Definition: JsonEncoder.cpp:51
static void encodeIntegral(std::ostream &stream, T value)
Definition: JsonEncoder.h:66