Marine Library  1.0
C++ library for Linux Networking Development
Public Types | Public Member Functions | Static Public Attributes | List of all members
CCharBuffer< CharT > Class Template Reference

Provide interfaces similar to std::string for raw byte array. More...

#include <char_buffer.hh>

Public Types

typedef std::char_traits< __Char > traits_type
 
typedef traits_type::char_type value_type
 
typedef value_type & reference
 
typedef const value_type & const_reference
 
typedef value_type * pointer
 
typedef const value_type * const_pointer
 
typedef __gnu_cxx::__normal_iterator< pointer, CCharBufferiterator
 
typedef __gnu_cxx::__normal_iterator< const_pointer, CCharBufferconst_iterator
 
typedef size_t size_type
 
typedef ptrdiff_t difference_type
 
typedef std::reverse_iterator< iterator > reverse_iterator
 
typedef std::reverse_iterator< const_iterator > const_reverse_iterator
 

Public Member Functions

 CCharBuffer ()
 Construct a null object with zero capacity.
 
 CCharBuffer (pointer buf)
 Construct from a C-style string. More...
 
 CCharBuffer (pointer buf, size_type capacity, size_type size=0)
 Construct from a byte buffer. More...
 
__Mytassign (pointer buf, size_type capacity, size_type size=0)
 Set this object to manage a byte buffer. More...
 
__Mytassign (const __Myt &other)
 Set this object to manage a buffer from another object. More...
 
void swap (__Myt &other) throw ()
 Swap two CCharBuffer objects. More...
 
Iterators
iterator begin ()
 Get the beginning of the data. More...
 
iterator end ()
 Get the ending of the data. More...
 
const_iterator begin () const
 Get the beginning of the data. More...
 
const_iterator end () const
 Get the ending of the data. More...
 
reverse_iterator rbegin ()
 Get the ending of the data. More...
 
reverse_iterator rend ()
 Get the beginning of the data. More...
 
const_reverse_iterator rbegin () const
 Get the ending of the data. More...
 
const_reverse_iterator rend () const
 Get the beginning of the data. More...
 
Capacity
bool empty () const
 Test if the data is empty. More...
 
size_type length () const
 Get the size of the data, same as size(). More...
 
size_type size () const
 Get the size of the data. More...
 
size_type capacity () const
 Get the capacity of the underlying byte buffer. More...
 
size_type max_size () const
 Get the maximum number of bytes. More...
 
Element access
reference operator[] (size_type i)
 Access a byte. More...
 
const_reference operator[] (size_type i) const
 Access a byte. More...
 
reference front ()
 Access the first byte. More...
 
const_reference front () const
 Access the first byte. More...
 
reference back ()
 Access the last byte. More...
 
const_reference back () const
 Access the last byte. More...
 
reference at (size_type i)
 Access a certain byte. More...
 
const_reference at (size_type i) const
 Access a certain byte. More...
 
const_pointer c_str () const
 Get the underlying C-style string. More...
 
const_pointer data () const
 Get the data pointer. More...
 
Operations

If any of the following operations makes size exceed capacity, an exception will be thrown to indicate the error.

void clear ()
 Empty the data. More...
 
void resize (size_type count, value_type val=0)
 Resize the data. More...
 
size_type copy (pointer buf, size_type count, size_type offset=0) const
 Copy content of a buffer to self. More...
 
void push_back (value_type val)
 Append a byte to the end of the data. More...
 
__Mytappend (size_type count, value_type val)
 Append a number of bytes to the end of the data. More...
 
__Mytappend (const_pointer buf, size_type count)
 Append content of a buffer to the end of the data. More...
 
__Mytappend (const_pointer buf)
 Append a C-style string to the end of the data. More...
 
__Mytappend (const __Myt &other, size_type offset, size_type count)
 Append content of another CCharBuffer content to the end of the data. More...
 
__Mytappend (const __Myt &other)
 Append content of another CCharBuffer content to the end of the data. More...
 
__Mytoperator+= (const __Myt &other)
 Append content of another CCharBuffer to the end of the data. More...
 
__Mytoperator+= (const_pointer buf)
 Append a C-style string to the end of the data. More...
 
