Created
June 6, 2013 05:21
-
-
Save mchinen/5719480 to your computer and use it in GitHub Desktop.
cococs2d-x macro to help with load save common cases for CCUserDefaults
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// RSCCMacros.h | |
// doghouse | |
// | |
// Created by Michael Chinen on 13/05/17. | |
// | |
// | |
#ifndef doghouse_RSCCMacros_h | |
#define doghouse_RSCCMacros_h | |
// use this to ensure you don't fuck up the keys with copy pasta | |
#define LOADINTKEY(db, baseKey, varName, keyName) \ | |
{\ | |
char szKey[64] = {0};\ | |
snprintf(szKey, 63, "%s%s", baseKey, keyName);\ | |
varName = db->getIntegerForKey(szKey, varName);\ | |
} | |
#define LOADINT(db, baseKey, varName) \ | |
LOADINTKEY(db, baseKey, varName, #varName) | |
#define SAVEINTKEY(db, baseKey, varName, keyName) \ | |
{\ | |
char szKey[64] = {0};\ | |
snprintf(szKey, 63, "%s%s", baseKey, keyName);\ | |
db->setIntegerForKey(szKey, varName);\ | |
} | |
#define SAVEINT(db, baseKey, varName) \ | |
SAVEINTKEY(db, baseKey, varName, #varName) | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment