Exiv2::Internal::MutableSliceBase< storage_type, data_type > Struct Template Reference

#include <slice.hpp>

Inheritance diagram for Exiv2::Internal::MutableSliceBase< storage_type, data_type >:

Public Types

using iterator = typename ConstSliceBase< storage_type, data_type >::iterator
 
using const_iterator = typename ConstSliceBase< storage_type, data_type >::const_iterator
 
using value_type = typename ConstSliceBase< storage_type, data_type >::value_type
 
- Public Types inherited from Exiv2::Internal::ConstSliceBase< storage_type, data_type >
using iterator = typename storage_type< data_type >::iterator
 
using const_iterator = typename storage_type< data_type >::const_iterator
 
using value_type = typename storage_type< data_type >::value_type
 

Public Member Functions

value_type & at (size_t index)
 
const value_type & at (size_t index) const
 
iterator begin () noexcept
 
iterator end () noexcept
 
- Public Member Functions inherited from Exiv2::Internal::ConstSliceBase< storage_type, data_type >
 ConstSliceBase (data_type &data, size_t begin, size_t end)
 
const value_type & at (size_t index) const
 
const_iterator cbegin () const noexcept
 
const_iterator cend () const noexcept
 
template<typename slice_type >
slice_type subSlice (size_t begin, size_t end) const
 
- Public Member Functions inherited from Exiv2::Internal::SliceBase
 SliceBase (size_t begin, size_t end)
 
size_t size () const noexcept
 

Protected Types

using base_type = ConstSliceBase< storage_type, data_type >
 

Protected Member Functions

ConstSliceBase< storage_type, const data_type > to_const_base () const noexcept
 
template<typename slice_type >
slice_type subSlice (size_t begin, size_t end)
 
- Protected Member Functions inherited from Exiv2::Internal::SliceBase
void rangeCheck (size_t index) const
 

Additional Inherited Members

- Protected Attributes inherited from Exiv2::Internal::ConstSliceBase< storage_type, data_type >
storage_type< data_type > storage_
 
- Protected Attributes inherited from Exiv2::Internal::SliceBase
size_t begin_
 
size_t end_
 

Detailed Description

template<template< typename > class storage_type, typename data_type>
struct Exiv2::Internal::MutableSliceBase< storage_type, data_type >

This class provides all public-facing non-const-qualified methods of slices. It only re-implements the const-qualified versions as non-const.

Member Function Documentation

◆ at()

template<template< typename > class storage_type, typename data_type >
value_type& Exiv2::Internal::MutableSliceBase< storage_type, data_type >::at ( size_t  index)
inline

Obtain a reference to the element with the specified index in the slice.

Exceptions
std::out_of_rangewhen index is out of bounds of the slice

References Exiv2::Internal::SliceBase::begin_, Exiv2::Internal::SliceBase::rangeCheck(), and Exiv2::Internal::ConstSliceBase< storage_type, data_type >::storage_.

Referenced by Exiv2::getUShort().

◆ begin()

template<template< typename > class storage_type, typename data_type >
iterator Exiv2::Internal::MutableSliceBase< storage_type, data_type >::begin ( )
inlinenoexcept

◆ end()

template<template< typename > class storage_type, typename data_type >
iterator Exiv2::Internal::MutableSliceBase< storage_type, data_type >::end ( )
inlinenoexcept

◆ subSlice()

template<template< typename > class storage_type, typename data_type >
template<typename slice_type >
slice_type Exiv2::Internal::MutableSliceBase< storage_type, data_type >::subSlice ( size_t  begin,
size_t  end 
)
inlineprotected

Create a mutable sub-slice with the given bounds (with respect to the current slice).

Template Parameters
slice_typeType of the slice that this function shall return. Provide it with the type of the class that derives from mutable_slice_base.

References Exiv2::Internal::MutableSliceBase< storage_type, data_type >::begin(), Exiv2::Internal::SliceBase::begin_, Exiv2::Internal::MutableSliceBase< storage_type, data_type >::end(), Exiv2::Internal::SliceBase::rangeCheck(), and Exiv2::Internal::ConstSliceBase< storage_type, data_type >::storage_.

◆ to_const_base()

template<template< typename > class storage_type, typename data_type >
ConstSliceBase<storage_type, const data_type> Exiv2::Internal::MutableSliceBase< storage_type, data_type >::to_const_base ( ) const
inlineprotectednoexcept

Explicitly convert this instance into a base-class of the appropriate constant version of this slice.

This function is required to properly implement the subSlice() const function for mutable slices. The problem here is, that a slice<T> and a slice<const T> actually don't share the same base class ConstSliceBase<storage_type, T>. Instead slice<T> inherits from ConstSliceBase<storage_type, T> and slice<const T> inherits from ConstSliceBase<storage_type, const T>.

Now, slice<T> can call the subSlice() const method from its base class, but that will return a mutable slice<T>! Instead we use this function to convert the `slice<T> into the parent of the appropriate slice<const T> and call its subSlice() const, which returns the correct type.

References Exiv2::Internal::SliceBase::begin_, and Exiv2::Internal::ConstSliceBase< storage_type, data_type >::storage_.


The documentation for this struct was generated from the following file: