Posts 1–1 of 1 · Page 1 of 1
Helpful Macros / Scripts
I'm gonna leave here some macros that may or may not be helpful to other users.
If anyone wishes to leave a bit of code below that you might deem helpful to other users, feel free to comment below:
Description:
These are macros that can be used to implement faster (and cleaner) declaration of variables.
They can be "read-only", "write-only" or "read-write". You can add things like customizable get / set methods, etc...
Code:
Code:
//Defines a read-write property.
#define DECLARE_PROPERTY_RW ( TYPE , NAME ) \
private:\
TYPE NAME##_;\
\
public:\
void set##NAME##(TYPE new##NAME#__ ) {\
NAME##_ = new##NAME##__;\
}\
TYPE get##NAME##(void) {\
return NAME##_ ;\
}\
\
__declspec(property(get = get##NAME##, put = set##NAME##)) TYPE NAME;
//Defines a readonly(you can access the private version of this property by using the name of the property + "_") property.
#define DECLARE_PROPERTY_R ( TYPE , NAME ) \
private:\
TYPE NAME##_;\
\
public:\
TYPE get##NAME##(void) {\
return NAME##_ ;\
}\
\
__declspec(property(get = get##NAME##)) TYPE NAME;
//Defines a writeonly property.
#define DECLARE_PROPERTY_W ( TYPE , NAME ) \
private:\
TYPE NAME##_;\
\
public:\
void set##NAME##(TYPE new##NAME#__ ) {\
NAME##_ = new##NAME##__;\
}\
\
__declspec(property(put = set##NAME##)) TYPE NAME;
Posts 1–1 of 1 · Page 1 of 1