OnixS C++ CME MDP Conflated UDP Handler 1.1.2
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
44template
45<
46 typename Type
47>
48inline
49void*
50toOpaquePtr(Type* ptr)
51{
52 return static_cast<void*>(ptr);
53}
54
56template
57<
58 typename Type
59>
60inline
61const void*
63 const Type* ptr)
64{
65 return static_cast<const void*>(ptr);
66}
67
70template
71<
72 typename Type
73>
74inline
75Byte*
77 Type* ptr)
78{
79 return
80 static_cast
81 <Byte*>
82 (toOpaquePtr(ptr));
83}
84
87template
88<
89 typename Type
90>
91inline
92const Byte*
94 const Type* ptr)
95{
96 return
97 static_cast
98 <const Byte*>
99 (toOpaquePtr(ptr));
100}
101
103template
104<
105 typename Type
106>
107inline
108Type*
110 Type* pointer,
111 ptrdiff_t distance)
112{
113 return
114 reinterpret_cast<Type*>
115 (
116 toByteBlock(pointer) + distance
117 );
118}
119
122template
123<
124 typename Type
125>
126inline
127Type*
129 Type* pointer,
130 ptrdiff_t distance)
131{
132 return
133 reinterpret_cast<Type*>
134 (
135 toByteBlock(pointer) - distance
136 );
137}
138
140template
141<
142 typename Left,
143 typename Right
144>
145inline
146ptrdiff_t
148 Left* left,
149 Right* right)
150{
151 return (
152 toByteBlock(left) -
153 toByteBlock(right)
154 );
155}
156
#define ONIXS_CONFLATEDUDP_NAMESPACE_END
Definition Bootstrap.h:157
#define ONIXS_CONFLATEDUDP_NAMESPACE_BEGIN
Definition Bootstrap.h:153
void * toOpaquePtr(Type *ptr)
Makes pointer as opaque one.
Definition Memory.h:50
ptrdiff_t byteDistance(Left *left, Right *right)
Returns distance in bytes between two pointers.
Definition Memory.h:147
Type * advanceByBytes(Type *pointer, ptrdiff_t distance)
Advances given pointer to a given offset (distance) in bytes.
Definition Memory.h:109
Type * advanceBackByBytes(Type *pointer, ptrdiff_t distance)
Definition Memory.h:128
UInt64 UInt64
uInt64.
Definition Fields.h:265
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
UInt32 UInt32
uInt32.
Definition Fields.h:261
Byte * toByteBlock(Type *ptr)
Definition Memory.h:76
UInt16 UInt16
uInt16.
Definition Fields.h:257
UInt8 Byte
Alias for Byte.
Definition Memory.h:30