__Mytoperator+= (value_type val)
 Append a byte to the end of the data. More...
 
__Mytinsert (size_type offset, size_type count, value_type val)
 Insert a number of bytes. More...
 
__Mytinsert (size_type offset, const_pointer buf, size_type count)
 Insert the content of a buffer. More...
 
__Mytinsert (size_type offset, const_pointer buf)
 Insert a C-style string. More...
 
__Mytinsert (size_type offset, const __Myt &other, size_type newOffset, size_type count)
 Insert the content of another CCharBuffer. More...
 
__Mytinsert (size_type offset, const __Myt &other)
 Insert the content of another CCharBuffer. More...
 
iterator insert (iterator pos, value_type val)
 Insert a byte. More...
 
__Mytreplace (size_type offset, size_type count, size_type newCount, value_type val)
 Replace a range of bytes with a number of new bytes. More...
 
__Mytreplace (size_type offset, size_type count, const_pointer buf, size_type newCount)
 Replace a range of bytes with the content of a byte buffer. More...
 
__Mytreplace (size_type offset, size_type count, const_pointer buf)
 Replace a range of bytes with the content of a C-style string. More...
 
__Mytreplace (size_type offset, size_type count, const __Myt &other, size_type newOffset, size_type newCount)
 Replace a range of bytes with the content of another CCharBuffer. More...
 
__Mytreplace (size_type offset, size_type count, const __Myt &other)
 Replace a range of bytes with the content of another CCharBuffer. More...
 
__Mytreplace (iterator first, iterator last, size_type count, value_type val)
 Replace a range of bytes with a number of new bytes. More...
 
__Mytreplace (iterator first, iterator last, const_pointer buf, size_type count)
 Replace a range of bytes with the content of a byte buffer. More...
 
__Mytreplace (iterator first, iterator last, const_pointer buf)
 Replace a range of bytes with the content of a C-style string. More...
 
__Mytreplace (iterator first, iterator last, const __Myt &other, size_type offset, size_type count)
 Replace a range of bytes with the content of another CCharBuffer. More...
 
__Mytreplace (iterator first, iterator last, const __Myt &other)
 Replace a range of bytes with the content of another CCharBuffer. More...
 
iterator erase (iterator first, iterator last)
 Erase a range of bytes. More...
 
iterator erase (iterator pos)
 Erase a byte. More...
 
__Myterase (size_type offset=0, size_type count=npos)
 Erase a range of bytes. More...
 
__Myt substr (size_type offset=0, size_type count=npos)
 Get a substring. More...
 
int compare (size_type offset, size_type count, const_pointer buf, size_type newCount) const
 Compare a range of bytes with a buffer lexicographically. More...
 
int compare (size_type offset, size_type count, const_pointer buf) const
 Compare a range of bytes with a C-style string lexicographically. More...
 
int compare (const_pointer buf) const
 Compare self with a C-style string lexicographically. More...
 
int compare (size_type offset, size_type count, const __Myt &other, size_type newOffset, size_type newCount) const
 Compare a range of bytes with another CCharBuffer object. More...
 
int compare (size_type offset, size_type count, const __Myt &other) const
 Compare a range of bytes with another CCharBuffer object. More...
 
int compare (const __Myt &other) const
 Compare self with another CCharBuffer object. More...
 

Static Public Attributes

static const size_type npos = static_cast<size_type>(-1)
 

Detailed Description

template<typename CharT>
class CCharBuffer< CharT >

Provide interfaces similar to std::string for raw byte array.

CCharBuffer provides convenient interfaces, like begin/end, append, insert, to manipulate a byte array, and performs necessary boundary checks to prevent access violation. It does NOT manage memory, so the user is responsible for the validation of the underlying buffer.

Template Parameters
CharTA character type, must be char, unsigned char or signed char. Other wider sized types are NOT supported, e.g. wchar_t.

Constructor & Destructor Documentation

template<typename CharT>
CCharBuffer< CharT >::CCharBuffer ( pointer  buf)
inline

Construct from a C-style string.

Both size and capacity are set to strlen(buf).

Parameters
bufPointer to a string
template<typename CharT>
CCharBuffer< CharT >::CCharBuffer ( pointer  buf,
size_type  capacity,
size_type  size = 0 
)
inline

