glim::bufstr_t< SIZE, THROW > Struct Template Reference

#include <bufstr_t.hpp>

List of all members.


Detailed Description

template<int SIZE, bool THROW = true>
struct glim::bufstr_t< SIZE, THROW >

Stack-allocated string buffer.

Based on str_t and safestr_t classes from libaga, of the same author, which were made back in 1999, but without C++ templating and exceptions.

Operations that would overflow will either throw the std::out_of_range error (if the THROW template parameter is true, which it is by default), or silently ignored.

See also http://www.codeproject.com/string/Allocdynstringsonstack.asp


Public Member Functions

 bufstr_t ()
 This default constructor is sufficient to use the buffer.
char * c ()
 Access the buffer as null-terminated C string.
char * c_str ()
 Access the buffer as null-terminated C string.
char * end () const
 Returns a pointer to the end of the contained string.
std::pair< char const *, int > pair () const
 Access the buffer as std::pair.
bufstr_treset ()
 Set the length counter back to 0, so that the buffer can be reused.
template<int C_SIZE, bool C_THROW>
bufstr_toperator<< (const bufstr_t< C_SIZE, C_THROW > &ab)
 Append another buffer.
bufstr_toperator<< (std::pair< char const *, int > str)
 Append a string whose length is known.
bufstr_toperator<< (char const *cs)
 Append a null-terminated character string.
bufstr_toperator<< (const std::string &str)
 Append a C++ string into the buffer.
template<typename INT>
bufstr_tappendInt (INT integer)
 Append a signed integer to the buffer, converting it to decimal form.
bufstr_tappendString (char const *str, int strLen)
 Append a string whose length is known.
bufstr_tappendString (char const *cs)
 Append a null-terminated character string.
bufstr_tappendString (const std::string &str)
 Append a C++ string into the buffer.
bufstr_toperator<< (int integer)
 Append an int to the buffer, converting it to decimal form.
bufstr_toperator<< (long long integer)
 Append a long long to the buffer, converting it to decimal form.
bufstr_toperator<< (char ch)
 Append a single character to the buffer.

Public Attributes

char buf [SIZE+1]
 The buffer (stack-allocated, if the containing instance is).
int len
 The current length of the string.


Member Function Documentation

template<int SIZE, bool THROW = true>
char* glim::bufstr_t< SIZE, THROW >::c  )  [inline]
 

Access the buffer as null-terminated C string.

This method will terminate the buffer with zero.

template<int SIZE, bool THROW = true>
char* glim::bufstr_t< SIZE, THROW >::c_str  )  [inline]
 

Access the buffer as null-terminated C string.

This method will terminate the buffer with zero.

template<int SIZE, bool THROW = true>
char* glim::bufstr_t< SIZE, THROW >::end  )  const [inline]
 

Returns a pointer to the end of the contained string.

bufstr.end() is a shorthand to (bufstr.buf + bufstr.len).

template<int SIZE, bool THROW = true>
std::pair<char const*, int> glim::bufstr_t< SIZE, THROW >::pair  )  const [inline]
 

Access the buffer as std::pair.

The pair consists of a pointer to the beginning and the length of the contained string.


Member Data Documentation

template<int SIZE, bool THROW = true>
char glim::bufstr_t< SIZE, THROW >::buf[SIZE+1]
 

The buffer (stack-allocated, if the containing instance is).

The size of the buffer is SIZE + 1, so that we always have a space to zero-terminate the string.


Generated on Fri Nov 24 20:57:37 2006 for libglim by  doxygen 1.4.6