cocos2d-x  3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Data Class Reference

#include <CCData.h>

Public Member Functions

 Data ()
 Constructor of Data. More...
 
 Data (const Data &other)
 Copy constructor of Data. More...
 
 Data (Data &&other)
 Copy constructor of Data. More...
 
 ~Data ()
 Destructor of Data. More...
 
Dataoperator= (const Data &other)
 Overroads of operator=. More...
 
Dataoperator= (Data &&other)
 Overroads of operator=. More...
 
unsigned char * getBytes () const
 Gets internal bytes of Data. More...
 
ssize_t getSize () const
 Gets the size of the bytes. More...
 
void copy (const unsigned char *bytes, const ssize_t size)
 Copies the buffer pointer and its size. More...
 
void fastSet (unsigned char *bytes, const ssize_t size)
 Fast set the buffer pointer and its size. More...
 
void clear ()
 Clears data, free buffer and reset data size. More...
 
bool isNull () const
 Check whether the data is null. More...
 

Static Public Attributes

static const Data Null
 This parameter is defined for convenient reference if a null Data object is needed. More...
 

Constructor & Destructor Documentation

Data ( )

Constructor of Data.

Data ( const Data other)

Copy constructor of Data.

Data ( Data &&  other)

Copy constructor of Data.

~Data ( )

Destructor of Data.

Member Function Documentation

void clear ( )

Clears data, free buffer and reset data size.

void copy ( const unsigned char *  bytes,
const ssize_t  size 
)

Copies the buffer pointer and its size.

Note
This method will copy the whole buffer. Developer should free the pointer after invoking this method.
See also
Data::fastSet
void fastSet ( unsigned char *  bytes,
const ssize_t  size 
)

Fast set the buffer pointer and its size.

Please use it carefully.

Parameters
bytesThe buffer pointer, note that it have to be allocated by 'malloc' or 'calloc', since in the destructor of Data, the buffer will be deleted by 'free'.
Note
1. This method will move the ownship of 'bytes'pointer to Data,
  1. The pointer should not be used outside after it was passed to this method.
See also
Data::copy
unsigned char* getBytes ( ) const

Gets internal bytes of Data.

It will retrun the pointer directly used in Data, so don't delete it.

Returns
Pointer of bytes used internal in Data.
ssize_t getSize ( ) const

Gets the size of the bytes.

Returns
The size of bytes of Data.
bool isNull ( ) const

Check whether the data is null.

Returns
True if the the Data is null, false if not.
Data& operator= ( const Data other)

Overroads of operator=.

Data& operator= ( Data &&  other)

Overroads of operator=.

Member Data Documentation

const Data Null
static

This parameter is defined for convenient reference if a null Data object is needed.


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