Defined in file: hzString.h

hzChain is an unlimited char buffer, for any purpose but widely used to assemble complex string values such as HTTP server responses. To this end, hzChain has both standard append functions and Printf, a vararg printf type member function. String assembly must be as a series of one or more append operations as no INSERT method is provided. The content is held in a double linked list of fixed sized blocks rather than as contiguous memory. This arrangement avoids reallocation and copying during string assembly, but not if a hzChain of more than one block is cast to a null terminated character string. Such casting however, is not the norm. hzChain instances are expected to be iterated from begining to end. An iterator is provided as a sub-class for this purpose. Although the double linked list allows iterators to decrement, this facility is not used in any current HadronZoo software and should be considered as deprecated. In addition to acting as a single string value container, hzChain allows blocks to be deleted from the front, making it suitable for processing data streams. Incomming data and requests from connected clients and server responses, are both processed as data streams by the hzIpServer class. Once the iterator processing the incomming data passes onto the next block, the first block is discarded. Likewise once blocks in the outgoing data have been written to the socket, they are discarded. Doing this prevents chains becoming ever larger in cases where clients remain connected and make a large number of requests. Note that while hzChain is good for string assembly, the fixed block size makes it a poor choice for string storage. Once assembled, strings should be stored as hzString.

This class employes the private sub-class _chain as follows:-

_chain

Constructors/Detructors

hzChain*hzChain(void)
hzChain*hzChain(hzChain& op)
NULL-TYPEhzChain(void)Construct an empty hzChain instance. Increment the global count of currently allocated hzChain instances for memory use reporting purposes.
NULL-TYPEhzChain(hzChain& op)Copy constructor
void~hzChain(void)
NULL-TYPE~hzChain(void)Delete this hzChain instance. Decrement the global count of currently allocated hzChain instances for memory use reporting purposes.

Public Methods:

hzEcodeAddByte(const char C)Appends chain with a single byte. Takes the single arg as the char to append, returns either E_OK if successful but E_MEMORY if not. The latter is a fatal condition. Returns: E_OK
uint32_tAppend(const void* vpStr)uint32_t nBytes, Appends the chain with the first nBytes nB (void*) buffer of given size. This operation makes no assumptions about buffer content and so the operation is not null terminated.
uint32_tAppendSub(hzChain& Z)uint32_t nStart, uint32_t nBytes, Append this chain with a sub-chain
voidClear(void)Clears all content held by the hzChain. Arguments: None Returns: None
uint32_tCopies(void)
uint32_tPrintf(const char*)Write to the chain using the printf method. Uses varargs.
uint32_tSize(void)
int32_t_compare(hzChain& op)Lexical compare
void*_int_addr(void)
void_int_clr(void)
void_int_set(const void* ptr)
uint32_t_vainto(const char*)va_list, This is the 'backbone' of the Printf function. It is not to be called at the application level.

Overloaded operators:

booloperator!(void)
booloperator!=(hzChain& op)
hzChain&operator+=(const char* s)Append the current chain with the supplied char string operand.
hzChain&operator+=(hzString& s)Append chain with supplied string
hzChain&operator+=(hzChain& op)Append this chain with the supplied chain. This is done as a series of memcpy calls.
hzChain&operator+=(hzChain::Iter& op)Append this chain with the supplied chain. This is done as a series of memcpy calls.
hzChain&operator+=(ifstream& is)Append the current chain with the operand stream. The stream is read until no more bytes are available.
booloperator<(hzChain& op)
hzChain&operator<<(const char* s)Append chain with supplied char string
hzChain&operator<<(hzString& s)Append chain with supplied string
hzChain&operator<<(hzEmaddr& e)Append chain with supplied Email address
hzChain&operator<<(hzIpaddr& i)Append chain with supplied IP address
hzChain&operator<<(uint32_t nValue)Append the current chain with the text equivelent of the supplied integer operand.
hzChain&operator<<(uint64_t nValue)Append the current chain with the text equivelent of the supplied integer operand.
hzChain&operator<<(int32_t nValue)Append the current chain with the text equivelent of the supplied integer operand.
hzChain&operator<<(int64_t nValue)Append the current chain with the text equivelent of the supplied integer operand.
hzChain&operator<<(double nValue)Append the current chain with the text equivelent of the supplied numeric operand.
hzChain&operator<<(hzChain& C)Append chain with supplied chain
hzChain&operator<<(hzChain::Iter& zi)Append chain with supplied chain
hzChain&operator<<(ifstream& is)Append the current chain with the operand stream. The stream is read until no more bytes are available.
ostream&operator<<(ostream& os)hzChain& obj,
booloperator<=(hzChain& op)
hzChain&operator=(hzChain& op)Makes this chain equal to the supplied chain operand. Any pre-existing contents are disregarded.
hzChain&operator=(hzString& S)Makes this chain equal to the supplied string operand. Any pre-existing contents are disregarded.
hzChain&operator=(const char* s)Makes this chain equal to the supplied char string operand. Any pre-existing contents are disregarded.
booloperator==(hzChain& op)
booloperator>(hzChain& op)
booloperator>=(hzChain& op)
istream&operator>>(istream& is)hzChain& obj,

Member Variables:

hzChain::_chain*mxSmart pointer to contents