29 #ifndef EXIV2_INCLUDE_SLICE_HPP 30 #define EXIV2_INCLUDE_SLICE_HPP 99 throw std::out_of_range(
"Begin must be smaller than end");
106 inline size_t size()
const throw()
121 if (index >=
size()) {
122 throw std::out_of_range(
"Index outside of the slice");
159 template <
template <
typename data_type>
class storage_type,
typename data_type>
162 typedef typename storage_type<data_type>::iterator iterator;
163 typedef typename storage_type<data_type>::const_iterator const_iterator;
164 typedef typename storage_type<data_type>::value_type value_type;
182 const value_type&
at(
size_t index)
const 203 const_iterator
cend()
const throw()
205 return storage_.unsafeGetIteratorAt(end_);
216 template <
typename slice_type>
217 slice_type
subSlice(
size_t begin,
size_t end)
const 226 const size_t new_begin = begin + this->
begin_;
227 const size_t new_end = this->begin_ + end;
228 if (new_end > this->end_) {
229 throw std::out_of_range(
"Invalid input parameters to slice");
231 return slice_type(
storage_.data_, new_begin, new_end);
246 template <
template <
typename>
class storage_type,
typename data_type>
249 typedef typename ConstSliceBase<storage_type, data_type>::iterator iterator;
250 typedef typename ConstSliceBase<storage_type, data_type>::const_iterator const_iterator;
251 typedef typename ConstSliceBase<storage_type, data_type>::value_type value_type;
269 value_type&
at(
size_t index)
275 const value_type&
at(
size_t index)
const 294 return this->
storage_.unsafeGetIteratorAt(this->end_);
330 template <
typename slice_type>
342 const size_t new_end = this->begin_ +
end;
343 if (new_end > this->end_) {
344 throw std::out_of_range(
"Invalid input parameters to slice");
346 return slice_type(this->
storage_.data_, new_begin, new_end);
355 template <
typename container>
358 typedef typename container::iterator iterator;
360 typedef typename container::const_iterator const_iterator;
362 typedef typename Internal::remove_cv<typename container::value_type>::type value_type;
370 if (end > data.size()) {
371 throw std::out_of_range(
"Invalid input parameters to slice");
383 return data_.at(index);
388 return data_.at(index);
400 assert(index <= data_.size());
402 iterator it = data_.begin();
403 std::advance(it, index);
409 assert(index <= data_.size());
411 const_iterator it = data_.begin();
412 std::advance(it, index);
426 template <
typename storage_type>
430 typedef value_type* iterator;
431 typedef const value_type* const_iterator;
443 throw std::invalid_argument(
"Null pointer passed to slice constructor");
458 const value_type&
unsafeAt(
size_t index)
const throw()
471 return data_ + index;
476 return data_ + index;
528 template <
typename container>
531 typedef typename container::iterator iterator;
533 typedef typename container::const_iterator const_iterator;
535 typedef typename Internal::remove_cv<typename container::value_type>::type value_type;
586 template <
typename container>
589 typedef typename container::iterator iterator;
591 typedef typename container::const_iterator const_iterator;
593 typedef typename Internal::remove_cv<typename container::value_type>::type value_type;
603 const container>::template subSlice<Slice<const container> >(
begin,
end);
615 template <
typename T>
630 Slice(
const T* ptr,
size_t begin,
size_t end)
646 template <
typename T>
649 Slice(T* ptr,
size_t begin,
size_t end)
655 Slice<T*> subSlice(
size_t begin,
size_t end)
662 return this->to_const_base().template subSlice<Slice<const T*> >(begin, end);
672 template <
typename T>
681 template <
typename T>
690 template <
typename container>
700 template <
typename container>
709 template <
typename container>
718 template <
typename T>
iterator unsafeGetIteratorAt(size_t index)
Definition: slice.hpp:397
value_type & unsafeAt(size_t index)
Definition: slice.hpp:453
Slice (= view) for STL containers.
Definition: slice.hpp:529
Slice< container > makeSliceUntil(container &cont, size_t end)
Return a new slice spanning until end.
Definition: slice.hpp:710
PtrSliceStorage(storage_type ptr, size_t, size_t)
Definition: slice.hpp:439
Slice(const T *ptr, size_t begin, size_t end)
Definition: slice.hpp:630
Definition: slice.hpp:616
Specialization of slices for constant containers.
Definition: slice.hpp:587
storage_type< data_type > storage_
Definition: slice.hpp:238
ConstSliceBase(data_type &data, size_t begin, size_t end)
Definition: slice.hpp:171
const value_type & at(size_t index) const
Definition: slice.hpp:182
iterator unsafeGetIteratorAt(size_t index)
Definition: slice.hpp:469
Implementation of the storage concept for slices of C arrays.
Definition: slice.hpp:427
ConstSliceBase< storage_type, const data_type > to_const_base() const
Definition: slice.hpp:315
iterator begin()
Definition: slice.hpp:284
Slice< container > makeSliceFrom(container &cont, size_t begin)
Return a new slice spanning from begin until the end of the container.
Definition: slice.hpp:701
slice_type subSlice(size_t begin, size_t end)
Definition: slice.hpp:331
Definition: slice.hpp:247
Slice< const container > subSlice(size_t begin, size_t end) const
Definition: slice.hpp:577
Definition: slice.hpp:356
size_t size() const
Definition: slice.hpp:106
const_iterator cbegin() const
Definition: slice.hpp:195
void rangeCheck(size_t index) const
Definition: slice.hpp:119
const value_type & unsafeAt(size_t index) const
Definition: slice.hpp:381
This class provides the public-facing const-qualified methods of a slice.
Definition: slice.hpp:160
Slice< T > makeSlice(T &cont, size_t begin, size_t end)
Return a new slice with the given bounds.
Definition: slice.hpp:673
const size_t begin_
Definition: slice.hpp:130
slice_type subSlice(size_t begin, size_t end) const
Definition: slice.hpp:217
Slice subSlice(size_t begin, size_t end)
Definition: slice.hpp:567
Provides classes and functions to encode and decode Exif and Iptc data. The libexiv2 API consists of ...
Definition: asfvideo.hpp:36
value_type & at(size_t index)
Definition: slice.hpp:269
Slice(container &cont, size_t begin, size_t end)
Construct a slice of the container cont starting at begin (including) and ending before end...
Definition: slice.hpp:553
iterator end()
Definition: slice.hpp:292
ContainerStorage(container &data, size_t, size_t end)
Definition: slice.hpp:368
const_iterator cend() const
Definition: slice.hpp:203
Definition: slice.hpp:647
MutableSliceBase(data_type &data, size_t begin, size_t end)
Definition: slice.hpp:258