TPIE

11a2c2d
tpie::stream_position Class Reference

POD object indicating the position of an item in a stream. More...

#include <tpie/compressed/stream_position.h>

Public Member Functions

 stream_position ()
 Default constructor resulting in a not-a-stream_position. More...
 
stream_size_type offset () const
 The stream offset of the item pointed to. More...
 
bool operator== (const stream_position &other) const
 
bool operator!= (const stream_position &other) const
 
bool operator< (const stream_position &other) const
 Total ordering of stream_position objects. More...
 

Static Public Member Functions

static stream_position beginning ()
 Convenience constructor returning a pointer to the beginning. More...
 
static stream_position end ()
 Special-value constructor returning a pointer to the end. More...
 

Friends

class compressed_stream_base_p
 
class compressed_stream_base
 
template<typename T >
class file_stream
 
std::ostream & operator<< (std::ostream &s, const stream_position &p)
 

Detailed Description

POD object indicating the position of an item in a stream.

The object returned by stream_position::beginning is equal to any position object returned by a stream that points to the beginning of the stream.

On the other hand, the object returned by stream_position::end is special: It is never returned by file_stream::get_position; instead, the object tells set_position to perform the equivalent of seek(0, end). The object resulting from the default constructor stream_position() is also special and should never be passed to set_position.

The offset() method of an ordinary stream_position object indicates the offset of the item in the stream that is pointed to. The values stream_position().offset() and stream_position::end().offset() are not well-defined and should not be relied on to have any particular value; instead, check for equality to respectively stream_position() and stream_position::end().

The less-than operator defines a total order and is derived from the values returned by offset() with an implementation-defined tiebreaker in case offset() are equal.

It is guaranteed that any ordinary position is ordered before stream_position::end(), but the ordering of stream_position objects with regards to the special values stream_position() and stream_position::end() may otherwise be subject to change in the future.

Definition at line 72 of file stream_position.h.

Constructor & Destructor Documentation

◆ stream_position()

tpie::stream_position::stream_position ( )
inline

Default constructor resulting in a not-a-stream_position.

Definition at line 103 of file stream_position.h.

104  : m_readOffset(std::numeric_limits<uint64_t>::max())
105  , m_offset(std::numeric_limits<uint64_t>::max())
106  {
107  }

Referenced by beginning(), and end().

Member Function Documentation

◆ beginning()

static stream_position tpie::stream_position::beginning ( )
inlinestatic

Convenience constructor returning a pointer to the beginning.

Definition at line 87 of file stream_position.h.

87  {
88  return stream_position(0, 0);
89  }

References stream_position().

◆ end()

static stream_position tpie::stream_position::end ( )
inlinestatic

Special-value constructor returning a pointer to the end.

Definition at line 94 of file stream_position.h.

94  {
95  return stream_position(
96  std::numeric_limits<uint64_t>::max() - 1,
97  std::numeric_limits<uint64_t>::max() - 1);
98  }

References stream_position().

◆ offset()

stream_size_type tpie::stream_position::offset ( ) const
inline

The stream offset of the item pointed to.

Definition at line 125 of file stream_position.h.

125  {
126  return m_offset;
127  }

◆ operator<()

bool tpie::stream_position::operator< ( const stream_position other) const
inline

Total ordering of stream_position objects.

See the class documentation for more information.

Definition at line 153 of file stream_position.h.

153  {
154  return (m_offset != other.m_offset)
155  ? (m_offset < other.m_offset)
156  : (m_readOffset < other.m_readOffset);
157  }

The documentation for this class was generated from the following file:
tpie::stream_position::stream_position
stream_position()
Default constructor resulting in a not-a-stream_position.
Definition: stream_position.h:103