/src/arduinojson/src/ArduinoJson/MsgPack/MsgPackSerializer.hpp
Line | Count | Source |
1 | | // ArduinoJson - https://arduinojson.org |
2 | | // Copyright © 2014-2026, Benoit BLANCHON |
3 | | // MIT License |
4 | | |
5 | | #pragma once |
6 | | |
7 | | #include <ArduinoJson/MsgPack/endianness.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 VariantDataVisitor<size_t> { |
19 | | public: |
20 | | static const bool producesText = false; |
21 | | |
22 | | MsgPackSerializer(TWriter writer, ResourceManager* resources) |
23 | 889 | : writer_(writer), resources_(resources) {} |
24 | | |
25 | | template <typename T> |
26 | | enable_if_t<is_floating_point<T>::value && sizeof(T) == 4, size_t> visit( |
27 | 1.17k | T value32) { |
28 | 1.17k | if (canConvertNumber<JsonInteger>(value32)) { |
29 | 981 | JsonInteger truncatedValue = JsonInteger(value32); |
30 | 981 | if (value32 == T(truncatedValue)) |
31 | 770 | return visit(truncatedValue); |
32 | 981 | } |
33 | 406 | writeByte(0xCA); |
34 | 406 | writeInteger(value32); |
35 | 406 | return bytesWritten(); |
36 | 1.17k | } _ZN11ArduinoJson8V742HB426detail17MsgPackSerializerINS1_6WriterINSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEvEEE5visitIfEENS1_9enable_ifIXaasr17is_floating_pointIT_EE5valueeqstSF_Li4EEmE4typeESF_ Line | Count | Source | 27 | 1.17k | T value32) { | 28 | 1.17k | if (canConvertNumber<JsonInteger>(value32)) { | 29 | 981 | JsonInteger truncatedValue = JsonInteger(value32); | 30 | 981 | if (value32 == T(truncatedValue)) | 31 | 770 | return visit(truncatedValue); | 32 | 981 | } | 33 | 406 | writeByte(0xCA); | 34 | 406 | writeInteger(value32); | 35 | 406 | return bytesWritten(); | 36 | 1.17k | } |
Unexecuted instantiation: _ZN11ArduinoJson8V742HB426detail17MsgPackSerializerINS1_18StaticStringWriterEE5visitIfEENS1_9enable_ifIXaasr17is_floating_pointIT_EE5valueeqstS7_Li4EEmE4typeES7_ Unexecuted instantiation: _ZN11ArduinoJson8V742HB426detail17MsgPackSerializerINS1_11DummyWriterEE5visitIfEENS1_9enable_ifIXaasr17is_floating_pointIT_EE5valueeqstS7_Li4EEmE4typeES7_ |
37 | | |
38 | | template <typename T> |
39 | | ARDUINOJSON_NO_SANITIZE("float-cast-overflow") |
40 | | enable_if_t<is_floating_point<T>::value && sizeof(T) == 8, size_t> visit( |
41 | 194 | T value64) { |
42 | 194 | float value32 = float(value64); |
43 | 194 | if (value32 == value64) |
44 | 0 | return visit(value32); |
45 | 194 | writeByte(0xCB); |
46 | 194 | writeInteger(value64); |
47 | 194 | return bytesWritten(); |
48 | 194 | } _ZN11ArduinoJson8V742HB426detail17MsgPackSerializerINS1_6WriterINSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEEvEEE5visitIdEENS1_9enable_ifIXaasr17is_floating_pointIT_EE5valueeqstSF_Li8EEmE4typeESF_ Line | Count | Source | 41 | 194 | T value64) { | 42 | 194 | float value32 = float(value64); | 43 | 194 | if (value32 == value64) | 44 | 0 | return visit(value32); | 45 | 194 | writeByte(0xCB); | 46 | 194 | writeInteger(value64); | 47 | 194 | return bytesWritten(); | 48 | 194 | } |
Unexecuted instantiation: _ZN11ArduinoJson8V742HB426detail17MsgPackSerializerINS1_18StaticStringWriterEE5visitIdEENS1_9enable_ifIXaasr17is_floating_pointIT_EE5valueeqstS7_Li8EEmE4typeES7_ Unexecuted instantiation: _ZN11ArduinoJson8V742HB426detail17MsgPackSerializerINS1_11DummyWriterEE5visitIdEENS1_9enable_ifIXaasr17is_floating_pointIT_EE5valueeqstS7_Li8EEmE4typeES7_ |
49 | | |
50 | 2.99k | size_t visitArray(VariantData* array) { |
51 | 2.99k | ARDUINOJSON_ASSERT(array != nullptr); |
52 | 2.99k | ARDUINOJSON_ASSERT(array->isArray()); |
53 | | |
54 | 2.99k | auto n = VariantImpl::size(array, resources_); |
55 | 2.99k | if (n < 0x10) { |
56 | 2.74k | writeByte(uint8_t(0x90 + n)); |
57 | 2.74k | } else if (n < 0x10000) { |
58 | 243 | writeByte(0xDC); |
59 | 243 | writeInteger(uint16_t(n)); |
60 | 243 | } else { |
61 | 0 | writeByte(0xDD); |
62 | 0 | writeInteger(uint32_t(n)); |
63 | 0 | } |
64 | | |
65 | 2.99k | auto slotId = array->content.asCollection.head; |
66 | 45.1k | while (slotId != NULL_SLOT) { |
67 | 42.1k | auto slot = resources_->getVariant(slotId); |
68 | 42.1k | VariantImpl::accept(*this, slot, resources_); |
69 | 42.1k | slotId = slot->next; |
70 | 42.1k | } |
71 | | |
72 | 2.99k | return bytesWritten(); |
73 | 2.99k | } ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::Writer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void> >::visitArray(ArduinoJson::V742HB42::detail::VariantData*) Line | Count | Source | 50 | 2.99k | size_t visitArray(VariantData* array) { | 51 | 2.99k | ARDUINOJSON_ASSERT(array != nullptr); | 52 | 2.99k | ARDUINOJSON_ASSERT(array->isArray()); | 53 | | | 54 | 2.99k | auto n = VariantImpl::size(array, resources_); | 55 | 2.99k | if (n < 0x10) { | 56 | 2.74k | writeByte(uint8_t(0x90 + n)); | 57 | 2.74k | } else if (n < 0x10000) { | 58 | 243 | writeByte(0xDC); | 59 | 243 | writeInteger(uint16_t(n)); | 60 | 243 | } else { | 61 | 0 | writeByte(0xDD); | 62 | 0 | writeInteger(uint32_t(n)); | 63 | 0 | } | 64 | | | 65 | 2.99k | auto slotId = array->content.asCollection.head; | 66 | 45.1k | while (slotId != NULL_SLOT) { | 67 | 42.1k | auto slot = resources_->getVariant(slotId); | 68 | 42.1k | VariantImpl::accept(*this, slot, resources_); | 69 | 42.1k | slotId = slot->next; | 70 | 42.1k | } | 71 | | | 72 | 2.99k | return bytesWritten(); | 73 | 2.99k | } |
Unexecuted instantiation: ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::StaticStringWriter>::visitArray(ArduinoJson::V742HB42::detail::VariantData*) Unexecuted instantiation: ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::DummyWriter>::visitArray(ArduinoJson::V742HB42::detail::VariantData*) |
74 | | |
75 | 1.07k | size_t visitObject(VariantData* object) { |
76 | 1.07k | ARDUINOJSON_ASSERT(object != nullptr); |
77 | 1.07k | ARDUINOJSON_ASSERT(object->isObject()); |
78 | | |
79 | 1.07k | auto n = VariantImpl::size(object, resources_); |
80 | 1.07k | if (n < 0x10) { |
81 | 998 | writeByte(uint8_t(0x80 + n)); |
82 | 998 | } else if (n < 0x10000) { |
83 | 81 | writeByte(0xDE); |
84 | 81 | writeInteger(uint16_t(n)); |
85 | 81 | } else { |
86 | 0 | writeByte(0xDF); |
87 | 0 | writeInteger(uint32_t(n)); |
88 | 0 | } |
89 | | |
90 | 1.07k | auto slotId = object->content.asCollection.head; |
91 | 12.8k | while (slotId != NULL_SLOT) { |
92 | 11.8k | auto slot = resources_->getVariant(slotId); |
93 | 11.8k | VariantImpl::accept(*this, slot, resources_); |
94 | 11.8k | slotId = slot->next; |
95 | 11.8k | } |
96 | | |
97 | 1.07k | return bytesWritten(); |
98 | 1.07k | } ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::Writer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void> >::visitObject(ArduinoJson::V742HB42::detail::VariantData*) Line | Count | Source | 75 | 1.07k | size_t visitObject(VariantData* object) { | 76 | 1.07k | ARDUINOJSON_ASSERT(object != nullptr); | 77 | 1.07k | ARDUINOJSON_ASSERT(object->isObject()); | 78 | | | 79 | 1.07k | auto n = VariantImpl::size(object, resources_); | 80 | 1.07k | if (n < 0x10) { | 81 | 998 | writeByte(uint8_t(0x80 + n)); | 82 | 998 | } else if (n < 0x10000) { | 83 | 81 | writeByte(0xDE); | 84 | 81 | writeInteger(uint16_t(n)); | 85 | 81 | } else { | 86 | 0 | writeByte(0xDF); | 87 | 0 | writeInteger(uint32_t(n)); | 88 | 0 | } | 89 | | | 90 | 1.07k | auto slotId = object->content.asCollection.head; | 91 | 12.8k | while (slotId != NULL_SLOT) { | 92 | 11.8k | auto slot = resources_->getVariant(slotId); | 93 | 11.8k | VariantImpl::accept(*this, slot, resources_); | 94 | 11.8k | slotId = slot->next; | 95 | 11.8k | } | 96 | | | 97 | 1.07k | return bytesWritten(); | 98 | 1.07k | } |
Unexecuted instantiation: ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::StaticStringWriter>::visitObject(ArduinoJson::V742HB42::detail::VariantData*) Unexecuted instantiation: ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::DummyWriter>::visitObject(ArduinoJson::V742HB42::detail::VariantData*) |
99 | | |
100 | | size_t visit(const char* value) { |
101 | | return visit(JsonString(value)); |
102 | | } |
103 | | |
104 | 12.6k | size_t visit(JsonString value) { |
105 | 12.6k | ARDUINOJSON_ASSERT(!value.isNull()); |
106 | | |
107 | 12.6k | auto n = value.size(); |
108 | | |
109 | 12.6k | if (n < 0x20) { |
110 | 12.4k | writeByte(uint8_t(0xA0 + n)); |
111 | 12.4k | } else if (n < 0x100) { |
112 | 84 | writeByte(0xD9); |
113 | 84 | writeInteger(uint8_t(n)); |
114 | 84 | } else if (n < 0x10000) { |
115 | 37 | writeByte(0xDA); |
116 | 37 | writeInteger(uint16_t(n)); |
117 | 37 | } else { |
118 | 0 | writeByte(0xDB); |
119 | 0 | writeInteger(uint32_t(n)); |
120 | 0 | } |
121 | 12.6k | writeBytes(reinterpret_cast<const uint8_t*>(value.c_str()), n); |
122 | 12.6k | return bytesWritten(); |
123 | 12.6k | } ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::Writer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void> >::visit(ArduinoJson::V742HB42::JsonString) Line | Count | Source | 104 | 12.6k | size_t visit(JsonString value) { | 105 | 12.6k | ARDUINOJSON_ASSERT(!value.isNull()); | 106 | | | 107 | 12.6k | auto n = value.size(); | 108 | | | 109 | 12.6k | if (n < 0x20) { | 110 | 12.4k | writeByte(uint8_t(0xA0 + n)); | 111 | 12.4k | } else if (n < 0x100) { | 112 | 84 | writeByte(0xD9); | 113 | 84 | writeInteger(uint8_t(n)); | 114 | 84 | } else if (n < 0x10000) { | 115 | 37 | writeByte(0xDA); | 116 | 37 | writeInteger(uint16_t(n)); | 117 | 37 | } else { | 118 | 0 | writeByte(0xDB); | 119 | 0 | writeInteger(uint32_t(n)); | 120 | 0 | } | 121 | 12.6k | writeBytes(reinterpret_cast<const uint8_t*>(value.c_str()), n); | 122 | 12.6k | return bytesWritten(); | 123 | 12.6k | } |
Unexecuted instantiation: ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::StaticStringWriter>::visit(ArduinoJson::V742HB42::JsonString) Unexecuted instantiation: ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::DummyWriter>::visit(ArduinoJson::V742HB42::JsonString) |
124 | | |
125 | 203 | size_t visit(RawString value) { |
126 | 203 | writeBytes(reinterpret_cast<const uint8_t*>(value.data()), value.size()); |
127 | 203 | return bytesWritten(); |
128 | 203 | } ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::Writer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void> >::visit(ArduinoJson::V742HB42::SerializedValue<char const*>) Line | Count | Source | 125 | 203 | size_t visit(RawString value) { | 126 | 203 | writeBytes(reinterpret_cast<const uint8_t*>(value.data()), value.size()); | 127 | 203 | return bytesWritten(); | 128 | 203 | } |
Unexecuted instantiation: ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::StaticStringWriter>::visit(ArduinoJson::V742HB42::SerializedValue<char const*>) Unexecuted instantiation: ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::DummyWriter>::visit(ArduinoJson::V742HB42::SerializedValue<char const*>) |
129 | | |
130 | 32.9k | size_t visit(JsonInteger value) { |
131 | 32.9k | if (value > 0) { |
132 | 11.1k | visit(static_cast<JsonUInt>(value)); |
133 | 21.7k | } else if (value >= -0x20) { |
134 | 20.4k | writeInteger(int8_t(value)); |
135 | 20.4k | } else if (value >= -0x80) { |
136 | 204 | writeByte(0xD0); |
137 | 204 | writeInteger(int8_t(value)); |
138 | 1.11k | } else if (value >= -0x8000) { |
139 | 222 | writeByte(0xD1); |
140 | 222 | writeInteger(int16_t(value)); |
141 | 222 | } |
142 | 897 | #if ARDUINOJSON_USE_LONG_LONG |
143 | 897 | else if (value >= -0x80000000LL) |
144 | | #else |
145 | | else |
146 | | #endif |
147 | 360 | { |
148 | 360 | writeByte(0xD2); |
149 | 360 | writeInteger(int32_t(value)); |
150 | 360 | } |
151 | 537 | #if ARDUINOJSON_USE_LONG_LONG |
152 | 537 | else { |
153 | 537 | writeByte(0xD3); |
154 | 537 | writeInteger(int64_t(value)); |
155 | 537 | } |
156 | 32.9k | #endif |
157 | 32.9k | return bytesWritten(); |
158 | 32.9k | } ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::Writer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void> >::visit(long) Line | Count | Source | 130 | 32.9k | size_t visit(JsonInteger value) { | 131 | 32.9k | if (value > 0) { | 132 | 11.1k | visit(static_cast<JsonUInt>(value)); | 133 | 21.7k | } else if (value >= -0x20) { | 134 | 20.4k | writeInteger(int8_t(value)); | 135 | 20.4k | } else if (value >= -0x80) { | 136 | 204 | writeByte(0xD0); | 137 | 204 | writeInteger(int8_t(value)); | 138 | 1.11k | } else if (value >= -0x8000) { | 139 | 222 | writeByte(0xD1); | 140 | 222 | writeInteger(int16_t(value)); | 141 | 222 | } | 142 | 897 | #if ARDUINOJSON_USE_LONG_LONG | 143 | 897 | else if (value >= -0x80000000LL) | 144 | | #else | 145 | | else | 146 | | #endif | 147 | 360 | { | 148 | 360 | writeByte(0xD2); | 149 | 360 | writeInteger(int32_t(value)); | 150 | 360 | } | 151 | 537 | #if ARDUINOJSON_USE_LONG_LONG | 152 | 537 | else { | 153 | 537 | writeByte(0xD3); | 154 | 537 | writeInteger(int64_t(value)); | 155 | 537 | } | 156 | 32.9k | #endif | 157 | 32.9k | return bytesWritten(); | 158 | 32.9k | } |
Unexecuted instantiation: ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::StaticStringWriter>::visit(long) Unexecuted instantiation: ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::DummyWriter>::visit(long) |
159 | | |
160 | 12.6k | size_t visit(JsonUInt value) { |
161 | 12.6k | if (value <= 0x7F) { |
162 | 10.9k | writeInteger(uint8_t(value)); |
163 | 10.9k | } else if (value <= 0xFF) { |
164 | 205 | writeByte(0xCC); |
165 | 205 | writeInteger(uint8_t(value)); |
166 | 1.57k | } else if (value <= 0xFFFF) { |
167 | 228 | writeByte(0xCD); |
168 | 228 | writeInteger(uint16_t(value)); |
169 | 228 | } |
170 | 1.34k | #if ARDUINOJSON_USE_LONG_LONG |
171 | 1.34k | else if (value <= 0xFFFFFFFF) |
172 | | #else |
173 | | else |
174 | | #endif |
175 | 276 | { |
176 | 276 | writeByte(0xCE); |
177 | 276 | writeInteger(uint32_t(value)); |
178 | 276 | } |
179 | 1.06k | #if ARDUINOJSON_USE_LONG_LONG |
180 | 1.06k | else { |
181 | 1.06k | writeByte(0xCF); |
182 | 1.06k | writeInteger(uint64_t(value)); |
183 | 1.06k | } |
184 | 12.6k | #endif |
185 | 12.6k | return bytesWritten(); |
186 | 12.6k | } ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::Writer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void> >::visit(unsigned long) Line | Count | Source | 160 | 12.6k | size_t visit(JsonUInt value) { | 161 | 12.6k | if (value <= 0x7F) { | 162 | 10.9k | writeInteger(uint8_t(value)); | 163 | 10.9k | } else if (value <= 0xFF) { | 164 | 205 | writeByte(0xCC); | 165 | 205 | writeInteger(uint8_t(value)); | 166 | 1.57k | } else if (value <= 0xFFFF) { | 167 | 228 | writeByte(0xCD); | 168 | 228 | writeInteger(uint16_t(value)); | 169 | 228 | } | 170 | 1.34k | #if ARDUINOJSON_USE_LONG_LONG | 171 | 1.34k | else if (value <= 0xFFFFFFFF) | 172 | | #else | 173 | | else | 174 | | #endif | 175 | 276 | { | 176 | 276 | writeByte(0xCE); | 177 | 276 | writeInteger(uint32_t(value)); | 178 | 276 | } | 179 | 1.06k | #if ARDUINOJSON_USE_LONG_LONG | 180 | 1.06k | else { | 181 | 1.06k | writeByte(0xCF); | 182 | 1.06k | writeInteger(uint64_t(value)); | 183 | 1.06k | } | 184 | 12.6k | #endif | 185 | 12.6k | return bytesWritten(); | 186 | 12.6k | } |
Unexecuted instantiation: ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::StaticStringWriter>::visit(unsigned long) Unexecuted instantiation: ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::DummyWriter>::visit(unsigned long) |
187 | | |
188 | 2.49k | size_t visit(bool value) { |
189 | 2.49k | writeByte(value ? 0xC3 : 0xC2); |
190 | 2.49k | return bytesWritten(); |
191 | 2.49k | } ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::Writer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void> >::visit(bool) Line | Count | Source | 188 | 2.49k | size_t visit(bool value) { | 189 | 2.49k | writeByte(value ? 0xC3 : 0xC2); | 190 | 2.49k | return bytesWritten(); | 191 | 2.49k | } |
Unexecuted instantiation: ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::StaticStringWriter>::visit(bool) Unexecuted instantiation: ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::DummyWriter>::visit(bool) |
192 | | |
193 | 348 | size_t visit(nullptr_t) { |
194 | 348 | writeByte(0xC0); |
195 | 348 | return bytesWritten(); |
196 | 348 | } ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::Writer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void> >::visit(decltype(nullptr)) Line | Count | Source | 193 | 348 | size_t visit(nullptr_t) { | 194 | 348 | writeByte(0xC0); | 195 | 348 | return bytesWritten(); | 196 | 348 | } |
Unexecuted instantiation: ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::StaticStringWriter>::visit(decltype(nullptr)) Unexecuted instantiation: ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::DummyWriter>::visit(decltype(nullptr)) |
197 | | |
198 | | private: |
199 | 65.9k | size_t bytesWritten() const { |
200 | 65.9k | return writer_.count(); |
201 | 65.9k | } ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::Writer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void> >::bytesWritten() const Line | Count | Source | 199 | 65.9k | size_t bytesWritten() const { | 200 | 65.9k | return writer_.count(); | 201 | 65.9k | } |
Unexecuted instantiation: ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::StaticStringWriter>::bytesWritten() const Unexecuted instantiation: ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::DummyWriter>::bytesWritten() const |
202 | | |
203 | 23.2k | void writeByte(uint8_t c) { |
204 | 23.2k | writer_.write(c); |
205 | 23.2k | } ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::Writer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void> >::writeByte(unsigned char) Line | Count | Source | 203 | 23.2k | void writeByte(uint8_t c) { | 204 | 23.2k | writer_.write(c); | 205 | 23.2k | } |
Unexecuted instantiation: ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::StaticStringWriter>::writeByte(unsigned char) Unexecuted instantiation: ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::DummyWriter>::writeByte(unsigned char) |
206 | | |
207 | 48.3k | void writeBytes(const uint8_t* p, size_t n) { |
208 | 48.3k | writer_.write(p, n); |
209 | 48.3k | } ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::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 | 207 | 48.3k | void writeBytes(const uint8_t* p, size_t n) { | 208 | 48.3k | writer_.write(p, n); | 209 | 48.3k | } |
Unexecuted instantiation: ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::StaticStringWriter>::writeBytes(unsigned char const*, unsigned long) Unexecuted instantiation: ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::DummyWriter>::writeBytes(unsigned char const*, unsigned long) |
210 | | |
211 | | template <typename T> |
212 | 35.5k | void writeInteger(T value) { |
213 | 35.5k | fixEndianness(value); |
214 | 35.5k | writeBytes(reinterpret_cast<uint8_t*>(&value), sizeof(value)); |
215 | 35.5k | } void ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::Writer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void> >::writeInteger<float>(float) Line | Count | Source | 212 | 406 | void writeInteger(T value) { | 213 | 406 | fixEndianness(value); | 214 | 406 | writeBytes(reinterpret_cast<uint8_t*>(&value), sizeof(value)); | 215 | 406 | } |
void ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::Writer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void> >::writeInteger<double>(double) Line | Count | Source | 212 | 194 | void writeInteger(T value) { | 213 | 194 | fixEndianness(value); | 214 | 194 | writeBytes(reinterpret_cast<uint8_t*>(&value), sizeof(value)); | 215 | 194 | } |
void ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::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 | 212 | 589 | void writeInteger(T value) { | 213 | 589 | fixEndianness(value); | 214 | 589 | writeBytes(reinterpret_cast<uint8_t*>(&value), sizeof(value)); | 215 | 589 | } |
void ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::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 | 212 | 276 | void writeInteger(T value) { | 213 | 276 | fixEndianness(value); | 214 | 276 | writeBytes(reinterpret_cast<uint8_t*>(&value), sizeof(value)); | 215 | 276 | } |
void ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::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 | 212 | 11.2k | void writeInteger(T value) { | 213 | 11.2k | fixEndianness(value); | 214 | 11.2k | writeBytes(reinterpret_cast<uint8_t*>(&value), sizeof(value)); | 215 | 11.2k | } |
void ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::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 | 212 | 20.6k | void writeInteger(T value) { | 213 | 20.6k | fixEndianness(value); | 214 | 20.6k | writeBytes(reinterpret_cast<uint8_t*>(&value), sizeof(value)); | 215 | 20.6k | } |
void ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::Writer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void> >::writeInteger<short>(short) Line | Count | Source | 212 | 222 | void writeInteger(T value) { | 213 | 222 | fixEndianness(value); | 214 | 222 | writeBytes(reinterpret_cast<uint8_t*>(&value), sizeof(value)); | 215 | 222 | } |
void ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::Writer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void> >::writeInteger<int>(int) Line | Count | Source | 212 | 360 | void writeInteger(T value) { | 213 | 360 | fixEndianness(value); | 214 | 360 | writeBytes(reinterpret_cast<uint8_t*>(&value), sizeof(value)); | 215 | 360 | } |
void ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::Writer<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, void> >::writeInteger<long>(long) Line | Count | Source | 212 | 537 | void writeInteger(T value) { | 213 | 537 | fixEndianness(value); | 214 | 537 | writeBytes(reinterpret_cast<uint8_t*>(&value), sizeof(value)); | 215 | 537 | } |
void ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::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 | 212 | 1.06k | void writeInteger(T value) { | 213 | 1.06k | fixEndianness(value); | 214 | 1.06k | writeBytes(reinterpret_cast<uint8_t*>(&value), sizeof(value)); | 215 | 1.06k | } |
Unexecuted instantiation: void ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::StaticStringWriter>::writeInteger<float>(float) Unexecuted instantiation: void ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::StaticStringWriter>::writeInteger<double>(double) Unexecuted instantiation: void ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::StaticStringWriter>::writeInteger<unsigned short>(unsigned short) Unexecuted instantiation: void ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::StaticStringWriter>::writeInteger<unsigned int>(unsigned int) Unexecuted instantiation: void ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::StaticStringWriter>::writeInteger<unsigned char>(unsigned char) Unexecuted instantiation: void ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::StaticStringWriter>::writeInteger<signed char>(signed char) Unexecuted instantiation: void ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::StaticStringWriter>::writeInteger<short>(short) Unexecuted instantiation: void ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::StaticStringWriter>::writeInteger<int>(int) Unexecuted instantiation: void ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::StaticStringWriter>::writeInteger<long>(long) Unexecuted instantiation: void ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::StaticStringWriter>::writeInteger<unsigned long>(unsigned long) Unexecuted instantiation: void ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::DummyWriter>::writeInteger<float>(float) Unexecuted instantiation: void ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::DummyWriter>::writeInteger<double>(double) Unexecuted instantiation: void ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::DummyWriter>::writeInteger<unsigned short>(unsigned short) Unexecuted instantiation: void ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::DummyWriter>::writeInteger<unsigned int>(unsigned int) Unexecuted instantiation: void ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::DummyWriter>::writeInteger<unsigned char>(unsigned char) Unexecuted instantiation: void ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::DummyWriter>::writeInteger<signed char>(signed char) Unexecuted instantiation: void ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::DummyWriter>::writeInteger<short>(short) Unexecuted instantiation: void ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::DummyWriter>::writeInteger<int>(int) Unexecuted instantiation: void ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::DummyWriter>::writeInteger<long>(long) Unexecuted instantiation: void ArduinoJson::V742HB42::detail::MsgPackSerializer<ArduinoJson::V742HB42::detail::DummyWriter>::writeInteger<unsigned long>(unsigned long) |
216 | | |
217 | | CountingDecorator<TWriter> writer_; |
218 | | ResourceManager* resources_; |
219 | | }; |
220 | | |
221 | | ARDUINOJSON_END_PRIVATE_NAMESPACE |
222 | | |
223 | | ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE |
224 | | |
225 | | // Produces a MessagePack document. |
226 | | // https://arduinojson.org/v7/api/msgpack/serializemsgpack/ |
227 | | template < |
228 | | typename TDestination, |
229 | | detail::enable_if_t<!detail::is_pointer<TDestination>::value, int> = 0> |
230 | 889 | inline size_t serializeMsgPack(JsonVariantConst source, TDestination& output) { |
231 | 889 | using namespace ArduinoJson::detail; |
232 | 889 | return serialize<MsgPackSerializer>(source, output); |
233 | 889 | } |
234 | | |
235 | | // Produces a MessagePack document. |
236 | | // https://arduinojson.org/v7/api/msgpack/serializemsgpack/ |
237 | | inline size_t serializeMsgPack(JsonVariantConst source, void* output, |
238 | 0 | size_t size) { |
239 | 0 | using namespace ArduinoJson::detail; |
240 | 0 | return serialize<MsgPackSerializer>(source, output, size); |
241 | 0 | } |
242 | | |
243 | | // Computes the length of the document that serializeMsgPack() produces. |
244 | | // https://arduinojson.org/v7/api/msgpack/measuremsgpack/ |
245 | 0 | inline size_t measureMsgPack(JsonVariantConst source) { |
246 | 0 | using namespace ArduinoJson::detail; |
247 | 0 | return measure<MsgPackSerializer>(source); |
248 | 0 | } |
249 | | |
250 | | ARDUINOJSON_END_PUBLIC_NAMESPACE |