Skip to content

Commit 8922641

Browse files
authored
Merge pull request #19 from cosminpolifronie/master
Fix compilation issues with stricter rules
2 parents 5d051ec + 38a424b commit 8922641

2 files changed

Lines changed: 30 additions & 29 deletions

File tree

msgpack11.cpp

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -99,23 +99,23 @@ void dump_data(const T value, std::ostream& os)
9999
}
100100

101101
inline void dump(NullStruct, std::ostream& os) {
102-
os.put(0xc0);
102+
os.put(static_cast<char>(0xc0));
103103
}
104104

105105
inline void dump(float value, std::ostream& os) {
106-
os.put(0xca);
106+
os.put(static_cast<char>(0xca));
107107
dump_data(value, os);
108108
}
109109

110110
inline void dump(double value, std::ostream& os) {
111-
os.put(0xcb);
111+
os.put(static_cast<char>(0xcb));
112112
dump_data(value, os);
113113
}
114114

115115
inline void dump(uint8_t value, std::ostream& os) {
116116
if(128 <= value)
117117
{
118-
os.put(0xcc);
118+
os.put(static_cast<char>(0xcc));
119119
}
120120
os.put(value);
121121
}
@@ -127,7 +127,7 @@ inline void dump(uint16_t value, std::ostream& os) {
127127
}
128128
else
129129
{
130-
os.put(0xcd);
130+
os.put(static_cast<char>(0xcd));
131131
dump_data(value, os);
132132
}
133133
}
@@ -139,7 +139,7 @@ inline void dump(uint32_t value, std::ostream& os) {
139139
}
140140
else
141141
{
142-
os.put(0xce);
142+
os.put(static_cast<char>(0xce));
143143
dump_data(value, os);
144144
}
145145
}
@@ -151,23 +151,23 @@ inline void dump(uint64_t value, std::ostream& os) {
151151
}
152152
else
153153
{
154-
os.put(0xcf);
154+
os.put(static_cast<char>(0xcf));
155155
dump_data(value, os);
156156
}
157157
}
158158

159159
inline void dump(int8_t value, std::ostream& os) {
160160
if( value < -32 )
161161
{
162-
os.put(0xd0);
162+
os.put(static_cast<char>(0xd0));
163163
}
164164
os.put(value);
165165
}
166166

167167
inline void dump(int16_t value, std::ostream& os) {
168168
if( value < -(1 << 7) )
169169
{
170-
os.put(0xd1);
170+
os.put(static_cast<char>(0xd1));
171171
dump_data(value, os);
172172
}
173173
else if( value <= 0 )
@@ -183,7 +183,7 @@ inline void dump(int16_t value, std::ostream& os) {
183183
inline void dump(int32_t value, std::ostream& os) {
184184
if( value < -(1 << 15) )
185185
{
186-
os.put(0xd2);
186+
os.put(static_cast<char>(0xd2));
187187
dump_data(value, os);
188188
}
189189
else if( value <= 0 )
@@ -199,7 +199,7 @@ inline void dump(int32_t value, std::ostream& os) {
199199
inline void dump(int64_t value, std::ostream& os) {
200200
if( value < -(1LL << 31) )
201201
{
202-
os.put(0xd3);
202+
os.put(static_cast<char>(0xd3));
203203
dump_data(value, os);
204204
}
205205
else if( value <= 0 )
@@ -226,17 +226,17 @@ inline void dump(const std::string& value, std::ostream& os) {
226226
}
227227
else if(len <= 0xff)
228228
{
229-
os.put(0xd9);
229+
os.put(static_cast<char>(0xd9));
230230
os.put(static_cast<uint8_t>(len));
231231
}
232232
else if(len <= 0xffff)
233233
{
234-
os.put(0xda);
234+
os.put(static_cast<char>(0xda));
235235
dump_data(static_cast<uint16_t>(len), os);
236236
}
237237
else if(len <= 0xffffffff)
238238
{
239-
os.put(0xdb);
239+
os.put(static_cast<char>(0xdb));
240240
dump_data(static_cast<uint32_t>(len), os);
241241
}
242242
else
@@ -258,12 +258,12 @@ inline void dump(const MsgPack::array& value, std::ostream& os) {
258258
}
259259
else if(len <= 0xffff)
260260
{
261-
os.put(0xdc);
261+
os.put(static_cast<char>(0xdc));
262262
dump_data(static_cast<uint16_t>(len), os);
263263
}
264264
else if(len <= 0xffffffff)
265265
{
266-
os.put(0xdd);
266+
os.put(static_cast<char>(0xdd));
267267
dump_data(static_cast<uint32_t>(len), os);
268268
}
269269
else
@@ -285,12 +285,12 @@ inline void dump(const MsgPack::object& value, std::ostream& os) {
285285
}
286286
else if(len <= 0xffff)
287287
{
288-
os.put(0xde);
288+
os.put(static_cast<char>(0xde));
289289
dump_data(static_cast<uint16_t>(len), os);
290290
}
291291
else if(len <= 0xffffffff)
292292
{
293-
os.put(0xdf);
293+
os.put(static_cast<char>(0xdf));
294294
dump_data(static_cast<uint32_t>(len), os);
295295
}
296296
else
@@ -308,17 +308,17 @@ inline void dump(const MsgPack::binary& value, std::ostream& os) {
308308
size_t const len = value.size();
309309
if(len <= 0xff)
310310
{
311-
os.put(0xc4);
311+
os.put(static_cast<char>(0xc4));
312312
dump_data(static_cast<uint8_t>(len), os);
313313
}
314314
else if(len <= 0xffff)
315315
{
316-
os.put(0xc5);
316+
os.put(static_cast<char>(0xc5));
317317
dump_data(static_cast<uint16_t>(len), os);
318318
}
319319
else if(len <= 0xffffffff)
320320
{
321-
os.put(0xc6);
321+
os.put(static_cast<char>(0xc6));
322322
dump_data(static_cast<uint32_t>(len), os);
323323
}
324324
else
@@ -334,30 +334,30 @@ inline void dump(const MsgPack::extension& value, std::ostream& os) {
334334
const size_t len = data.size();
335335

336336
if(len == 0x01) {
337-
os.put(0xd4);
337+
os.put(static_cast<char>(0xd4));
338338
}
339339
else if(len == 0x02) {
340-
os.put(0xd5);
340+
os.put(static_cast<char>(0xd5));
341341
}
342342
else if(len == 0x04) {
343-
os.put(0xd6);
343+
os.put(static_cast<char>(0xd6));
344344
}
345345
else if(len == 0x08) {
346-
os.put(0xd7);
346+
os.put(static_cast<char>(0xd7));
347347
}
348348
else if(len == 0x10) {
349-
os.put(0xd8);
349+
os.put(static_cast<char>(0xd8));
350350
}
351351
else if(len <= 0xff) {
352-
os.put(0xc7);
352+
os.put(static_cast<char>(0xc7));
353353
os.put(static_cast<uint8_t>(len));
354354
}
355355
else if(len <= 0xffff) {
356-
os.put(0xc8);
356+
os.put(static_cast<char>(0xc8));
357357
dump_data(static_cast<uint16_t>(len), os);
358358
}
359359
else if(len <= 0xffffffff) {
360-
os.put(0xc9);
360+
os.put(static_cast<char>(0xc9));
361361
dump_data(static_cast<uint32_t>(len), os);
362362
}
363363
else {

msgpack11.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
22

3+
#include <cstdint>
34
#include <string>
45
#include <vector>
56
#include <map>

0 commit comments

Comments
 (0)