OnixS C++ CME MDP Streamlined Market Data Handler 1.2.0
API Documentation
Loading...
Searching...
No Matches
Memory.h
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#pragma once
22
23#include <cstddef>
24
26
28
30typedef UInt8 Byte;
31
33typedef UInt16 Word;
34
36typedef UInt32 DWord;
37
39typedef UInt64 QWord;
40
41//
42
45template
46<
47 typename Target,
48 typename Source
49>
50inline Target c_cast(Source src)
51{
52 return (Target)src;
53}
54
56template
57<
58 typename Type
59>
60inline
61void*
62toOpaquePtr(Type* ptr)
63{
64 return static_cast<void*>(ptr);
65}
66
68template
69<
70 typename Type
71>
72inline
73const void*
75 const Type* ptr)
76{
77 return static_cast<const void*>(ptr);
78}
79
82template
83<
84 typename Type
85>
86inline
87Byte*
89 Type* ptr)
90{
91 return
92 static_cast
93 <Byte*>
94 (toOpaquePtr(ptr));
95}
96
99template
100<
101 typename Type
102>
103inline
104const Byte*
106 const Type* ptr)
107{
108 return
109 static_cast
110 <const Byte*>
111 (toOpaquePtr(ptr));
112}
113
115template
116<
117 typename Type
118>
119inline
120Type*
122 Type* pointer,
123 ptrdiff_t distance)
124{
125 return
126 reinterpret_cast<Type*>
127 (
128 toByteBlock(pointer) + distance
129 );
130}
131
134template
135<
136 typename Type
137>
138inline
139Type*
141 Type* pointer,
142 ptrdiff_t distance)
143{
144 return
145 reinterpret_cast<Type*>
146 (
147 toByteBlock(pointer) - distance
148 );
149}
150
152template
153<
154 typename Left,
155 typename Right
156>
157inline
158ptrdiff_t
160 Left* left,
161 Right* right)
162{
163 return (
164 toByteBlock(left) -
165 toByteBlock(right)
166 );
167}
168
#define ONIXS_CMESTREAMLINEDMDH_NAMESPACE_BEGIN
Definition Bootstrap.h:169
#define ONIXS_CMESTREAMLINEDMDH_NAMESPACE_END
Definition Bootstrap.h:173
void * toOpaquePtr(Type *ptr)
Makes pointer as opaque one.
Definition Memory.h:62
ptrdiff_t byteDistance(Left *left, Right *right)
Returns distance in bytes between two pointers.
Definition Memory.h:159
Type * advanceByBytes(Type *pointer, ptrdiff_t distance)
Advances given pointer to a given offset (distance) in bytes.
Definition Memory.h:121
Type * advanceBackByBytes(Type *pointer, ptrdiff_t distance)
Returns pointer which is lower than given one to a given number of bytes.
Definition Memory.h:140
UInt16 Word
Alias for Word.
Definition Memory.h:33
UInt64 QWord
Alias for Quad Word.
Definition Memory.h:39
UInt32 DWord
Alias for Double Word.
Definition Memory.h:36
Byte * toByteBlock(Type *ptr)
Reinterprets pointer to one referencing to byte block.
Definition Memory.h:88
Target c_cast(Source src)
Casts data of source type to the data of target type using C casting rules.
Definition Memory.h:50
UInt8 Byte
Alias for Byte.
Definition Memory.h:30