Public Types | Public Member Functions | Static Public Member Functions
Tonido::Data::RawData Class Reference

Encapsulates a raw block of memory and provides read and write access to it. More...

List of all members.

Public Types

typedef boost::shared_ptr
< RawData
SharedPtr

Public Member Functions

 RawData (const uint8_bt *pMemoryBlock, uint64_bt numBytes, bool a_doCopy=false)
 Ctor.
 RawData (uint64_bt numBytes)
 Ctor.
 RawData (const std::string &a_fileName)
 Ctor.
 ~RawData ()
 Dtor.
bool writeFile (const std::string &a_fileName)
 Writes the given raw data to a file.
bool writeData (const unsigned char *a_in, uint64_bt numBytes)
 Other Write Data Overrides.
bool writeData (unsigned char *a_in, uint64_bt numBytes)
bool writeData (const std::string &a_in)
bool writeData (const Poco::UUID &a_uuid)
bool writeData (const Poco::Net::SocketAddress &a_address)
bool writeData (const PeerID &a_peer)
bool writeData (int64_bt a_value)
bool writeData (uint64_bt a_value)
bool writeData (uint32_bt a_value)
bool writeData (int32_bt a_value)
bool writeData (double a_value)
bool reset ()
 reset
bool readData (unsigned char *a_in, uint64_bt numBytes)
 Reads data into the given pointer upto numBytes.
bool readData (std::string &a_str)
 Other readData Overrides.
bool readData (Poco::UUID &a_uuid)
bool readData (Poco::Net::SocketAddress &a_address)
bool readData (PeerID &a_peer)
bool readData (int64_bt &a_value)
bool readData (uint64_bt &a_value)
bool readData (uint32_bt &a_value)
bool readData (int32_bt &a_value)
bool readData (double &a_value)
uint64_bt getRemainingBytes () const
 Returns the number of bytes left from the current read/write location.
uint64_bt getTotalBytes () const
 Returns the total number of bytes in the memory block.
unsigned char * getRawData () const
 Returns the pointer to the actual allocated memory block.

Static Public Member Functions

static void encode64 (std::string &output, unsigned char *ptr, size_t length)
 Encodes a given char* block into a 64 encoded string.
static void decode64 (const std::string &input, std::string &output)
 decodes a given char* block from a 64 encoded string

Detailed Description

Encapsulates a raw block of memory and provides read and write access to it.


Constructor & Destructor Documentation

Tonido::Data::RawData::RawData ( const uint8_bt *  pMemoryBlock,
uint64_bt  numBytes,
bool  a_doCopy = false 
)

Ctor.

Constructs a RawData object out of an an already existing block of memory.

Tonido::Data::RawData::RawData ( uint64_bt  numBytes)

Ctor.

Constructs a RawData object by allocating memory

Tonido::Data::RawData::RawData ( const std::string &  a_fileName)

Ctor.

Constructs a RawData object by loading it from a file

Tonido::Data::RawData::~RawData ( )

Dtor.

Details if needed


Member Function Documentation

unsigned char * Tonido::Data::RawData::getRawData ( ) const

Returns the pointer to the actual allocated memory block.

Returns:
pointer to actual memory block
uint64_bt Tonido::Data::RawData::getRemainingBytes ( ) const

Returns the number of bytes left from the current read/write location.

Returns:
number of bytes left from the end of the buffer
uint64_bt Tonido::Data::RawData::getTotalBytes ( ) const

Returns the total number of bytes in the memory block.

Returns:
number of bytes of the memory block
bool Tonido::Data::RawData::readData ( unsigned char *  a_in,
uint64_bt  numBytes 
)

Reads data into the given pointer upto numBytes.

Parameters:
[in]a_inpointer to data
[in]numBytesnumber of bytes to read
Returns:
true on sucess, false if numBytes exceeds available size
bool Tonido::Data::RawData::reset ( )

reset

Returns the current read/write location back to the beginning of the block

Returns:
true on sucess, false otherwise
bool Tonido::Data::RawData::writeFile ( const std::string &  a_fileName)

Writes the given raw data to a file.

Returns:
true on sucess, false otherwise

Generated on Wed Oct 12 2011 21:46:53. © CodeLathe LLC 2007-2011. All Rights Reserved.