Public Types | Public Member Functions | Data Fields

ts::Buffer Struct Reference

A chunk of writable memory. More...

#include <TsBuffer.h>

Public Types

typedef Buffer self
 Self reference type.
typedef bool(self::* pseudo_bool )() const

Public Member Functions

 Buffer ()
 Default constructor (empty buffer).
 Buffer (char *ptr, size_t n)
 Construct from pointer and size.
 Buffer (char *start, char *end)
 Construct from two pointers.
bool operator== (self const &that) const
 Equality.
bool operator!= (self const &that) const
 Inequality.
bool operator== (ConstBuffer const &that) const
 Equality for a constant buffer.
bool operator!= (ConstBuffer const &that) const
 Inequality.
char operator* () const
selfoperator++ ()
 Discard the first character in the buffer.
bool operator! () const
 Check for empty buffer.
 operator pseudo_bool () const
 Check for non-empty buffer.
selfset (char *ptr, size_t n=0)
 Set the chunk.
selfreset ()
 Reset to empty.
Accessors.

char * data () const
 Get the data in the buffer.
size_t size () const
 Get the size of the buffer.

Data Fields

char * _ptr
 Pointer to base of memory chunk.
size_t _size
 Size of memory chunk.

Detailed Description

A chunk of writable memory.

A convenience class because we pass this kind of pair frequently.

Note:
The default construct leaves the object uninitialized. This is for performance reasons. To construct an empty Buffer use Buffer(0).

Definition at line 48 of file TsBuffer.h.


Member Typedef Documentation

typedef bool(self::* ts::Buffer::pseudo_bool)() const

Definition at line 50 of file TsBuffer.h.

Self reference type.

Definition at line 49 of file TsBuffer.h.


Constructor & Destructor Documentation

ts::Buffer::Buffer (  )  [inline]

Default constructor (empty buffer).

Definition at line 298 of file TsBuffer.h.

ts::Buffer::Buffer ( char *  ptr,
size_t  n 
) [inline]

Construct from pointer and size.

Note:
Due to ambiguity issues do not call this with two arguments if the first argument is 0.
Parameters:
ptr Pointer to buffer.
n Size of buffer.

Definition at line 299 of file TsBuffer.h.

ts::Buffer::Buffer ( char *  start,
char *  end 
) [inline]

Construct from two pointers.

Note:
This presumes a half open range, (start, end]
Parameters:
start First valid character.
end First invalid character.

Definition at line 301 of file TsBuffer.h.


Member Function Documentation

char * ts::Buffer::data (  )  const [inline]

Get the data in the buffer.

Definition at line 319 of file TsBuffer.h.

References _ptr.

ts::Buffer::operator pseudo_bool (  )  const [inline]

Check for non-empty buffer.

Returns:
true if the buffer has a non-zero pointer and size.

Definition at line 312 of file TsBuffer.h.

References _ptr, and _size.

bool ts::Buffer::operator! (  )  const [inline]

Check for empty buffer.

Returns:
true if the buffer has a zero pointer or size.

Definition at line 311 of file TsBuffer.h.

References _ptr, and _size.

bool ts::Buffer::operator!= ( ConstBuffer const &  that  )  const [inline]

Inequality.

Returns:
true if that does not refer to the same memory as this, false otherwise.

Definition at line 304 of file TsBuffer.h.

bool ts::Buffer::operator!= ( self const &  that  )  const [inline]

Inequality.

Returns:
true if that does not refer to the same memory as this, false otherwise.

Definition at line 303 of file TsBuffer.h.

char ts::Buffer::operator* (  )  const [inline]
Returns:
The first character in the buffer.

Definition at line 313 of file TsBuffer.h.

References _ptr.

Buffer & ts::Buffer::operator++ (  )  [inline]

Discard the first character in the buffer.

Returns:
this object.

Definition at line 314 of file TsBuffer.h.

References _ptr, and _size.

bool ts::Buffer::operator== ( self const &  that  )  const [inline]

Equality.

Returns:
true if that refers to the same memory as this, false otherwise.

Definition at line 305 of file TsBuffer.h.

References _ptr, and _size.

bool ts::Buffer::operator== ( ConstBuffer const &  that  )  const [inline]

Equality for a constant buffer.

Returns:
true if that refers to the same memory as this. false otherwise.

Definition at line 308 of file TsBuffer.h.

References ts::ConstBuffer::_ptr, _ptr, ts::ConstBuffer::_size, and _size.

Buffer & ts::Buffer::reset (  )  [inline]

Reset to empty.

Definition at line 302 of file TsBuffer.h.

References _ptr, and _size.

Referenced by ts::config::Builder::pathClose(), and ts::config::Builder::pathOpen().

Buffer & ts::Buffer::set ( char *  ptr,
size_t  n = 0 
) [inline]

Set the chunk.

Any previous values are discarded.

Returns:
this object.
Parameters:
ptr Buffer address.
n Buffer size.

Definition at line 300 of file TsBuffer.h.

References _ptr, and _size.

Referenced by ts::config::Builder::groupName(), ts::config::Builder::literalValue(), ts::config::Builder::pathIndex(), and ts::config::Builder::pathTag().

size_t ts::Buffer::size ( void   )  const [inline]

Get the size of the buffer.

Definition at line 320 of file TsBuffer.h.

References _size.


Field Documentation


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