karoo::text::text::clonea Class Reference

This class is a convenience class for containing a small block of memory which is a clone of the text string in a text object. More...

#include <util.h>

List of all members.

Classes

class  clonea_data

Public Member Functions

 clonea (const text *ref)
 clonea (const clonea &ref)
const cloneaoperator= (const clonea &ref)
 operator const char * () const
 operator size_t () const

Public Attributes

clonea_data * data


Detailed Description

This class is a convenience class for containing a small block of memory which is a clone of the text string in a text object.

This memory will be freed up when the clonea object itself is deleted. The clonea object itself is quite small, so its not a significant overhead to be creating temporary objects on the stack. The memory they hold though, is only created once, and referred to with a reference count. This may seem like a lot of coding and a lot of effort, to just get a temporary string, but it is a work-around for the fact that so many C functions exist which take a c_str (const char*) pointer as an argument... but this is diabloically horrible when it comes to avoiding race conditions.

There is a convenience defined macro for getting a temporary string from a text object, which uses the clonea object:

TEMP_STRING(str) ... where str is the text object. e.g.

 text path;
 ...
 ifstream is(TEMP_STRING(path), ios::binary);

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

Generated on Tue Feb 16 15:04:30 2010 for Karoo by  doxygen 1.5.8