TPIE

2362a60
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
 
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

tpie::stream_position::stream_position ( )
inline

Default constructor resulting in a not-a-stream_position.

Definition at line 101 of file stream_position.h.

Referenced by beginning(), and end().

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

Member Function Documentation

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

Convenience constructor returning a pointer to the beginning.

Definition at line 85 of file stream_position.h.

References stream_position().

85  {
86  return stream_position(0, 0);
87  }
stream_position()
Default constructor resulting in a not-a-stream_position.
static stream_position tpie::stream_position::end ( )
inlinestatic

Special-value constructor returning a pointer to the end.

Definition at line 92 of file stream_position.h.

References stream_position().

Referenced by tpie::file_stream< tpie::stream_position >::set_position().

92  {
93  return stream_position(
94  std::numeric_limits<uint64_t>::max() - 1,
95  std::numeric_limits<uint64_t>::max() - 1);
96  }
stream_position()
Default constructor resulting in a not-a-stream_position.
stream_size_type tpie::stream_position::offset ( ) const
inline

The stream offset of the item pointed to.

Definition at line 123 of file stream_position.h.

Referenced by tpie::file_stream< tpie::stream_position >::describe(), tpie::file_stream< tpie::stream_position >::set_position(), and tpie::file_stream< tpie::stream_position >::truncate().

123  {
124  return m_offset;
125  }
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 151 of file stream_position.h.

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

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