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

#include <CCData.h>

Public Member Functions

 Data ()
 Data (const Data &other)
 Data (Data &&other)
 ~Data ()
Dataoperator= (const Data &other)
Dataoperator= (Data &&other)
unsigned char * getBytes () const
ssize_t getSize () const
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

Constructor & Destructor Documentation

Data ( )
Data ( const Data other)
Data ( Data &&  other)
~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
ssize_t getSize ( ) const
bool isNull ( ) const

Check whether the data is null.

Data& operator= ( const Data other)
Data& operator= ( Data &&  other)

Member Data Documentation

const Data Null
static

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