Bond
 
Loading...
Searching...
No Matches
simple_binary_impl.h
1// Copyright (c) Microsoft. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
4#pragma once
5
6#include <bond/core/config.h>
7
8#include "simple_binary.h"
9
10#include <bond/core/detail/protocol_visitors.h>
11
12namespace bond
13{
14
15template <typename BufferT, typename MarshaledBondedProtocolsT>
16template <typename T>
17inline void SimpleBinaryReader<BufferT, MarshaledBondedProtocolsT>::Skip(const bonded<T, SimpleBinaryReader&>& bonded)
18{
19 detail::Skip(bonded);
20}
21
22
23template <typename BufferT>
24inline void SimpleBinaryWriter<BufferT>::WriteFieldOmitted(BondDataType type, uint16_t /*id*/, const Metadata& metadata)
25{
26 // Simple doesn't support omitting fields so instead we write a default value
27 BOOST_ASSERT(!metadata.default_value.nothing);
28
29 switch (type)
30 {
31 case BT_BOOL:
32 Write(!!metadata.default_value.uint_value);
33 break;
34 case BT_UINT8:
35 Write(static_cast<uint8_t>(metadata.default_value.uint_value));
36 break;
37 case BT_UINT16:
38 Write(static_cast<uint16_t>(metadata.default_value.uint_value));
39 break;
40 case BT_UINT32:
41 Write(static_cast<uint32_t>(metadata.default_value.uint_value));
42 break;
43 case BT_UINT64:
44 Write(static_cast<uint64_t>(metadata.default_value.uint_value));
45 break;
46 case BT_FLOAT:
47 Write(static_cast<float>(metadata.default_value.double_value));
48 break;
49 case BT_DOUBLE:
50 Write(metadata.default_value.double_value);
51 break;
52 case BT_STRING:
53 Write(metadata.default_value.string_value);
54 break;
55 case BT_STRUCT:
56 BOOST_ASSERT(false);
57 break;
58 case BT_LIST:
59 case BT_SET:
60 case BT_MAP:
61 WriteContainerBegin(0, type);
62 break;
63 case BT_INT8:
64 Write(static_cast<int8_t>(metadata.default_value.int_value));
65 break;
66 case BT_INT16:
67 Write(static_cast<int16_t>(metadata.default_value.int_value));
68 break;
69 case BT_INT32:
70 Write(static_cast<int32_t>(metadata.default_value.int_value));
71 break;
72 case BT_INT64:
73 Write(static_cast<int64_t>(metadata.default_value.int_value));
74 break;
75 case BT_WSTRING:
76 Write(metadata.default_value.wstring_value);
77 break;
78 default:
79 BOOST_ASSERT(false);
80 break;
81 }
82}
83
84}
namespace bond
Definition: apply.h:17