21#ifndef EXIV2_INCLUDE_SLICE_HPP
22#define EXIV2_INCLUDE_SLICE_HPP
91 throw std::out_of_range(
"Begin must be smaller than end");
98 inline size_t size()
const throw()
113 if (index >=
size()) {
114 throw std::out_of_range(
"Index outside of the slice");
151 template <
template <
typename data_type>
class storage_type,
typename data_type>
154 typedef typename storage_type<data_type>::iterator iterator;
155 typedef typename storage_type<data_type>::const_iterator const_iterator;
156 typedef typename storage_type<data_type>::value_type value_type;
174 const value_type&
at(
size_t index)
const
195 const_iterator
cend()
const throw()
197 return storage_.unsafeGetIteratorAt(end_);
208 template <
typename slice_type>
209 slice_type
subSlice(
size_t begin,
size_t end)
const
218 const size_t new_begin = begin + this->
begin_;
219 const size_t new_end = this->begin_ + end;
220 if (new_end > this->end_) {
221 throw std::out_of_range(
"Invalid input parameters to slice");
223 return slice_type(
storage_.data_, new_begin, new_end);
238 template <
template <
typename>
class storage_type,
typename data_type>
241 typedef typename ConstSliceBase<storage_type, data_type>::iterator iterator;
242 typedef typename ConstSliceBase<storage_type, data_type>::const_iterator const_iterator;
243 typedef typename ConstSliceBase<storage_type, data_type>::value_type value_type;
261 value_type&
at(
size_t index)
267 const value_type&
at(
size_t index)
const
286 return this->
storage_.unsafeGetIteratorAt(this->end_);
322 template <
typename slice_type>
334 const size_t new_end = this->begin_ +
end;
335 if (new_end > this->end_) {
336 throw std::out_of_range(
"Invalid input parameters to slice");
338 return slice_type(this->
storage_.data_, new_begin, new_end);
347 template <
typename container>
350 typedef typename container::iterator iterator;
352 typedef typename container::const_iterator const_iterator;
354 typedef typename Internal::remove_cv<typename container::value_type>::type value_type;
362 if (end > data.size()) {
363 throw std::out_of_range(
"Invalid input parameters to slice");
375 return data_.at(index);
380 return data_.at(index);
392 assert(index <= data_.size());
394 iterator it = data_.begin();
395 std::advance(it, index);
401 assert(index <= data_.size());
403 const_iterator it = data_.begin();
404 std::advance(it, index);
418 template <
typename storage_type>
422 typedef value_type* iterator;
423 typedef const value_type* const_iterator;
435 throw std::invalid_argument(
"Null pointer passed to slice constructor");
450 const value_type&
unsafeAt(
size_t index)
const throw()
463 return data_ + index;
468 return data_ + index;
520 template <
typename container>
523 typedef typename container::iterator iterator;
525 typedef typename container::const_iterator const_iterator;
527 typedef typename Internal::remove_cv<typename container::value_type>::type value_type;
578 template <
typename container>
581 typedef typename container::iterator iterator;
583 typedef typename container::const_iterator const_iterator;
585 typedef typename Internal::remove_cv<typename container::value_type>::type value_type;
595 const container>::template subSlice<Slice<const container> >(
begin,
end);
607 template <
typename T>
622 Slice(
const T* ptr,
size_t begin,
size_t end)
638 template <
typename T>
641 Slice(T* ptr,
size_t begin,
size_t end)
647 Slice<T*> subSlice(
size_t begin,
size_t end)
654 return this->to_const_base().template subSlice<Slice<const T*> >(begin, end);
664 template <
typename T>
673 template <
typename T>
682 template <
typename container>
692 template <
typename container>
701 template <
typename container>
710 template <
typename T>
Provides classes and functions to encode and decode Exif and Iptc data. The libexiv2 API consists of ...
Definition: asfvideo.hpp:36
Slice< T > makeSlice(T &cont, size_t begin, size_t end)
Return a new slice with the given bounds.
Definition: slice.hpp:665
Slice< container > makeSliceUntil(container &cont, size_t end)
Return a new slice spanning until end.
Definition: slice.hpp:702
Slice< container > makeSliceFrom(container &cont, size_t begin)
Return a new slice spanning from begin until the end of the container.
Definition: slice.hpp:693
This class provides the public-facing const-qualified methods of a slice.
Definition: slice.hpp:153
slice_type subSlice(size_t begin, size_t end) const
Definition: slice.hpp:209
const_iterator cend() const
Definition: slice.hpp:195
storage_type< data_type > storage_
Definition: slice.hpp:230
const value_type & at(size_t index) const
Definition: slice.hpp:174
const_iterator cbegin() const
Definition: slice.hpp:187
ConstSliceBase(data_type &data, size_t begin, size_t end)
Definition: slice.hpp:163
Definition: slice.hpp:349
iterator unsafeGetIteratorAt(size_t index)
Definition: slice.hpp:389
ContainerStorage(container &data, size_t, size_t end)
Definition: slice.hpp:360
const value_type & unsafeAt(size_t index) const
Definition: slice.hpp:373
Definition: slice.hpp:240
iterator begin()
Definition: slice.hpp:276
iterator end()
Definition: slice.hpp:284
MutableSliceBase(data_type &data, size_t begin, size_t end)
Definition: slice.hpp:250
slice_type subSlice(size_t begin, size_t end)
Definition: slice.hpp:323
ConstSliceBase< storage_type, const data_type > to_const_base() const
Definition: slice.hpp:307
value_type & at(size_t index)
Definition: slice.hpp:261
Implementation of the storage concept for slices of C arrays.
Definition: slice.hpp:420
value_type & unsafeAt(size_t index)
Definition: slice.hpp:445
PtrSliceStorage(storage_type ptr, size_t, size_t)
Definition: slice.hpp:431
iterator unsafeGetIteratorAt(size_t index)
Definition: slice.hpp:461
size_t size() const
Definition: slice.hpp:98
const size_t begin_
Definition: slice.hpp:122
void rangeCheck(size_t index) const
Definition: slice.hpp:111
Definition: slice.hpp:640
Definition: slice.hpp:609
Slice(const T *ptr, size_t begin, size_t end)
Definition: slice.hpp:622
Specialization of slices for constant containers.
Definition: slice.hpp:580
Slice (= view) for STL containers.
Definition: slice.hpp:522
Slice subSlice(size_t begin, size_t end)
Definition: slice.hpp:559
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:545
Slice< const container > subSlice(size_t begin, size_t end) const
Definition: slice.hpp:569