cocos2d-x
3.3
|
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 UserDefault * | getInstance () |
returns the singleton NA NA More... | |
static void | destroyInstance () |
NA More... | |
static UserDefault * | sharedUserDefault () |
deprecated. More... | |
static void | purgeSharedUserDefault () |
NA More... | |
static const std::string & | getXMLFilePath () |
NA More... | |
static bool | isXMLFileExist () |
NA More... | |
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
|
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
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 |
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 |
NA
|
static |
NA
|
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 |
deprecated.
Use getInstace() instead NA NA