OnixS ICE iMpact Multicast Price Feed Handler C++ library 8.18.0
API documentation
Loading...
Searching...
No Matches
Containers.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Onix Solutions Limited. All rights reserved.
3 *
4 * This software owned by Onix Solutions Limited and is protected by copyright law
5 * and international copyright treaties.
6 *
7 * Access to and use of the software is governed by the terms of the applicable ONIXS Software
8 * Services Agreement (the Agreement) and Customer end user license agreements granting
9 * a non-assignable, non-transferable and non-exclusive license to use the software
10 * for it's own data processing purposes under the terms defined in the Agreement.
11 *
12 * Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13 * of this source code or associated reference material to any other location for further reproduction
14 * or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15 *
16 * Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17 * the terms of the Agreement is a violation of copyright law.
18 */
19
20#pragma once
21
22#include <stdexcept>
23
24namespace OnixS { namespace ICE { namespace iMpact { namespace MarketData {
25
28template <typename ItemType, typename SizeType>
30{
31public:
32 typedef ItemType Item;
33 typedef ItemType* Iterator;
34
35 typedef SizeType Index;
36 typedef SizeType Size;
37
40 : items_(0)
41 , size_(0)
42 {
43 }
44
46 ArrayRef(Item* const items, const Size itemsCount)
47 : items_(items)
48 , size_(itemsCount)
49 {
50 }
51
53 template <typename OtherItem, typename OtherSize>
55 : items_(other.items())
56 , size_(other.size())
57 {
58 }
59
61 template <typename OtherItem, typename OtherSize>
63 {
64 items_ = other.items();
65 size_ = other.size();
66
67 return *this;
68 }
69
72
74 bool empty() const
75 {
76 return (0 == size_);
77 }
78
80 Size size() const
81 {
82 return size_;
83 }
84
86 Item* items() const
87 {
88 return items_;
89 }
90
93 {
94 return items_;
95 }
96
98 Iterator end() const
99 {
100 return (items_ + size_);
101 }
102
104 Item& operator[](Index index) const
105 {
106 return items_[index];
107 }
108
110 Item& at(const Index index) const
111 {
112 if (index < size_)
113 {
114 return items_[index];
115 }
116
117 throw std::out_of_range("Index outside of range.");
118 }
119
121 void reset(Item* const items = 0, const Size size = 0)
122 {
123 items_ = items;
124 size_ = size;
125 }
126
127protected:
130};
131
132}}}} // namespace OnixS::ICE::iMpact::MarketData
ArrayRef(const ArrayRef< OtherItem, OtherSize > &other)
Initializes instance as copy of other one.
Definition Containers.h:54
Iterator begin() const
Iterator referencing to the first item.
Definition Containers.h:92
Item & operator[](Index index) const
Accesses to item by index.
Definition Containers.h:104
ArrayRef & operator=(const ArrayRef< OtherItem, OtherSize > &other)
Re-initializes instance as copy of the other one.
Definition Containers.h:62
Item & at(const Index index) const
Accesses to item by index checking access bounds.
Definition Containers.h:110
ArrayRef(Item *const items, const Size itemsCount)
Initializes instance referencing to given data.
Definition Containers.h:46
Iterator end() const
Iterator referencing to the item behind the last item.
Definition Containers.h:98
bool empty() const
Indicates whether array has no items.
Definition Containers.h:74
void reset(Item *const items=0, const Size size=0)
Resets array with new items and size.
Definition Containers.h:121
~ArrayRef()
Destructs the instance.
Definition Containers.h:71
ArrayRef()
Initializes instance referencing to nothing.
Definition Containers.h:39