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

UserDefault acts as a tiny database. More...

#include <CCUserDefault.h>

Public Member Functions

bool getBoolForKey (const char *pKey)
 Get bool value by key, if the key doesn't exist, a default value will return. More...
 
bool getBoolForKey (const char *pKey, bool defaultValue)
 NA More...
 
int getIntegerForKey (const char *pKey)
 Get integer value by key, if the key doesn't exist, a default value will return. More...
 
int getIntegerForKey (const char *pKey, int defaultValue)
 NA More...
 
float getFloatForKey (const char *pKey)
 Get float value by key, if the key doesn't exist, a default value will return. More...
 
float getFloatForKey (const char *pKey, float defaultValue)
 NA More...
 
double getDoubleForKey (const char *pKey)
 Get double value by key, if the key doesn't exist, a default value will return. More...
 
double getDoubleForKey (const char *pKey, double defaultValue)
 NA More...
 
std::string getStringForKey (const char *pKey)
 Get string value by key, if the key doesn't exist, a default value will return. More...
 
std::string getStringForKey (const char *pKey, const std::string &defaultValue)
 NA More...
 
Data getDataForKey (const char *pKey)
 Get binary data value by key, if the key doesn't exist, a default value will return. More...
 
Data getDataForKey (const char *pKey, const Data &defaultValue)
 NA NA More...
 
void setBoolForKey (const char *pKey, bool value)
 Set bool value by key. More...
 
void setIntegerForKey (const char *pKey, int value)
 Set integer value by key. More...
 
void setFloatForKey (const char *pKey, float value)
 Set float value by key. More...
 
void setDoubleForKey (const char *pKey, double value)
 Set double value by key. More...
 
void setStringForKey (const char *pKey, const std::string &value)
 Set string value by key. More...
 
void setDataForKey (const char *pKey, const Data &value)
 Set binary data value by key. More...
 
void flush ()
 Save content to xml file NA. More...
 

Static Public Member Functions

static UserDefaultgetInstance ()
 returns the singleton NA NA More...
 
static void destroyInstance ()
 NA More...
 
static UserDefaultsharedUserDefault ()
 deprecated. More...
 
static void purgeSharedUserDefault ()
 NA More...
 
static const std::string & getXMLFilePath ()
 NA More...
 
static bool isXMLFileExist ()
 NA More...
 

Detailed Description

UserDefault acts as a tiny database.

You can save and get base type values by it. For example, setBoolForKey("played", true) will add a bool value true into the database. Its key is "played". You can get the value of the key by getBoolForKey("played").

It supports the following base types: bool, int, float, double, string

Member Function Documentation

static void destroyInstance ( )
static

NA

void flush ( )

Save content to xml file NA.

bool getBoolForKey ( const char *  pKey)

Get bool value by key, if the key doesn't exist, a default value will return.

You can set the default value, or it is false. NA

bool getBoolForKey ( const char *  pKey,
bool  defaultValue 
)

NA

Data getDataForKey ( const char *  pKey)

Get binary data value by key, if the key doesn't exist, a default value will return.

You can set the default value, or it is null. NA NA

Data getDataForKey ( const char *  pKey,
const Data defaultValue 
)

NA NA

double getDoubleForKey ( const char *  pKey)

Get double value by key, if the key doesn't exist, a default value will return.

You can set the default value, or it is 0.0. NA

double getDoubleForKey ( const char *  pKey,
double  defaultValue 
)

NA

float getFloatForKey ( const char *  pKey)

Get float value by key, if the key doesn't exist, a default value will return.

You can set the default value, or it is 0.0f. NA

float getFloatForKey ( const char *  pKey,
float  defaultValue 
)

NA

static UserDefault* getInstance ( )
static

returns the singleton NA NA

int getIntegerForKey ( const char *  pKey)

Get integer value by key, if the key doesn't exist, a default value will return.

You can set the default value, or it is 0. NA

int getIntegerForKey ( const char *  pKey,
int  defaultValue 
)

NA

std::string getStringForKey ( const char *  pKey)

Get string value by key, if the key doesn't exist, a default value will return.

You can set the default value, or it is "". NA

std::string getStringForKey ( const char *  pKey,
const std::string &  defaultValue 
)

NA

static const std::string& getXMLFilePath ( )
static

NA

static bool isXMLFileExist ( )
static

NA

static void purgeSharedUserDefault ( )
static

NA

void setBoolForKey ( const char *  pKey,
bool  value 
)

Set bool value by key.

NA

void setDataForKey ( const char *  pKey,
const Data value 
)

Set binary data value by key.

NA NA

void setDoubleForKey ( const char *  pKey,
double  value 
)

Set double value by key.

NA

void setFloatForKey ( const char *  pKey,
float  value 
)

Set float value by key.

NA

void setIntegerForKey ( const char *  pKey,
int  value 
)

Set integer value by key.

NA

void setStringForKey ( const char *  pKey,
const std::string &  value 
)

Set string value by key.

NA

static UserDefault* sharedUserDefault ( )
static

deprecated.

Use getInstace() instead NA NA


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