OnixS C++ CME MDP Premium Market Data Handler 5.9.0
API Documentation
Loading...
Searching...
No Matches
ValueContainer.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 <new>
24
27
29
32{
33 enum
34 {
35 // Capacity of the storage for a value.
36 //
37 // The storage must be capacious enough
38 // to store all integer types, string refs,
39 // time-related typed and the Decimal.
40 Capacity = 16
41 };
42
43 Byte bytes_[Capacity];
44
45 // This is to make G++ happy with the
46 // concept of storing value in the array.
47 void* place()
48 {
49 return static_cast<void*>(bytes_);
50 }
51
52 // This is to make G++ happy with the
53 // concept of storing value in the array.
54 const void* place() const
55 {
56 return static_cast<const void*>(bytes_);
57 }
58
59public:
62
66 template <typename Value>
67 Value& get()
68 {
70 sizeof(Value) <= Capacity,
71 "Capacity isn't sufficient for "
72 "storing values of the given type. "
73 );
74
75 return *static_cast<Value*>(place());
76 }
77
81 template <typename Value>
82 const Value& get() const
83 {
85 sizeof(Value) <= Capacity,
86 "Capacity of the storage isn't "
87 "sufficient to store values "
88 "of the specified type. "
89 );
90
91 return *static_cast<const Value*>(place());
92 }
93
95 template <class Value>
97 {
99 sizeof(Value) <= Capacity,
100 "Capacity of the storage isn't "
101 "sufficient to store values "
102 "of the specified type. "
103 );
104
105 new (place()) Value(value);
106
107 return *this;
108 }
109};
110
#define ONIXS_SASSERT_MSG(expression, message)
Definition Assertion.h:36
#define ONIXS_CMEMDHFIX_NAMESPACE_BEGIN
Definition Bootstrap.h:70
#define ONIXS_CMEMDH_LTWT
Definition Bootstrap.h:46
#define ONIXS_CMEMDHFIX_NAMESPACE_END
Definition Bootstrap.h:71
ValueContainer()
Initializes the container.
Value & get()
Provides access to the value stored in the container assuming the value is of the specified type.
ValueContainer & assign(const Value &value)
Stores the given value in the container.
const Value & get() const
Provides access to the value stored in the container assuming the value is of the specified type.
bool value(Number &number, const MultiContainer &container, Tag tag)
Finds a tag-value entry in the given collection by the given tag and returns its value component tran...
UInt8 Byte
Alias for Byte.
Definition Memory.h:30