OnixS C++ CME MDP Premium Market Data Handler 5.9.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
44template <typename Type>
45inline void* toOpaquePtr(Type* ptr)
46{
47 return static_cast<void*>(ptr);
48}
49
51template <typename Type>
52inline const void* toOpaquePtr(const Type* ptr)
53{
54 return static_cast<const void*>(ptr);
55}
56
59template <typename Type>
60inline Byte* toByteBlock(Type* ptr)
61{
62 return static_cast<Byte*>(toOpaquePtr(ptr));
63}
64
67template <typename Type>
68inline const Byte* toByteBlock(const Type* ptr)
69{
70 return static_cast<const Byte*>(toOpaquePtr(ptr));
71}
72
74template <typename Type>
75inline Type* advanceByBytes(Type* pointer, ptrdiff_t distance)
76{
77 return reinterpret_cast<Type*>(toByteBlock(pointer) + distance);
78}
79
82template <typename Type>
83inline Type* advanceBackByBytes(Type* pointer, ptrdiff_t distance)
84{
85 return reinterpret_cast<Type*>(toByteBlock(pointer) - distance);
86}
87
89template <typename Left, typename Right>
90inline ptrdiff_t byteDistance(Left* left, Right* right)
91{
92 return (toByteBlock(left) - toByteBlock(right));
93}
94
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
Definition Bootstrap.h:67
#define ONIXS_CMEMDH_NAMESPACE_END
Definition Bootstrap.h:68
void * toOpaquePtr(Type *ptr)
Makes pointer as opaque one.
Definition Memory.h:45
ptrdiff_t byteDistance(Left *left, Right *right)
Returns distance in bytes between two pointers.
Definition Memory.h:90
Type * advanceByBytes(Type *pointer, ptrdiff_t distance)
Advances given pointer to a given offset (distance) in bytes.
Definition Memory.h:75
Type * advanceBackByBytes(Type *pointer, ptrdiff_t distance)
Returns pointer which is lower than given one to a given number of bytes.
Definition Memory.h:83
UInt64 UInt64
uInt64.
Definition Fields.h:205
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:202
Byte * toByteBlock(Type *ptr)
Reinterprets pointer to one referencing to byte block.
Definition Memory.h:60
UInt8 UInt8
uInt8.
Definition Fields.h:208
UInt16 UInt16
uInt16.
Definition Fields.h:199
UInt8 Byte
Alias for Byte.
Definition Memory.h:30