Construct from a byte buffer.

Parameters
bufPointer to a byte buffer.
capacitySize of bytes that this object can manipulate. It could be smaller than the allocated size of buf, but not greater.
sizeSize of used bytes. It should be no more that capacity, otherwise capacity will be used instead.

Member Function Documentation

template<typename CharT>
__Myt& CCharBuffer< CharT >::append ( size_type  count,
value_type  val 
)
inline

Append a number of bytes to the end of the data.

Parameters
countNumber of bytes to append.
valValue of bytes to append.
Returns
Reference to self
template<typename CharT>
__Myt& CCharBuffer< CharT >::append ( const_pointer  buf,
size_type  count 
)
inline

Append content of a buffer to the end of the data.

Parameters
bufPointer to a byte buffer.
countSize of the buff.
Returns
Reference to self
template<typename CharT>
__Myt& CCharBuffer< CharT >::append ( const_pointer  buf)
inline

Append a C-style string to the end of the data.

Parameters
bufPointer to a string.
Returns
Reference to self
template<typename CharT>
__Myt& CCharBuffer< CharT >::append ( const __Myt other,
size_type  offset,
size_type  count 
)
inline

Append content of another CCharBuffer content to the end of the data.

This function appends contents between other.begin() + offset and other.begin() + offset + count to the data.

Parameters
otherAnother CCharBuffer object.
offsetOffset of the content in other.
countSize of the content in other.
Returns
Reference to self
template<typename CharT>
__Myt& CCharBuffer< CharT >::append ( const __Myt other)
inline

Append content of another CCharBuffer content to the end of the data.

Parameters
otherAnother CCharBuffer object.
Returns
Reference to self
template<typename CharT>
__Myt& CCharBuffer< CharT >::assign ( pointer  buf,
size_type  capacity,
size_type  size = 0 
)
inline

Set this object to manage a byte buffer.

Parameters
bufPointer to a byte buffer
capacitySize of bytes that this object can manipulate. It could be different from the real allocated size of buf.
sizeSize of used bytes. It should be no more that capacity, otherwise capacity will be used instead.
Returns
A reference to itself
template<typename CharT>
__Myt& CCharBuffer< CharT >::assign ( const __Myt other)
inline

Set this object to manage a buffer from another object.

These two objects will manipulate the same byte buffer, so if one changes the content of the buffer, the other will reflect the change. But they can have different size, for example, one can resize to a new size, the other object's size won't get affected.

Parameters
otherAnother CCharBuffer object.
Returns
A reference to itself
template<typename CharT>
reference CCharBuffer< CharT >::at ( size_type  i)
inline

Access a certain byte.

Parameters
iIndex of the byte
Returns
Mutable reference of the byte
Note
If i exceed size, an exception will be thrown.
template<typename CharT>
const_reference CCharBuffer< CharT >::at ( size_type  i) const
inline

Access a certain byte.

Parameters
iIndex of the byte
Returns
Constant reference of the byte
Note
If i exceed size, an exception will be thrown.
template<typename CharT>
reference CCharBuffer< CharT >::back ( )
inline

Access the last byte.

Returns
Mutable reference to the back byte.
template<typename CharT>
const_reference CCharBuffer< CharT >::back ( ) const
inline

Access the last byte.

Returns
Constant reference to the last byte.
template<typename CharT>
iterator CCharBuffer< CharT >::begin ( )
inline

Get the beginning of the data.

Returns
An mutable iterator pointing to the beginning of the data.
template<typename CharT>
const_iterator CCharBuffer< CharT >::begin ( ) const
inline

Get the beginning of the data.

Returns
An constant iterator pointing to the beginning of the data.
template<typename CharT>
const_pointer CCharBuffer< CharT >::c_str ( ) const
inline

Get the underlying C-style string.

Returns
Pointer to the data
See also
data
template<typename CharT>
size_type CCharBuffer< CharT >::capacity ( ) const
inline

Get the capacity of the underlying byte buffer.

Returns
Size of bytes that this object can hold at most.
template<typename CharT>
void CCharBuffer< CharT >::clear ( )
inline

Empty the data.

