OnixS C++ eSpeed ITCH Market Data Handler 1.7.3
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
33template
34 <
35 typename Type
36 >
37 inline
38 void*
39 toOpaquePtr(Type* ptr)
40{
41 return static_cast<void*>(ptr);
42}
43
45template
46 <
47 typename Type
48 >
49 inline
50 const void*
52 const Type* ptr)
53{
54 return static_cast<const void*>(ptr);
55}
56
59template
60 <
61 typename Type
62 >
63 inline
64 Byte*
66 Type* ptr)
67{
68 return
69 static_cast
70 <Byte*>
71 (toOpaquePtr(ptr));
72}
73
76template
77 <
78 typename Type
79 >
80 inline
81 const Byte*
83 const Type* ptr)
84{
85 return
86 static_cast
87 <const Byte*>
88 (toOpaquePtr(ptr));
89}
90
92template
93 <
94 typename Type
95 >
96 inline
97 Type*
99 Type* pointer,
100 ptrdiff_t distance)
101{
102 return
103 reinterpret_cast<Type*>
104 (
105 toByteBlock(pointer) + distance
106 );
107}
108
111template
112 <
113 typename Type
114 >
115 inline
116 Type*
118 Type* pointer,
119 ptrdiff_t distance)
120{
121 return
122 reinterpret_cast<Type*>
123 (
124 toByteBlock(pointer) - distance
125 );
126}
127
129template
130 <
131 typename Left,
132 typename Right
133 >
134 inline
135 ptrdiff_t
137 Left* left,
138 Right* right)
139{
140 return (
141 toByteBlock(left) -
142 toByteBlock(right)
143 );
144}
145
#define ONIXS_ESPEED_ITCH_NAMESPACE_BEGIN
Definition Bootstrap.h:27
#define ONIXS_ESPEED_ITCH_NAMESPACE_END
Definition Bootstrap.h:31
void * toOpaquePtr(Type *ptr)
Makes pointer as opaque one.
Definition Memory.h:39
ptrdiff_t byteDistance(Left *left, Right *right)
Returns distance in bytes between two pointers.
Definition Memory.h:136
Type * advanceByBytes(Type *pointer, ptrdiff_t distance)
Advances given pointer to a given offset (distance) in bytes.
Definition Memory.h:98
Type * advanceBackByBytes(Type *pointer, ptrdiff_t distance)
Definition Memory.h:117
Byte * toByteBlock(Type *ptr)
Definition Memory.h:65
ONIXS_ESPEED_ITCH_NAMESPACE_BEGIN typedef UInt8 Byte
Alias for Byte.
Definition Memory.h:30