/src/arduinojson/src/ArduinoJson/MsgPack/MsgPackSerializer.hpp
Line | Count | Source (jump to first uncovered line) |
1 | | // ArduinoJson - https://arduinojson.org |
2 | | // Copyright © 2014-2023, Benoit BLANCHON |
3 | | // MIT License |
4 | | |
5 | | #pragma once |
6 | | |
7 | | #include <ArduinoJson/MsgPack/endianess.hpp> |
8 | | #include <ArduinoJson/Polyfills/assert.hpp> |
9 | | #include <ArduinoJson/Polyfills/type_traits.hpp> |
10 | | #include <ArduinoJson/Serialization/CountingDecorator.hpp> |
11 | | #include <ArduinoJson/Serialization/measure.hpp> |
12 | | #include <ArduinoJson/Serialization/serialize.hpp> |
13 | | #include <ArduinoJson/Variant/VariantData.hpp> |
14 | | |
15 | | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE |
16 | | |
17 | | template <typename TWriter> |
18 | | class MsgPackSerializer : public Visitor<size_t> { |
19 | | public: |
20 | | static const bool producesText = false; |
21 | | |
22 | 600 | MsgPackSerializer(TWriter writer) : _writer(writer) {} |
23 | | |
24 | | template <typename T> |
25 | 410 | typename enable_if<sizeof(T) == 4, size_t>::type visitFloat(T value32) { |
26 | 410 | if (canConvertNumber<JsonInteger>(value32)) { |
27 | 344 | JsonInteger truncatedValue = JsonInteger(value32); |
28 | 344 | if (value32 == T(truncatedValue)) |
29 | 278 | return visitSignedInteger(truncatedValue); |
30 | 344 | } |
31 | 132 | writeByte(0xCA); |
32 | 132 | writeInteger(value32); |
33 | 132 | return bytesWritten(); |
34 | 410 | } ArduinoJson::V6211HB::detail::enable_if<(sizeof (float))==(4), unsigned long>::type ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::Writer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void> >::visitFloat<float>(float) Line | Count | Source | 25 | 410 | typename enable_if<sizeof(T) == 4, size_t>::type visitFloat(T value32) { | 26 | 410 | if (canConvertNumber<JsonInteger>(value32)) { | 27 | 344 | JsonInteger truncatedValue = JsonInteger(value32); | 28 | 344 | if (value32 == T(truncatedValue)) | 29 | 278 | return visitSignedInteger(truncatedValue); | 30 | 344 | } | 31 | 132 | writeByte(0xCA); | 32 | 132 | writeInteger(value32); | 33 | 132 | return bytesWritten(); | 34 | 410 | } |
Unexecuted instantiation: ArduinoJson::V6211HB::detail::enable_if<(sizeof (float))==(4), unsigned long>::type ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::StaticStringWriter>::visitFloat<float>(float) Unexecuted instantiation: ArduinoJson::V6211HB::detail::enable_if<(sizeof (float))==(4), unsigned long>::type ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::DummyWriter>::visitFloat<float>(float) |
35 | | |
36 | | template <typename T> |
37 | | ARDUINOJSON_NO_SANITIZE("float-cast-overflow") |
38 | 487 | typename enable_if<sizeof(T) == 8, size_t>::type visitFloat(T value64) { |
39 | 487 | float value32 = float(value64); |
40 | 487 | if (value32 == value64) |
41 | 410 | return visitFloat(value32); |
42 | 77 | writeByte(0xCB); |
43 | 77 | writeInteger(value64); |
44 | 77 | return bytesWritten(); |
45 | 487 | } ArduinoJson::V6211HB::detail::enable_if<(sizeof (double))==(8), unsigned long>::type ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::Writer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void> >::visitFloat<double>(double) Line | Count | Source | 38 | 487 | typename enable_if<sizeof(T) == 8, size_t>::type visitFloat(T value64) { | 39 | 487 | float value32 = float(value64); | 40 | 487 | if (value32 == value64) | 41 | 410 | return visitFloat(value32); | 42 | 77 | writeByte(0xCB); | 43 | 77 | writeInteger(value64); | 44 | 77 | return bytesWritten(); | 45 | 487 | } |
Unexecuted instantiation: ArduinoJson::V6211HB::detail::enable_if<(sizeof (double))==(8), unsigned long>::type ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::StaticStringWriter>::visitFloat<double>(double) Unexecuted instantiation: ArduinoJson::V6211HB::detail::enable_if<(sizeof (double))==(8), unsigned long>::type ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::DummyWriter>::visitFloat<double>(double) |
46 | | |
47 | 736 | size_t visitArray(const CollectionData& array) { |
48 | 736 | size_t n = array.size(); |
49 | 736 | if (n < 0x10) { |
50 | 704 | writeByte(uint8_t(0x90 + array.size())); |
51 | 704 | } else if (n < 0x10000) { |
52 | 32 | writeByte(0xDC); |
53 | 32 | writeInteger(uint16_t(n)); |
54 | 32 | } else { |
55 | 0 | writeByte(0xDD); |
56 | 0 | writeInteger(uint32_t(n)); |
57 | 0 | } |
58 | 4.32k | for (const VariantSlot* slot = array.head(); slot; slot = slot->next()) { |
59 | 3.59k | slot->data()->accept(*this); |
60 | 3.59k | } |
61 | 736 | return bytesWritten(); |
62 | 736 | } ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::Writer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void> >::visitArray(ArduinoJson::V6211HB::detail::CollectionData const&) Line | Count | Source | 47 | 736 | size_t visitArray(const CollectionData& array) { | 48 | 736 | size_t n = array.size(); | 49 | 736 | if (n < 0x10) { | 50 | 704 | writeByte(uint8_t(0x90 + array.size())); | 51 | 704 | } else if (n < 0x10000) { | 52 | 32 | writeByte(0xDC); | 53 | 32 | writeInteger(uint16_t(n)); | 54 | 32 | } else { | 55 | 0 | writeByte(0xDD); | 56 | 0 | writeInteger(uint32_t(n)); | 57 | 0 | } | 58 | 4.32k | for (const VariantSlot* slot = array.head(); slot; slot = slot->next()) { | 59 | 3.59k | slot->data()->accept(*this); | 60 | 3.59k | } | 61 | 736 | return bytesWritten(); | 62 | 736 | } |
Unexecuted instantiation: ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::StaticStringWriter>::visitArray(ArduinoJson::V6211HB::detail::CollectionData const&) Unexecuted instantiation: ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::DummyWriter>::visitArray(ArduinoJson::V6211HB::detail::CollectionData const&) |
63 | | |
64 | 330 | size_t visitObject(const CollectionData& object) { |
65 | 330 | size_t n = object.size(); |
66 | 330 | if (n < 0x10) { |
67 | 315 | writeByte(uint8_t(0x80 + n)); |
68 | 315 | } else if (n < 0x10000) { |
69 | 15 | writeByte(0xDE); |
70 | 15 | writeInteger(uint16_t(n)); |
71 | 15 | } else { |
72 | 0 | writeByte(0xDF); |
73 | 0 | writeInteger(uint32_t(n)); |
74 | 0 | } |
75 | 970 | for (const VariantSlot* slot = object.head(); slot; slot = slot->next()) { |
76 | 640 | visitString(slot->key()); |
77 | 640 | slot->data()->accept(*this); |
78 | 640 | } |
79 | 330 | return bytesWritten(); |
80 | 330 | } ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::Writer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void> >::visitObject(ArduinoJson::V6211HB::detail::CollectionData const&) Line | Count | Source | 64 | 330 | size_t visitObject(const CollectionData& object) { | 65 | 330 | size_t n = object.size(); | 66 | 330 | if (n < 0x10) { | 67 | 315 | writeByte(uint8_t(0x80 + n)); | 68 | 315 | } else if (n < 0x10000) { | 69 | 15 | writeByte(0xDE); | 70 | 15 | writeInteger(uint16_t(n)); | 71 | 15 | } else { | 72 | 0 | writeByte(0xDF); | 73 | 0 | writeInteger(uint32_t(n)); | 74 | 0 | } | 75 | 970 | for (const VariantSlot* slot = object.head(); slot; slot = slot->next()) { | 76 | 640 | visitString(slot->key()); | 77 | 640 | slot->data()->accept(*this); | 78 | 640 | } | 79 | 330 | return bytesWritten(); | 80 | 330 | } |
Unexecuted instantiation: ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::StaticStringWriter>::visitObject(ArduinoJson::V6211HB::detail::CollectionData const&) Unexecuted instantiation: ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::DummyWriter>::visitObject(ArduinoJson::V6211HB::detail::CollectionData const&) |
81 | | |
82 | 640 | size_t visitString(const char* value) { |
83 | 640 | return visitString(value, strlen(value)); |
84 | 640 | } ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::Writer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void> >::visitString(char const*) Line | Count | Source | 82 | 640 | size_t visitString(const char* value) { | 83 | 640 | return visitString(value, strlen(value)); | 84 | 640 | } |
Unexecuted instantiation: ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::StaticStringWriter>::visitString(char const*) Unexecuted instantiation: ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::DummyWriter>::visitString(char const*) |
85 | | |
86 | 1.31k | size_t visitString(const char* value, size_t n) { |
87 | 1.31k | ARDUINOJSON_ASSERT(value != NULL); |
88 | | |
89 | 1.31k | if (n < 0x20) { |
90 | 1.28k | writeByte(uint8_t(0xA0 + n)); |
91 | 1.28k | } else if (n < 0x100) { |
92 | 24 | writeByte(0xD9); |
93 | 24 | writeInteger(uint8_t(n)); |
94 | 24 | } else if (n < 0x10000) { |
95 | 0 | writeByte(0xDA); |
96 | 0 | writeInteger(uint16_t(n)); |
97 | 0 | } else { |
98 | 0 | writeByte(0xDB); |
99 | 0 | writeInteger(uint32_t(n)); |
100 | 0 | } |
101 | 1.31k | writeBytes(reinterpret_cast<const uint8_t*>(value), n); |
102 | 1.31k | return bytesWritten(); |
103 | 1.31k | } ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::Writer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void> >::visitString(char const*, unsigned long) Line | Count | Source | 86 | 1.31k | size_t visitString(const char* value, size_t n) { | 87 | 1.31k | ARDUINOJSON_ASSERT(value != NULL); | 88 | | | 89 | 1.31k | if (n < 0x20) { | 90 | 1.28k | writeByte(uint8_t(0xA0 + n)); | 91 | 1.28k | } else if (n < 0x100) { | 92 | 24 | writeByte(0xD9); | 93 | 24 | writeInteger(uint8_t(n)); | 94 | 24 | } else if (n < 0x10000) { | 95 | 0 | writeByte(0xDA); | 96 | 0 | writeInteger(uint16_t(n)); | 97 | 0 | } else { | 98 | 0 | writeByte(0xDB); | 99 | 0 | writeInteger(uint32_t(n)); | 100 | 0 | } | 101 | 1.31k | writeBytes(reinterpret_cast<const uint8_t*>(value), n); | 102 | 1.31k | return bytesWritten(); | 103 | 1.31k | } |
Unexecuted instantiation: ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::StaticStringWriter>::visitString(char const*, unsigned long) Unexecuted instantiation: ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::DummyWriter>::visitString(char const*, unsigned long) |
104 | | |
105 | 0 | size_t visitRawJson(const char* data, size_t size) { |
106 | 0 | writeBytes(reinterpret_cast<const uint8_t*>(data), size); |
107 | 0 | return bytesWritten(); |
108 | 0 | } Unexecuted instantiation: ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::Writer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void> >::visitRawJson(char const*, unsigned long) Unexecuted instantiation: ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::StaticStringWriter>::visitRawJson(char const*, unsigned long) Unexecuted instantiation: ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::DummyWriter>::visitRawJson(char const*, unsigned long) |
109 | | |
110 | 2.02k | size_t visitSignedInteger(JsonInteger value) { |
111 | 2.02k | if (value > 0) { |
112 | 695 | visitUnsignedInteger(static_cast<JsonUInt>(value)); |
113 | 1.33k | } else if (value >= -0x20) { |
114 | 887 | writeInteger(int8_t(value)); |
115 | 887 | } else if (value >= -0x80) { |
116 | 75 | writeByte(0xD0); |
117 | 75 | writeInteger(int8_t(value)); |
118 | 372 | } else if (value >= -0x8000) { |
119 | 90 | writeByte(0xD1); |
120 | 90 | writeInteger(int16_t(value)); |
121 | 90 | } |
122 | 282 | #if ARDUINOJSON_USE_LONG_LONG |
123 | 282 | else if (value >= -0x80000000LL) |
124 | | #else |
125 | | else |
126 | | #endif |
127 | 123 | { |
128 | 123 | writeByte(0xD2); |
129 | 123 | writeInteger(int32_t(value)); |
130 | 123 | } |
131 | 159 | #if ARDUINOJSON_USE_LONG_LONG |
132 | 159 | else { |
133 | 159 | writeByte(0xD3); |
134 | 159 | writeInteger(int64_t(value)); |
135 | 159 | } |
136 | 2.02k | #endif |
137 | 2.02k | return bytesWritten(); |
138 | 2.02k | } ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::Writer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void> >::visitSignedInteger(long) Line | Count | Source | 110 | 2.02k | size_t visitSignedInteger(JsonInteger value) { | 111 | 2.02k | if (value > 0) { | 112 | 695 | visitUnsignedInteger(static_cast<JsonUInt>(value)); | 113 | 1.33k | } else if (value >= -0x20) { | 114 | 887 | writeInteger(int8_t(value)); | 115 | 887 | } else if (value >= -0x80) { | 116 | 75 | writeByte(0xD0); | 117 | 75 | writeInteger(int8_t(value)); | 118 | 372 | } else if (value >= -0x8000) { | 119 | 90 | writeByte(0xD1); | 120 | 90 | writeInteger(int16_t(value)); | 121 | 90 | } | 122 | 282 | #if ARDUINOJSON_USE_LONG_LONG | 123 | 282 | else if (value >= -0x80000000LL) | 124 | | #else | 125 | | else | 126 | | #endif | 127 | 123 | { | 128 | 123 | writeByte(0xD2); | 129 | 123 | writeInteger(int32_t(value)); | 130 | 123 | } | 131 | 159 | #if ARDUINOJSON_USE_LONG_LONG | 132 | 159 | else { | 133 | 159 | writeByte(0xD3); | 134 | 159 | writeInteger(int64_t(value)); | 135 | 159 | } | 136 | 2.02k | #endif | 137 | 2.02k | return bytesWritten(); | 138 | 2.02k | } |
Unexecuted instantiation: ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::StaticStringWriter>::visitSignedInteger(long) Unexecuted instantiation: ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::DummyWriter>::visitSignedInteger(long) |
139 | | |
140 | 1.03k | size_t visitUnsignedInteger(JsonUInt value) { |
141 | 1.03k | if (value <= 0x7F) { |
142 | 610 | writeInteger(uint8_t(value)); |
143 | 610 | } else if (value <= 0xFF) { |
144 | 76 | writeByte(0xCC); |
145 | 76 | writeInteger(uint8_t(value)); |
146 | 353 | } else if (value <= 0xFFFF) { |
147 | 95 | writeByte(0xCD); |
148 | 95 | writeInteger(uint16_t(value)); |
149 | 95 | } |
150 | 258 | #if ARDUINOJSON_USE_LONG_LONG |
151 | 258 | else if (value <= 0xFFFFFFFF) |
152 | | #else |
153 | | else |
154 | | #endif |
155 | 120 | { |
156 | 120 | writeByte(0xCE); |
157 | 120 | writeInteger(uint32_t(value)); |
158 | 120 | } |
159 | 138 | #if ARDUINOJSON_USE_LONG_LONG |
160 | 138 | else { |
161 | 138 | writeByte(0xCF); |
162 | 138 | writeInteger(uint64_t(value)); |
163 | 138 | } |
164 | 1.03k | #endif |
165 | 1.03k | return bytesWritten(); |
166 | 1.03k | } ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::Writer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void> >::visitUnsignedInteger(unsigned long) Line | Count | Source | 140 | 1.03k | size_t visitUnsignedInteger(JsonUInt value) { | 141 | 1.03k | if (value <= 0x7F) { | 142 | 610 | writeInteger(uint8_t(value)); | 143 | 610 | } else if (value <= 0xFF) { | 144 | 76 | writeByte(0xCC); | 145 | 76 | writeInteger(uint8_t(value)); | 146 | 353 | } else if (value <= 0xFFFF) { | 147 | 95 | writeByte(0xCD); | 148 | 95 | writeInteger(uint16_t(value)); | 149 | 95 | } | 150 | 258 | #if ARDUINOJSON_USE_LONG_LONG | 151 | 258 | else if (value <= 0xFFFFFFFF) | 152 | | #else | 153 | | else | 154 | | #endif | 155 | 120 | { | 156 | 120 | writeByte(0xCE); | 157 | 120 | writeInteger(uint32_t(value)); | 158 | 120 | } | 159 | 138 | #if ARDUINOJSON_USE_LONG_LONG | 160 | 138 | else { | 161 | 138 | writeByte(0xCF); | 162 | 138 | writeInteger(uint64_t(value)); | 163 | 138 | } | 164 | 1.03k | #endif | 165 | 1.03k | return bytesWritten(); | 166 | 1.03k | } |
Unexecuted instantiation: ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::StaticStringWriter>::visitUnsignedInteger(unsigned long) Unexecuted instantiation: ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::DummyWriter>::visitUnsignedInteger(unsigned long) |
167 | | |
168 | 253 | size_t visitBoolean(bool value) { |
169 | 253 | writeByte(value ? 0xC3 : 0xC2); |
170 | 253 | return bytesWritten(); |
171 | 253 | } ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::Writer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void> >::visitBoolean(bool) Line | Count | Source | 168 | 253 | size_t visitBoolean(bool value) { | 169 | 253 | writeByte(value ? 0xC3 : 0xC2); | 170 | 253 | return bytesWritten(); | 171 | 253 | } |
Unexecuted instantiation: ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::StaticStringWriter>::visitBoolean(bool) Unexecuted instantiation: ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::DummyWriter>::visitBoolean(bool) |
172 | | |
173 | 256 | size_t visitNull() { |
174 | 256 | writeByte(0xC0); |
175 | 256 | return bytesWritten(); |
176 | 256 | } ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::Writer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void> >::visitNull() Line | Count | Source | 173 | 256 | size_t visitNull() { | 174 | 256 | writeByte(0xC0); | 175 | 256 | return bytesWritten(); | 176 | 256 | } |
Unexecuted instantiation: ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::StaticStringWriter>::visitNull() Unexecuted instantiation: ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::DummyWriter>::visitNull() |
177 | | |
178 | | private: |
179 | 6.16k | size_t bytesWritten() const { |
180 | 6.16k | return _writer.count(); |
181 | 6.16k | } ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::Writer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void> >::bytesWritten() const Line | Count | Source | 179 | 6.16k | size_t bytesWritten() const { | 180 | 6.16k | return _writer.count(); | 181 | 6.16k | } |
Unexecuted instantiation: ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::StaticStringWriter>::bytesWritten() const Unexecuted instantiation: ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::DummyWriter>::bytesWritten() const |
182 | | |
183 | 3.97k | void writeByte(uint8_t c) { |
184 | 3.97k | _writer.write(c); |
185 | 3.97k | } ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::Writer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void> >::writeByte(unsigned char) Line | Count | Source | 183 | 3.97k | void writeByte(uint8_t c) { | 184 | 3.97k | _writer.write(c); | 185 | 3.97k | } |
Unexecuted instantiation: ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::StaticStringWriter>::writeByte(unsigned char) Unexecuted instantiation: ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::DummyWriter>::writeByte(unsigned char) |
186 | | |
187 | 3.96k | void writeBytes(const uint8_t* p, size_t n) { |
188 | 3.96k | _writer.write(p, n); |
189 | 3.96k | } ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::Writer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void> >::writeBytes(unsigned char const*, unsigned long) Line | Count | Source | 187 | 3.96k | void writeBytes(const uint8_t* p, size_t n) { | 188 | 3.96k | _writer.write(p, n); | 189 | 3.96k | } |
Unexecuted instantiation: ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::StaticStringWriter>::writeBytes(unsigned char const*, unsigned long) Unexecuted instantiation: ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::DummyWriter>::writeBytes(unsigned char const*, unsigned long) |
190 | | |
191 | | template <typename T> |
192 | 2.65k | void writeInteger(T value) { |
193 | 2.65k | fixEndianess(value); |
194 | 2.65k | writeBytes(reinterpret_cast<uint8_t*>(&value), sizeof(value)); |
195 | 2.65k | } void ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::Writer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void> >::writeInteger<float>(float) Line | Count | Source | 192 | 132 | void writeInteger(T value) { | 193 | 132 | fixEndianess(value); | 194 | 132 | writeBytes(reinterpret_cast<uint8_t*>(&value), sizeof(value)); | 195 | 132 | } |
void ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::Writer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void> >::writeInteger<double>(double) Line | Count | Source | 192 | 77 | void writeInteger(T value) { | 193 | 77 | fixEndianess(value); | 194 | 77 | writeBytes(reinterpret_cast<uint8_t*>(&value), sizeof(value)); | 195 | 77 | } |
void ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::Writer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void> >::writeInteger<unsigned short>(unsigned short) Line | Count | Source | 192 | 142 | void writeInteger(T value) { | 193 | 142 | fixEndianess(value); | 194 | 142 | writeBytes(reinterpret_cast<uint8_t*>(&value), sizeof(value)); | 195 | 142 | } |
void ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::Writer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void> >::writeInteger<unsigned int>(unsigned int) Line | Count | Source | 192 | 120 | void writeInteger(T value) { | 193 | 120 | fixEndianess(value); | 194 | 120 | writeBytes(reinterpret_cast<uint8_t*>(&value), sizeof(value)); | 195 | 120 | } |
void ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::Writer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void> >::writeInteger<unsigned char>(unsigned char) Line | Count | Source | 192 | 710 | void writeInteger(T value) { | 193 | 710 | fixEndianess(value); | 194 | 710 | writeBytes(reinterpret_cast<uint8_t*>(&value), sizeof(value)); | 195 | 710 | } |
void ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::Writer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void> >::writeInteger<signed char>(signed char) Line | Count | Source | 192 | 962 | void writeInteger(T value) { | 193 | 962 | fixEndianess(value); | 194 | 962 | writeBytes(reinterpret_cast<uint8_t*>(&value), sizeof(value)); | 195 | 962 | } |
void ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::Writer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void> >::writeInteger<short>(short) Line | Count | Source | 192 | 90 | void writeInteger(T value) { | 193 | 90 | fixEndianess(value); | 194 | 90 | writeBytes(reinterpret_cast<uint8_t*>(&value), sizeof(value)); | 195 | 90 | } |
void ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::Writer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void> >::writeInteger<int>(int) Line | Count | Source | 192 | 123 | void writeInteger(T value) { | 193 | 123 | fixEndianess(value); | 194 | 123 | writeBytes(reinterpret_cast<uint8_t*>(&value), sizeof(value)); | 195 | 123 | } |
void ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::Writer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void> >::writeInteger<long>(long) Line | Count | Source | 192 | 159 | void writeInteger(T value) { | 193 | 159 | fixEndianess(value); | 194 | 159 | writeBytes(reinterpret_cast<uint8_t*>(&value), sizeof(value)); | 195 | 159 | } |
void ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::Writer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void> >::writeInteger<unsigned long>(unsigned long) Line | Count | Source | 192 | 138 | void writeInteger(T value) { | 193 | 138 | fixEndianess(value); | 194 | 138 | writeBytes(reinterpret_cast<uint8_t*>(&value), sizeof(value)); | 195 | 138 | } |
Unexecuted instantiation: void ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::StaticStringWriter>::writeInteger<float>(float) Unexecuted instantiation: void ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::StaticStringWriter>::writeInteger<double>(double) Unexecuted instantiation: void ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::StaticStringWriter>::writeInteger<unsigned short>(unsigned short) Unexecuted instantiation: void ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::StaticStringWriter>::writeInteger<unsigned int>(unsigned int) Unexecuted instantiation: void ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::StaticStringWriter>::writeInteger<unsigned char>(unsigned char) Unexecuted instantiation: void ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::StaticStringWriter>::writeInteger<signed char>(signed char) Unexecuted instantiation: void ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::StaticStringWriter>::writeInteger<short>(short) Unexecuted instantiation: void ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::StaticStringWriter>::writeInteger<int>(int) Unexecuted instantiation: void ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::StaticStringWriter>::writeInteger<long>(long) Unexecuted instantiation: void ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::StaticStringWriter>::writeInteger<unsigned long>(unsigned long) Unexecuted instantiation: void ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::DummyWriter>::writeInteger<float>(float) Unexecuted instantiation: void ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::DummyWriter>::writeInteger<double>(double) Unexecuted instantiation: void ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::DummyWriter>::writeInteger<unsigned short>(unsigned short) Unexecuted instantiation: void ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::DummyWriter>::writeInteger<unsigned int>(unsigned int) Unexecuted instantiation: void ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::DummyWriter>::writeInteger<unsigned char>(unsigned char) Unexecuted instantiation: void ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::DummyWriter>::writeInteger<signed char>(signed char) Unexecuted instantiation: void ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::DummyWriter>::writeInteger<short>(short) Unexecuted instantiation: void ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::DummyWriter>::writeInteger<int>(int) Unexecuted instantiation: void ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::DummyWriter>::writeInteger<long>(long) Unexecuted instantiation: void ArduinoJson::V6211HB::detail::MsgPackSerializer<ArduinoJson::V6211HB::detail::DummyWriter>::writeInteger<unsigned long>(unsigned long) |
196 | | |
197 | | CountingDecorator<TWriter> _writer; |
198 | | }; |
199 | | |
200 | | ARDUINOJSON_END_PRIVATE_NAMESPACE |
201 | | |
202 | | ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE |
203 | | |
204 | | // Produces a MessagePack document. |
205 | | // https://arduinojson.org/v6/api/msgpack/serializemsgpack/ |
206 | | template <typename TDestination> |
207 | 600 | inline size_t serializeMsgPack(JsonVariantConst source, TDestination& output) { |
208 | 600 | using namespace ArduinoJson::detail; |
209 | 600 | return serialize<MsgPackSerializer>(source, output); |
210 | 600 | } |
211 | | |
212 | | // Produces a MessagePack document. |
213 | | // https://arduinojson.org/v6/api/msgpack/serializemsgpack/ |
214 | | inline size_t serializeMsgPack(JsonVariantConst source, void* output, |
215 | 0 | size_t size) { |
216 | 0 | using namespace ArduinoJson::detail; |
217 | 0 | return serialize<MsgPackSerializer>(source, output, size); |
218 | 0 | } |
219 | | |
220 | | // Computes the length of the document that serializeMsgPack() produces. |
221 | | // https://arduinojson.org/v6/api/msgpack/measuremsgpack/ |
222 | 0 | inline size_t measureMsgPack(JsonVariantConst source) { |
223 | 0 | using namespace ArduinoJson::detail; |
224 | 0 | return measure<MsgPackSerializer>(source); |
225 | 0 | } |
226 | | |
227 | | ARDUINOJSON_END_PUBLIC_NAMESPACE |