tudocomp
– The TU Dortmund Compression Framework
tdc::ConstGenericView< uliteral_t > Class Template Reference

A const view into a slice of memory. More...

#include <GenericConstU8View.hpp>

Inheritance diagram for tdc::ConstGenericView< uliteral_t >:
tdc::GenericViewBase< uliteral_t, const uliteral_t * >

Public Types

using value_type = typename Super::value_type
 
using const_reference = typename Super::const_reference
 
using const_pointer = typename Super::const_pointer
 
using const_iterator = typename Super::const_iterator
 
using const_reverse_iterator = typename Super::const_reverse_iterator
 
using difference_type = typename Super::difference_type
 
using size_type = typename Super::size_type
 

Public Member Functions

 ConstGenericView ()
 Construct a empty View. More...
 
 ConstGenericView (const uliteral_t *data, size_t len)
 Construct a View pointing at len elements starting from data More...
 
 ConstGenericView (const ConstGenericView &other)
 Construct a View as a copy of other More...
 
 ConstGenericView (const GenericView< uliteral_t > &other)
 Construct a View as a copy of other More...
 
 ConstGenericView (const std::vector< uliteral_t > &other)
 Construct a View pointing at the contents of a vector. More...
 
template<size_t N>
 ConstGenericView (const std::array< uliteral_t, N > &other)
 Construct a View pointing at the contents of a array. More...
 
 operator std::vector< uliteral_t > () const
 Construct a vector with the contents of this View. More...
 
const_iterator begin () const
 Begin of iterator. More...
 
const_iterator end () const
 End of iterator. More...
 
const_reverse_iterator rbegin () const
 Begin of reverse iterator. More...
 
const_reverse_iterator rend () const
 End of reverse iterator. More...
 
const_iterator cbegin () const
 Begin of const iterator. More...
 
const_iterator cend () const
 End of const iterator. More...
 
const_reverse_iterator crbegin () const
 Begin of const reverse iterator. More...
 
const_reverse_iterator crend () const
 End of const reverse iterator. More...
 
size_type size () const
 Returns size of the View. More...
 
size_type max_size () const
 Returns max size of the View. Always the same as size() More...
 
bool empty () const
 Returns true if empty. More...
 
const_reference operator[] (size_type pos) const
 Access the element at pos More...
 
const_reference at (size_type pos) const
 Access the element at pos More...
 
const_reference front () const
 Access the first element. More...
 
const_reference back () const
 Access the last element. More...
 
const value_typedata () const noexcept
 The backing memory location. More...
 
void pop_back ()
 Remove the last element from the View. More...
 
void pop_front ()
 Remove the first element from the View. More...
 
void swap (ConstGenericView &other)
 Swap two Views. More...
 
void clear ()
 Sets the size to 0. More...
 
ConstGenericView substr (size_type pos, size_type len=npos) const
 Construct a new View that is a sub view into the current one. More...
 
ConstGenericView slice (size_type from, size_type to=npos) const
 Construct a new View that is a sub view into the current one. More...
 
void remove_prefix (size_type n)
 Removes the first n elements from the View. More...
 
void remove_suffix (size_type n)
 Removes the last n elements from the View. More...
 
bool starts_with (const uliteral_t &other) const
 Returns true if the View starts with the literal other More...
 
bool starts_with (const ConstGenericView< uliteral_t > &other) const
 Returns true if the View starts with the sequence of literals contained in other. More...
 
bool ends_with (const uliteral_t &other) const
 Returns true if the View ends with the literal other More...
 
bool ends_with (const ConstGenericView< uliteral_t > &other) const
 Returns true if the View ends with the sequence of literals contained in other. More...
 
 ConstGenericView (const std::string &other)
 Construct a View pointing at the contents of a string. More...
 
 ConstGenericView (const char *other)
 Construct a View pointing at a C-style null terminated string. More...
 
 ConstGenericView (const char *data, size_t len)
 Construct a View pointing at len elements starting from data More...
 
 operator std::string () const
 Construct a string with the contents of this View. More...
 

Static Public Attributes

static const size_type npos = Super::npos
 Sentinel value indicating a index at the end of the view. More...
 

Friends

class GenericView< uliteral_t >
 
template<class U >
void swap (ConstGenericView< U > &lhs, ConstGenericView< U > &rhs)
 
bool operator== (const ConstGenericView< uliteral_t > &lhs, const ConstGenericView< uliteral_t > &rhs)
 
bool operator!= (const ConstGenericView< uliteral_t > &lhs, const ConstGenericView< uliteral_t > &rhs)
 
bool operator< (const ConstGenericView< uliteral_t > &lhs, const ConstGenericView< uliteral_t > &rhs)
 
bool operator<= (const ConstGenericView< uliteral_t > &lhs, const ConstGenericView< uliteral_t > &rhs)
 
bool operator> (const ConstGenericView< uliteral_t > &lhs, const ConstGenericView< uliteral_t > &rhs)
 
bool operator>= (const ConstGenericView< uliteral_t > &lhs, const ConstGenericView< uliteral_t > &rhs)
 

Detailed Description

template<>
class tdc::ConstGenericView< uliteral_t >

A const view into a slice of memory.

This is an abstraction around a const pointer to T and a size, and represents N elements consecutive in memory.

Creating/Copying/Modifying a View will not copy any of the data it points at. Its API mostly mirrors that of a std::vector<T>.

Definition at line 31 of file GenericConstU8View.hpp.

Member Typedef Documentation

Definition at line 49 of file GenericConstU8View.hpp.

Definition at line 43 of file GenericConstU8View.hpp.

Constructor & Destructor Documentation

Construct a empty View.

Definition at line 55 of file GenericConstU8View.hpp.

tdc::ConstGenericView< uliteral_t >::ConstGenericView ( const uliteral_t data,
size_t  len 
)
inline

Construct a View pointing at len elements starting from data

Definition at line 59 of file GenericConstU8View.hpp.

Construct a View as a copy of other

Definition at line 63 of file GenericConstU8View.hpp.

Construct a View as a copy of other

Definition at line 67 of file GenericConstU8View.hpp.

tdc::ConstGenericView< uliteral_t >::ConstGenericView ( const std::vector< uliteral_t > &  other)
inline

Construct a View pointing at the contents of a vector.

Definition at line 71 of file GenericConstU8View.hpp.

template<size_t N>
tdc::ConstGenericView< uliteral_t >::ConstGenericView ( const std::array< uliteral_t, N > &  other)
inline

Construct a View pointing at the contents of a array.

Definition at line 76 of file GenericConstU8View.hpp.

tdc::ConstGenericView< uliteral_t >::ConstGenericView ( const std::string &  other)
inline

Construct a View pointing at the contents of a string.

Definition at line 271 of file GenericConstU8View.hpp.

tdc::ConstGenericView< uliteral_t >::ConstGenericView ( const char *  other)
inline

Construct a View pointing at a C-style null terminated string.

Can be used to construct from a string literal

Definition at line 277 of file GenericConstU8View.hpp.

tdc::ConstGenericView< uliteral_t >::ConstGenericView ( const char *  data,
size_t  len 
)
inline

Construct a View pointing at len elements starting from data

Definition at line 281 of file GenericConstU8View.hpp.

Member Function Documentation

Access the element at pos

This method is always bounds checked

Definition at line 149 of file GenericConstU8View.hpp.

Access the last element.

Definition at line 159 of file GenericConstU8View.hpp.

const_iterator tdc::ConstGenericView< uliteral_t >::begin ( ) const
inline

Begin of iterator.

Definition at line 85 of file GenericConstU8View.hpp.

const_iterator tdc::ConstGenericView< uliteral_t >::cbegin ( ) const
inline

Begin of const iterator.

Definition at line 105 of file GenericConstU8View.hpp.

const_iterator tdc::ConstGenericView< uliteral_t >::cend ( ) const
inline

End of const iterator.

Definition at line 110 of file GenericConstU8View.hpp.

void tdc::ConstGenericView< uliteral_t >::clear ( )
inline

Sets the size to 0.

Definition at line 184 of file GenericConstU8View.hpp.

Begin of const reverse iterator.

Definition at line 115 of file GenericConstU8View.hpp.

End of const reverse iterator.

Definition at line 120 of file GenericConstU8View.hpp.

const value_type* tdc::ConstGenericView< uliteral_t >::data ( ) const
inlinenoexcept

The backing memory location.

Definition at line 164 of file GenericConstU8View.hpp.

bool tdc::ConstGenericView< uliteral_t >::empty ( ) const
inline

Returns true if empty.

Definition at line 135 of file GenericConstU8View.hpp.

End of iterator.

Definition at line 90 of file GenericConstU8View.hpp.

bool tdc::ConstGenericView< uliteral_t >::ends_with ( const uliteral_t other) const
inline

Returns true if the View ends with the literal other

Definition at line 242 of file GenericConstU8View.hpp.

bool tdc::ConstGenericView< uliteral_t >::ends_with ( const ConstGenericView< uliteral_t > &  other) const
inline

Returns true if the View ends with the sequence of literals contained in other.

Definition at line 248 of file GenericConstU8View.hpp.

const_reference tdc::ConstGenericView< uliteral_t >::front ( ) const
inline

Access the first element.

Definition at line 154 of file GenericConstU8View.hpp.

size_type tdc::ConstGenericView< uliteral_t >::max_size ( ) const
inline

Returns max size of the View. Always the same as size()

Definition at line 130 of file GenericConstU8View.hpp.

tdc::ConstGenericView< uliteral_t >::operator std::string ( ) const
inline

Construct a string with the contents of this View.

Definition at line 285 of file GenericConstU8View.hpp.

tdc::ConstGenericView< uliteral_t >::operator std::vector< uliteral_t > ( ) const
inline

Construct a vector with the contents of this View.

Definition at line 80 of file GenericConstU8View.hpp.

const_reference tdc::ConstGenericView< uliteral_t >::operator[] ( size_type  pos) const
inline

Access the element at pos

This method is bounds checked in debug builds

Definition at line 142 of file GenericConstU8View.hpp.

void tdc::ConstGenericView< uliteral_t >::pop_back ( )
inline

Remove the last element from the View.

Definition at line 169 of file GenericConstU8View.hpp.

void tdc::ConstGenericView< uliteral_t >::pop_front ( )
inline

Remove the first element from the View.

Definition at line 174 of file GenericConstU8View.hpp.

Begin of reverse iterator.

Definition at line 95 of file GenericConstU8View.hpp.

void tdc::ConstGenericView< uliteral_t >::remove_prefix ( size_type  n)
inline

Removes the first n elements from the View.

Definition at line 221 of file GenericConstU8View.hpp.

void tdc::ConstGenericView< uliteral_t >::remove_suffix ( size_type  n)
inline

Removes the last n elements from the View.

Definition at line 226 of file GenericConstU8View.hpp.

End of reverse iterator.

Definition at line 100 of file GenericConstU8View.hpp.

size_type tdc::ConstGenericView< uliteral_t >::size ( ) const
inline

Returns size of the View.

Definition at line 125 of file GenericConstU8View.hpp.

ConstGenericView tdc::ConstGenericView< uliteral_t >::slice ( size_type  from,
size_type  to = npos 
) const
inline

Construct a new View that is a sub view into the current one.

The returned view will be a "from-to" slice, and cover the bytes starting at from and ending just before to. T.slice(a,b) gives T[a..b-1]

Passing npos to to will create a slice until the end of the View

Example

View("abcd").slice(1, 3) == View("bc")

Definition at line 216 of file GenericConstU8View.hpp.

bool tdc::ConstGenericView< uliteral_t >::starts_with ( const uliteral_t other) const
inline

Returns true if the View starts with the literal other

Definition at line 231 of file GenericConstU8View.hpp.

bool tdc::ConstGenericView< uliteral_t >::starts_with ( const ConstGenericView< uliteral_t > &  other) const
inline

Returns true if the View starts with the sequence of literals contained in other.

Definition at line 237 of file GenericConstU8View.hpp.

ConstGenericView tdc::ConstGenericView< uliteral_t >::substr ( size_type  pos,
size_type  len = npos 
) const
inline

Construct a new View that is a sub view into the current one.

The returned view will be a "position-length" slice, and cover the bytes starting at pos and ending at pos + len.

Passing npos to len will create a slice until the end of the View

This method covers the same basic operation as slice(), but mirrors the semantic of std::string::substr.

Example

View("abcd").substr(1, 2) == View("bc")

Definition at line 201 of file GenericConstU8View.hpp.

void tdc::ConstGenericView< uliteral_t >::swap ( ConstGenericView< uliteral_t > &  other)
inline

Swap two Views.

Definition at line 179 of file GenericConstU8View.hpp.

Friends And Related Function Documentation

friend class GenericView< uliteral_t >
friend

Definition at line 34 of file GenericConstU8View.hpp.

bool operator!= ( const ConstGenericView< uliteral_t > &  lhs,
const ConstGenericView< uliteral_t > &  rhs 
)
friend

Definition at line 296 of file GenericConstU8View.hpp.

bool operator< ( const ConstGenericView< uliteral_t > &  lhs,
const ConstGenericView< uliteral_t > &  rhs 
)
friend

Definition at line 301 of file GenericConstU8View.hpp.

bool operator<= ( const ConstGenericView< uliteral_t > &  lhs,
const ConstGenericView< uliteral_t > &  rhs 
)
friend

Definition at line 306 of file GenericConstU8View.hpp.

bool operator== ( const ConstGenericView< uliteral_t > &  lhs,
const ConstGenericView< uliteral_t > &  rhs 
)
friend

Definition at line 291 of file GenericConstU8View.hpp.

bool operator> ( const ConstGenericView< uliteral_t > &  lhs,
const ConstGenericView< uliteral_t > &  rhs 
)
friend

Definition at line 311 of file GenericConstU8View.hpp.

bool operator>= ( const ConstGenericView< uliteral_t > &  lhs,
const ConstGenericView< uliteral_t > &  rhs 
)
friend

Definition at line 316 of file GenericConstU8View.hpp.

template<class U >
void swap ( ConstGenericView< U > &  lhs,
ConstGenericView< U > &  rhs 
)
friend

Member Data Documentation

const size_type tdc::ConstGenericView< uliteral_t >::npos = Super::npos
static

Sentinel value indicating a index at the end of the view.

Definition at line 52 of file GenericConstU8View.hpp.


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