This function will NOT change the content of the underlying byte buffer, only reset size of this object.

template<typename CharT>
int CCharBuffer< CharT >::compare ( size_type  offset,
size_type  count,
const_pointer  buf,
size_type  newCount 
) const
inline

Compare a range of bytes with a buffer lexicographically.

This function compares content between this->begin() + offset and this->begin() + offset + count, with content between buf and buf + count.

Parameters
offsetStart position in self to compare.
countSize of bytes in self to compare.
bufPointer to a byte buffer to compare with.
newCountLength of buf to compare with.
Returns
  • Negative value if the first content is less than the second;
  • 0 if two contents are equal;
  • Positive value if the first content is greater than the second;
template<typename CharT>
int CCharBuffer< CharT >::compare ( size_type  offset,
size_type  count,
const_pointer  buf 
) const
inline

Compare a range of bytes with a C-style string lexicographically.

This function compares content between this->begin() + offset and this->begin() + offset + count, with content of buf.

Parameters
offsetStart position in self to compare.
countSize of bytes in self to compare.
bufPointer to a string.
Returns
  • Negative value if the first content is less than the second;
  • 0 if two contents are equal;
  • Positive value if the first content is greater than the second;
template<typename CharT>
int CCharBuffer< CharT >::compare ( const_pointer  buf) const
inline

Compare self with a C-style string lexicographically.

This function compares content between this->begin() and this->end(), with content of buf.

Parameters
bufPointer to a string.
Returns
  • Negative value if the first content is less than the second;
  • 0 if two contents are equal;
  • Positive value if the first content is greater than the second;
template<typename CharT>
int CCharBuffer< CharT >::compare ( size_type  offset,
size_type  count,
const __Myt other,
size_type  newOffset,
size_type  newCount 
) const
inline

Compare a range of bytes with another CCharBuffer object.

This function compares content between this->begin() + offset and this->begin() + offset + count, with content between other.begin() + newOffset and other.begin() + newOffset + newCount.

Parameters
offsetStart position in self to compare.
countSize of bytes in self to compare.
otherAnother CCharBuffer object to compare with.
newOffsetStart position in other to compare with.
newCountSize of bytes in other to compare with.
Returns
  • Negative value if the first content is less than the second;
  • 0 if two contents are equal;
  • Positive value if the first content is greater than the second;
template<typename CharT>
int CCharBuffer< CharT >::compare ( size_type  offset,
size_type  count,
const __Myt other 
) const
inline

Compare a range of bytes with another CCharBuffer object.

This function compares content between this->begin() + offset and this->begin() + offset + count, with content between other.begin() and other.end().

Parameters
offsetStart position in self to compare.
countSize of bytes in self to compare.
otherAnother CCharBuffer object to compare with.
Returns
  • Negative value if the first content is less than the second;
  • 0 if two contents are equal;
  • Positive value if the first content is greater than the second;
template<typename CharT>
int CCharBuffer< CharT >::compare ( const __Myt other) const
inline

Compare self with another CCharBuffer object.

This function compares content between this->begin() and this->end(), with content between other.begin() and other.end().

Parameters
otherAnother CCharBuffer object to compare with.
Returns
  • Negative value if the first content is less than the second;
  • 0 if two contents are equal;
  • Positive value if the first content is greater than the second;
template<typename CharT>
size_type CCharBuffer< CharT >::copy ( pointer  buf,
size_type  count,
size_type  offset = 0 
) const
inline

Copy content of a buffer to self.

This function tries to copy at most count bytes from buf, to the buffer managed by this object, starting from offset, which is similar to:

std::copy(buf, buf + count, this->begin() + offset);

except that if self cannot hold as many as count bytes from offset, it will copy less bytes, which will be indicated in the return value.

Parameters
bufPointer to a byte buffer.
countSize of bytes to copy from buf.
offsetOffset of destination in self.
Returns
Size of bytes actually copied.
template<typename CharT>
const_pointer CCharBuffer< CharT >::data ( ) const
inline

Get the data pointer.

Returns
Pointer to the data
See also
c_str
template<typename CharT>
bool CCharBuffer< CharT >::empty ( ) const
inline

Test if the data is empty.

