text_t Struct Reference

implements a text. More...

#include <text.h>


Data Fields

int len
const char * str


Detailed Description

implements a text.

struct text_t implements a text that is alternative representation of character strings. The C representation of strings using the terminating null character has some drawbacks:

Because the null character does not play a role of terminating a string anymore, there is no need to treat it specially. Therefore, a text represented by text_t is allowed to contain the null character anywhere in it, and other text_t functions never treat it in a special way. Nevertheless, be warned that, if a text which has the null character embedded in it is converted to a C string, the resulting string might not work as expected because of the embedded null character.

The Text Library is not intended to completely replace the C representation of strings. To perform string operations other than those provided by the Text Library, a user has to convert a text back to a C string and then apply ordinary string functions to the result. Such a conversion between those two representations is the cost for the benefit the Text Library confers. To minimize the cost, some basic text operations like comparison and mapping are also supported.

text_t intentionally reveals its interals, so that a user can readily get the length of a text and can access to the text as necessary. Modifying a text, however, makes a program behave in an unpredictable way, which is the reason the str member is const-qualified.

Most functions in this library take and return a text_t value, not a pointer to it. This design approach simplifies an implementation since they never need to allocate a descriptor for a text. The size of text_t being not so big, passing its value would cause no big penalty on performance.


Field Documentation

length of string

const char* text_t::str

string (possibly not having null character


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

Generated on Mon Jan 24 01:12:44 2011 for The Text Library by  doxygen 1.5.8