35template <
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.");
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_);
199 Item*
const toBeErased = items_ + index;
201 Item* target = toBeErased;
202 Item* source = toBeErased + 1;
204 while (source != theEnd)
208 new (target++)
Item(*source++);
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_;
248template <
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);
271template <
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];
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
#define ONIXS_CMEMDH_NAMESPACE_END
#define ONIXS_CMEMDH_NULLPTR
Implements vector-like container over built-in array of fixed size being referenced.
void erase(Size index)
Erases item at given position.
Iterator begin()
Iterator referencing to the first item.
const Item & operator[](Size index) const
Accesses to item by index.
void resize(Size newSize, const Item &item=Item())
Item & at(Size index)
Accesses to item by index checking access bounds.
Item & operator[](Size index)
Accesses to item by index.
const Item * ConstIterator
bool empty() const
Indicates whether instance has no items.
ConstIterator end() const
Iterator referencing to the item behind the last item.
VectorOverArray(Item *items, Size capacity)
Initializes instance over given fixed-size array.
Item & insertExtrude(Size index)
Inserts new item to given position.
const Item & front() const
Provides access to the front item if available.
Iterator end()
Iterator referencing to the item behind the last item.
Size size() const
Number of items.
ConstIterator begin() const
Iterator referencing to the first item.
~VectorOverArray()
Cleans everything up.
Item & front()
Provides access to the front item if available.
const Item & at(Size index) const
Accesses to item by index checking access bounds.
VectorOverArray()
Initializes instance with no items.
void throwVectorCopyOverflow(TargetSize targetSize, SourceSize sourceSize)
MboBook & copy(MboBook &target, const MboBook &source)
Copies content of MBO book to the other one.
void toStr(std::string &, BookState::Enum)
Serializes book state value into a string.