Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

look::LookRawData Class Reference

Class representing binary data. More...

#include <lkrawdata.h>

Inheritance diagram for look::LookRawData::

look::LookTypeBase List of all members.

Public Methods

 LookRawData ()
 Default constructor. More...

 LookRawData (const char *theData, long theDataLength)
 Constructor.

 ~LookRawData (void)
 Destructor.

 LookRawData (const LookRawData &theOther)
 Shallow Copy constructor. More...

LookRawData& operator= (const LookRawData &theOther)
 Shallow Assignment operator. More...

LookTypeBaseGetNewCopy (void) const
 Get a new copy. More...

long GetTypeID (void) const
 Get Type ID. More...

char* GetData (void)
 Get a pointer to the data. More...

long GetLength (void)
 Get the length of the data. More...

char* GetData (long &theLength)
 Get a pointer to the data and its length. More...

void SetData (const char *theData, long theLength)
 Set the data. More...

char* InitialiseData (long theLength)
 Set up a data space. More...

void Append (const LookRawData &theOther)
 Append data. More...

void Append (const char *theData, long theLength)
 Append data. More...

void Resize (long theNewLength)
 Resize data. More...

bool Set (const LookString &theString)
 Convert from string. More...

LookString GetString (void) const
 Convert to string. More...


Protected Attributes

RawDataRepresentation* itsData

Detailed Description

Class representing binary data.

This behaves as a very stupid string class in some ways. Copies share the same binary data, so copying is fast but changes to one copy affect the other one.

For this reason, it should be used with great care!

There are a number of operations which create a proper new copy, eg append. These invalidate any pointers to the data in that object, however if there are any shallow copies around, pointers to data in that shallow copy will remain valid.


Constructor & Destructor Documentation

look::LookRawData::LookRawData ( )
 

Default constructor.

Default length and data will be 0 (NULL).

look::LookRawData::LookRawData ( const LookRawData & theOther )
 

Shallow Copy constructor.

The new copy shares the binary data representation.

The const isn't really so...


Member Function Documentation

void look::LookRawData::Append ( const char * theData,
long theLength )
 

Append data.

Appends theLength bytes of data from theData to me.

All existing pointers to my data will be invalidated.

My data will not be shared with anything else.

Parameters:
theData   Data
theLength   Length

void look::LookRawData::Append ( const LookRawData & theOther )
 

Append data.

Appends the data in theOther to me.

All existing pointers to my data will be invalidated.

My data will not be shared with anything else.

Parameters:
theOther   Other data

char * look::LookRawData::GetData ( long & theLength )
 

Get a pointer to the data and its length.

Parameters:
theLength   The length is returned in here.
Returns:
Pointer to data.

char * look::LookRawData::GetData ( void )
 

Get a pointer to the data.

Returns:
A pointer. If we have no data, this is 0 (NULL).

long look::LookRawData::GetLength ( void )
 

Get the length of the data.

Returns:
The length. If we have no data, this is 0.

LookTypeBase * look::LookRawData::GetNewCopy ( void ) const [virtual]
 

Get a new copy.

Virtual copy constructor, aka clone. Note this new copy shares data with the old one.

Returns:
A new copy of this. (You are responsible for deleting it).

Reimplemented from look::LookTypeBase.

LookString look::LookRawData::GetString ( void ) const
 

Convert to string.

LookString can cope with embedded nulls (as it is std::string), so this method returns a string of the correct length.

Returns:
String

long look::LookRawData::GetTypeID ( void ) const [virtual]
 

Get Type ID.

Pseudo-rtti, or isA.

Returns:
LookRawDataID

Reimplemented from look::LookTypeBase.

char * look::LookRawData::InitialiseData ( long theLength )
 

Set up a data space.

This reserves a space for data for you to fill - ie no copy required.

After this we own our own data representation.

Parameters:
theLength   Length required (reserved)
Returns:
Pointer to data area, which will be theLength long.

void look::LookRawData::Resize ( long theNewLength )
 

Resize data.

Resize my data to theNewLength.

All existing pointers to my data will be invalidated.

My data will not be shared with anything else.

Parameters:
theNewLength   New length

bool look::LookRawData::Set ( const LookString & theString )
 

Convert from string.

LookString has a length independent of embedded nulls (as it is std::string), so this calls SetData with that length.

Parameters:
theString   String
Returns:
true

void look::LookRawData::SetData ( const char * theData,
long theLength )
 

Set the data.

This takes a copy of theData.

After this we own our own data representation.

Parameters:
theData   Data
theLength   Length

LookRawData & look::LookRawData::operator= ( const LookRawData & theOther )
 

Shallow Assignment operator.

The old binary data representation is thrown away. We now share the binary data with theOther.

The const isn't really so...


The documentation for this class was generated from the following files:
Generated at Thu Jan 17 12:53:09 2002 for liblookdb by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001