Returns
true if size is 0; otherwise false.
template<typename CharT>
iterator CCharBuffer< CharT >::end ( )
inline

Get the ending of the data.

Returns
An mutable iterator pointing to the ending of the data, which is one position after the last used byte.
template<typename CharT>
const_iterator CCharBuffer< CharT >::end ( ) const
inline

Get the ending of the data.

Returns
An constant iterator pointing to the ending of the data, which is one position after the last used byte.
template<typename CharT>
iterator CCharBuffer< CharT >::erase ( iterator  first,
iterator  last 
)
inline

Erase a range of bytes.

Parameters
firstStart position to be erased.
lastEnd position to be erased.
Returns
first.
template<typename CharT>
iterator CCharBuffer< CharT >::erase ( iterator  pos)
inline

Erase a byte.

Parameters
posPosition of byte to be erased.
Returns
pos.
template<typename CharT>
__Myt& CCharBuffer< CharT >::erase ( size_type  offset = 0,
size_type  count = npos 
)
inline

Erase a range of bytes.

Parameters
offsetOffset of start position to be erased.
countSize of bytes to be erased.
Returns
Reference to self.
template<typename CharT>
reference CCharBuffer< CharT >::front ( )
inline

Access the first byte.

Returns
Mutable reference to the first byte.
template<typename CharT>
const_reference CCharBuffer< CharT >::front ( ) const
inline

Access the first byte.

Returns
Constant reference to the first byte.
template<typename CharT>
__Myt& CCharBuffer< CharT >::insert ( size_type  offset,
size_type  count,
value_type  val 
)
inline

Insert a number of bytes.

Parameters
offsetPosition to insert into.
countNumber of bytes to insert.
valValue of bytes to insert.
Returns
Reference to self
template<typename CharT>
__Myt& CCharBuffer< CharT >::insert ( size_type  offset,
const_pointer  buf,
size_type  count 
)
inline

Insert the content of a buffer.

Parameters
offsetPosition to insert into.
bufPointer to a byte buffer.
countLength of buf.
Returns
Reference to self
template<typename CharT>
__Myt& CCharBuffer< CharT >::insert ( size_type  offset,
const_pointer  buf 
)
inline

Insert a C-style string.

The trailing '\0' is NOT included.

Parameters
offsetPosition to insert into.
bufPointer to a string.
Returns
Reference to self
template<typename CharT>
__Myt& CCharBuffer< CharT >::insert ( size_type  offset,
const __Myt other,
size_type  newOffset,
size_type  count 
)
inline

Insert the content of another CCharBuffer.

This function reads contents from other.begin() + newOffset to other.begin() + newOffset + count, and insert it to this->begin() + offset.

Parameters
offsetPosition to insert into.
otherAnother CCharBuffer object.
newOffsetOffset of the content in other.
countSize of the content in other.
Returns
Reference to self
template<typename CharT>
__Myt& CCharBuffer< CharT >::insert ( size_type  offset,
const __Myt other 
)
inline

Insert the content of another CCharBuffer.

Parameters
offsetPosition to insert into.
otherAnother CCharBuffer object.
Returns
Reference to self
template<typename CharT>
iterator CCharBuffer< CharT >::insert ( iterator  pos,
value_type  val 
)
inline

Insert a byte.

Parameters
posPosition to insert the byte.
valValue of the byte.
Returns
pos.
template<typename CharT>
size_type CCharBuffer< CharT >::length ( ) const
inline

Get the size of the data, same as size().

Returns
Size of used bytes.
See also
size
template<typename CharT>
size_type CCharBuffer< CharT >::max_size ( ) const
inline

Get the maximum number of bytes.

Returns
Maximum number of bytes.
template<typename CharT>
__Myt& CCharBuffer< CharT >::operator+= ( const __Myt other)
inline

Append content of another CCharBuffer to the end of the data.

Parameters
otherAnother CCharBuffer object.
Returns
Reference to self
See also
append(const __Myt & other)
template<typename CharT>
__Myt& CCharBuffer< CharT >::operator+= ( const_pointer  buf)
inline

Append a C-style string to the end of the data.

The trailing '\0' is NOT included.

