OnixS C++ SGX Titan OUCH Trading Handler  1.2.0
API documentation
FieldAccessor.cpp
Go to the documentation of this file.
1 // Copyright Onix Solutions Limited [OnixS]. All rights reserved.
2 //
3 // This software owned by Onix Solutions Limited [OnixS] and is
4 // protected by copyright law and international copyright treaties.
5 //
6 // Access to and use of the software is governed by the terms of the applicable
7 // OnixS Software Services Agreement (the Agreement) and Customer end user license
8 // agreements granting a non-assignable, non-transferable and non-exclusive license
9 // to use the software for it's own data processing purposes under the terms defined
10 // in the Agreement.
11 //
12 // Except as otherwise granted within the terms of the Agreement, copying or
13 // reproduction of any part of this source code or associated reference material
14 // to any other location for further reproduction or redistribution, and any
15 // amendments to this copyright notice, are expressly prohibited.
16 //
17 // Any reproduction or redistribution for sale or hiring of the Software not in
18 // accordance with the terms of the Agreement is a violation of copyright law.
19 //
20 
21 #include <sstream>
22 
23 #include <boost/assert.hpp>
24 
25 #include <system/EndianConverters.h>
26 
27 #include <OnixS/HandlerCore/Compiler.h>
28 
30 
31 
33 
34 Binary2
35 BigEndianConverter::get(Binary2, const void* buffer)
36 ONIXS_SGX_OUCH_NOTHROW
37 {
38  BOOST_ASSERT(buffer);
39  return OnixS::System::BigEndianConverter::toUInt16(buffer);
40 }
41 
42 Binary4
43 BigEndianConverter::get(Binary4, const void* buffer)
44 ONIXS_SGX_OUCH_NOTHROW
45 {
46  BOOST_ASSERT(buffer);
47  return OnixS::System::BigEndianConverter::toUInt32(buffer);
48 }
49 
51 BigEndianConverter::get(SignedBinary4, const void* buffer)
52 ONIXS_SGX_OUCH_NOTHROW
53 {
54  BOOST_ASSERT(buffer);
55  return OnixS::System::BigEndianConverter::toInt32(buffer);
56 }
57 
58 Binary8
59 BigEndianConverter::get(Binary8, const void* buffer)
60 ONIXS_SGX_OUCH_NOTHROW
61 {
62  BOOST_ASSERT(buffer);
63  return OnixS::System::BigEndianConverter::toUInt64(buffer);
64 }
65 
67 BigEndianConverter::get(const Binary12&, const void* buffer)
68 ONIXS_SGX_OUCH_NOTHROW
69 {
70  BOOST_ASSERT(buffer);
71 
72  const Binary1* data = static_cast<const Binary1*>(buffer);
73 
74  Binary12 result = {{0}};
75 
76  result.value[11] = data[0];
77  result.value[10] = data[1];
78  result.value[9] = data[2];
79  result.value[8] = data[3];
80  result.value[7] = data[4];
81  result.value[6] = data[5];
82  result.value[5] = data[6];
83  result.value[4] = data[7];
84  result.value[3] = data[8];
85  result.value[2] = data[9];
86  result.value[1] = data[10];
87  result.value[0] = data[11];
88 
89  return result;
90 }
91 
92 void
93 BigEndianConverter::set(void* buffer, Binary2 value)
94 ONIXS_SGX_OUCH_NOTHROW
95 {
96  BOOST_ASSERT(buffer);
97  OnixS::System::BigEndianConverter::toBytes(buffer, value);
98 }
99 
100 void
101 BigEndianConverter::set(void* buffer, Binary4 value)
102 ONIXS_SGX_OUCH_NOTHROW
103 {
104  BOOST_ASSERT(buffer);
105  OnixS::System::BigEndianConverter::toBytes(buffer, value);
106 }
107 
108 void
109 BigEndianConverter::set(void* buffer, SignedBinary4 value)
110 ONIXS_SGX_OUCH_NOTHROW
111 {
112  BOOST_ASSERT(buffer);
113  OnixS::System::BigEndianConverter::toBytes(buffer, value);
114 }
115 
116 void
117 BigEndianConverter::set(void* buffer, Binary8 value)
118 ONIXS_SGX_OUCH_NOTHROW
119 {
120  BOOST_ASSERT(buffer);
121  OnixS::System::BigEndianConverter::toBytes(buffer, static_cast<long long unsigned int>(value));
122 }
123 
124 void
125 BigEndianConverter::set(void* buffer, const Binary12& value)
126 ONIXS_SGX_OUCH_NOTHROW
127 {
128  BOOST_ASSERT(buffer);
129 
130  Binary1* outData = static_cast<Binary1*>(buffer);
131  const Binary1* inData = reinterpret_cast<const Binary1*>(&value.value);
132 
133  outData[11] = inData[0];
134  outData[10] = inData[1];
135  outData[9] = inData[2];
136  outData[8] = inData[3];
137  outData[7] = inData[4];
138  outData[6] = inData[5];
139  outData[5] = inData[6];
140  outData[4] = inData[7];
141  outData[3] = inData[8];
142  outData[2] = inData[9];
143  outData[1] = inData[10];
144  outData[0] = inData[11];
145 }
146 
#define ONIXS_SGXTITAN_OUCH_NAMESPACE_END
Definition: Bootstrap.h:31
#define ONIXS_SGXTITAN_OUCH_NAMESPACE_BEGIN
Definition: Bootstrap.h:27