35 template <
typename ItemType,
typename SizeType>
106 return (items_ + size_);
112 return (items_ + size_);
134 assert(index < size_);
136 return items_[index];
142 assert(index < size_);
144 return items_[index];
152 return items_[index];
154 throw std::out_of_range(
"Index outside of range.");
159 const Item&
at(Size index)
const 162 return items_[index];
164 throw std::out_of_range(
"Index outside of range.");
176 assert(index < size_);
178 Item*
const toBeUpdated = items_ + index;
180 Item* target = items_ + size_ - 1;
181 Item* source = target - 1;
183 while (target != toBeUpdated)
187 new (target--) Item(*source--);
196 assert(index < size_);
198 Item*
const theEnd = end();
199 Item*
const toBeErased = items_ + index;
201 Item* target = toBeErased;
202 Item* source = toBeErased + 1;
204 while (source != theEnd)
208 new (target++) Item(*source++);
220 void resize(Size newSize,
const Item& item = Item())
222 assert(newSize <= capacity_);
226 while (size_ != newSize)
227 new (items_ + size_++) Item(item);
231 while (size_ != newSize)
232 (items_ + --size_)->~Item();
240 const Size capacity_;
248 template <
typename TargetSize,
typename SourceSize>
253 error +=
"Cannot copy items because number " 254 "of source items exceeds target capacity " 257 toStr(error, sourceSize);
259 error +=
",targetCapacity=";
261 toStr(error, targetSize);
265 throw std::runtime_error(error);
271 template <
typename TargetItem,
typename TargetSize,
typename SourceItem,
typename SourceSize>
275 SourceSize itemCount = static_cast<SourceSize>(-1)
278 itemCount = (itemCount > source.
size()) ? source.
size() : itemCount;
291 target[itemCount] = source[itemCount];
bool empty() const
Indicates whether instance has no items.
Implements vector-like container over built-in array of fixed size being referenced.
Item & at(Size index)
Accesses to item by index checking access bounds.
Size capacity() const
Total capacity of container.
Iterator begin()
Iterator referencing to the first item.
VectorOverArray(Item *items, Size capacity)
Initializes instance over given fixed-size array.
#define ONIXS_CMEMDH_NULLPTR
ItemType Item
Aliases container item type.
Item * Iterator
Aliases mutable iterator type.
void erase(Size index)
Erases item at given position.
void throwVectorCopyOverflow(TargetSize targetSize, SourceSize sourceSize)
Iterator end()
Iterator referencing to the item behind the last item.
void toStr(std::string &str, const Message &message)
Serializes FIX message into tag=value format.
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
Size size() const
Number of items.
Item & operator[](Size index)
Accesses to item by index.
const Item & at(Size index) const
Accesses to item by index checking access bounds.
Item & front()
Provides access to the front item if available.
ConstIterator begin() const
Iterator referencing to the first item.
Item & insertExtrude(Size index)
Inserts new item to given position.
VectorOverArray()
Initializes instance with no items.
void resize(Size newSize, const Item &item=Item())
Resizes container.
const Item & front() const
Provides access to the front item if available.
const Item * ConstIterator
Aliases constant iterator type.
ConstIterator end() const
Iterator referencing to the item behind the last item.
~VectorOverArray()
Cleans everything up.
void copy(VectorOverArray< TargetItem, TargetSize > &target, const VectorOverArray< SourceItem, TargetSize > &source, SourceSize itemCount=static_cast< SourceSize >(-1))
Copies items from source to target.
const Item & operator[](Size index) const
Accesses to item by index.
SizeType Size
Aliases dimension type.
#define ONIXS_CMEMDH_NAMESPACE_END