Parameters
bufPointer to a string.
Returns
Reference to self
See also
append(const_pointer buf)
template<typename CharT>
__Myt& CCharBuffer< CharT >::operator+= ( value_type  val)
inline

Append a byte to the end of the data.

Parameters
valValue to append to the data.
Returns
Reference to self
See also
push_back
template<typename CharT>
reference CCharBuffer< CharT >::operator[] ( size_type  i)
inline

Access a byte.

Parameters
iIndex of the byte.
Returns
Mutable reference to a byte.
template<typename CharT>
const_reference CCharBuffer< CharT >::operator[] ( size_type  i) const
inline

Access a byte.

Parameters
iIndex of the byte.
Returns
Constant reference to a byte.
template<typename CharT>
void CCharBuffer< CharT >::push_back ( value_type  val)
inline

Append a byte to the end of the data.

Parameters
valValue to append to the data.
template<typename CharT>
reverse_iterator CCharBuffer< CharT >::rbegin ( )
inline

Get the ending of the data.

Returns
An mutable reverse iterator pointing to the ending of the data.
template<typename CharT>
const_reverse_iterator CCharBuffer< CharT >::rbegin ( ) const
inline

Get the ending of the data.

Returns
An constant reverse iterator pointing to the ending of the data.
template<typename CharT>
reverse_iterator CCharBuffer< CharT >::rend ( )
inline

Get the beginning of the data.

Returns
An mutable reverse iterator pointing to the beginning of the data.
template<typename CharT>
const_reverse_iterator CCharBuffer< CharT >::rend ( ) const
inline

Get the beginning of the data.

Returns
An constant reverse iterator pointing to the beginning of the data.
template<typename CharT>
__Myt& CCharBuffer< CharT >::replace ( size_type  offset,
size_type  count,
size_type  newCount,
value_type  val 
)
inline

Replace a range of bytes with a number of new bytes.

This function performs actions similar to the following:

  • Erasing contents from begin() + offset to begin() + offset + count;
  • Insert new contents to begin() + offset;

The size of the data may change if count is not equal to newCount.

Parameters
offsetStart position of bytes to be replaced.
countSize of bytes to be replaced.
newCountNumber of new bytes.
valValue of new bytes.
Returns
Reference to self
template<typename CharT>
__Myt& CCharBuffer< CharT >::replace ( size_type  offset,
size_type  count,
const_pointer  buf,
size_type  newCount 
)
inline

Replace a range of bytes with the content of a byte buffer.

This function performs actions similar to the following:

  • Erasing contents from begin() + offset to begin() + offset + count;
  • Insert new contents to begin() + offset;

The size of the data may change if count is not equal to newCount.

Parameters
offsetStart position of bytes to be replaced.
countSize of bytes to be replaced.
bufPointer to a byte buffer.
newCountLength of buf.
Returns
Reference to self
template<typename CharT>
__Myt& CCharBuffer< CharT >::replace ( size_type  offset,
size_type  count,
const_pointer  buf 
)
inline

Replace a range of bytes with the content of a C-style string.

This function performs actions similar to the following:

  • Erasing contents from begin() + offset to begin() + offset + count;
  • Insert new contents to begin() + offset;

The size of the data may change if count is not equal to the length of buf.
The trailing '\0' of buf is not included.

Parameters
offsetStart position of bytes to be replaced.
countSize of bytes to be replaced.
bufPointer to a string
Returns
Reference to self
template<typename CharT>
__Myt& CCharBuffer< CharT >::replace ( size_type  offset,
size_type  count,
const __Myt other,
size_type  newOffset,
size_type  newCount 
)
inline

Replace a range of bytes with the content of another CCharBuffer.

This function performs actions similar to the following:

  • Erasing contents from begin() + offset to begin() + offset + count;
  • Insert new contents to begin() + offset;

The size of the data may change if count is not equal to newCount.

Parameters
offsetStart position of bytes to be replaced.
countSize of bytes to be replaced.
otherAnother CCharBuffer object.
newOffsetOffset of content in other.
newCountSize of content in other.
Returns
Reference to self
template<typename CharT>
__Myt& CCharBuffer< CharT >::replace ( size_type  offset,
size_type  count,
const __Myt other 
)
inline

