Zserio C++ runtime library  1.0.2
Built for Zserio 2.14.1
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/Vector.h"
11 
12 namespace zserio
13 {
14 
19 {
20 public:
26  static void encodeNull(std::ostream& stream);
27 
34  static void encodeBool(std::ostream& stream, bool value);
35 
42  template <typename T>
43  static void encodeIntegral(std::ostream& stream, T value);
44 
51  static void encodeFloatingPoint(std::ostream& stream, double value);
52 
61  static void encodeString(std::ostream& stream, StringView value);
62 };
63 
64 template <typename T>
65 void JsonEncoder::encodeIntegral(std::ostream& stream, T value)
66 {
67  using U = typename std::conditional<std::is_signed<T>::value, int64_t, uint64_t>::type;
68  stream << static_cast<U>(value);
69 }
70 
71 } // namespace zserio
72 
73 #endif // ZSERIO_JSON_ENCODER_H_INC
static void encodeFloatingPoint(std::ostream &stream, double value)
Definition: JsonEncoder.cpp:20
static void encodeNull(std::ostream &stream)
Definition: JsonEncoder.cpp:10
static void encodeBool(std::ostream &stream, bool value)
Definition: JsonEncoder.cpp:15
static void encodeString(std::ostream &stream, StringView value)
Definition: JsonEncoder.cpp:50
static void encodeIntegral(std::ostream &stream, T value)
Definition: JsonEncoder.h:65