Replace a range of bytes with the content of another CCharBuffer.

This function performs actions similar to the following:

  • Erasing contents from begin() + offset to begin() + offset + count;
  • Insert new contents to begin() + offset;

The size of the data may change if count is not equal to other.size().

Parameters
offsetStart position of bytes to be replaced.
countSize of bytes to be replaced.
otherAnother CCharBuffer object.
Returns
Reference to self
template<typename CharT>
__Myt& CCharBuffer< CharT >::replace ( iterator  first,
iterator  last,
size_type  count,
value_type  val 
)
inline

Replace a range of bytes with a number of new bytes.

This function performs actions similar to the following:

  • Erasing contents from first to last;
  • Insert new contents to first;

The size of the data may change if last - first is not equal to count.

Parameters
firstStart position to be replaced.
lastEnd position to be replaced.
countNumber of new bytes.
valValue of new bytes.
Returns
Reference to self
template<typename CharT>
__Myt& CCharBuffer< CharT >::replace ( iterator  first,
iterator  last,
const_pointer  buf,
size_type  count 
)
inline

Replace a range of bytes with the content of a byte buffer.

This function performs actions similar to the following:

  • Erasing contents from first to last;
  • Insert new contents to first;

The size of the data may change if last - first is not equal to count.

Parameters
firstStart position to be replaced.
lastEnd position to be replaced.
bufPointer to a byte buffer.
newCountLength of buf.
Returns
Reference to self
template<typename CharT>
__Myt& CCharBuffer< CharT >::replace ( iterator  first,
iterator  last,
const_pointer  buf 
)
inline

Replace a range of bytes with the content of a C-style string.

This function performs actions similar to the following:

  • Erasing contents from first to last;
  • Insert new contents to first;

The size of the data may change if last - first is not equal to the length of buf.
The trailing '\0' of buf is not included.

Parameters
firstStart position to be replaced.
lastEnd position to be replaced.
bufPointer to a string
Returns
Reference to self
template<typename CharT>
__Myt& CCharBuffer< CharT >::replace ( iterator  first,
iterator  last,
const __Myt other,
size_type  offset,
size_type  count 
)
inline

Replace a range of bytes with the content of another CCharBuffer.

This function performs actions similar to the following:

  • Erasing contents from first to last;
  • Insert new contents to first;

The size of the data may change if last - first is not equal to count.

Parameters
firstStart position to be replaced.
lastEnd position to be replaced.
otherAnother CCharBuffer object.
offsetOffset of content in other.
countSize of content in other.
Returns
Reference to self
template<typename CharT>
__Myt& CCharBuffer< CharT >::replace ( iterator  first,
iterator  last,
const __Myt other 
)
inline

Replace a range of bytes with the content of another CCharBuffer.

This function performs actions similar to the following:

  • Erasing contents from first to last;
  • Insert new contents to first;

The size of the data may change if last - first is not equal to other.size().

Parameters
firstStart position to be replaced.
lastEnd position to be replaced.
otherAnother CCharBuffer object.
Returns
Reference to self
template<typename CharT>
void CCharBuffer< CharT >::resize ( size_type  count,
value_type  val = 0 
)
inline

Resize the data.

If data shrinks, no change will be made to the content of the underlying buffer. If data expands, new data will be filled with val.

Parameters
countNew size of the data
valValue to fill in the expanded data
template<typename CharT>
size_type CCharBuffer< CharT >::size ( ) const
inline

Get the size of the data.

Returns
Size of used bytes.
See also
length
template<typename CharT>
__Myt CCharBuffer< CharT >::substr ( size_type  offset = 0,
size_type  count = npos 
)
inline

Get a substring.

The substring has the following attributes:

  • begin() is equal to this->begin() + offset;
  • size() is equal to the smaller one of count and this->size() - offset;
  • capacity() is equal to this->capacity() - offset;
    Parameters
    offsetOffset of start position of the substring.
    countLength of the substring.
    Returns
    A new CCharBuffer object denote the substring.
template<typename CharT>
void CCharBuffer< CharT >::swap ( __Myt other)
throw (
)
inline

Swap two CCharBuffer objects.

Parameters
otherReference to another object.

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