• entries
    437
  • comments
    1000
  • views
    335623

What if...

Sign in to follow this  
evolutional

94 views

C++

ClassDefinition simpleDef( "Vector" );
simpleDef.DeclareProperty( CDSP_PUBLIC, PTY_FLOAT, "x" );
simpleDef.DeclareProperty( CDSP_PUBLIC, PTY_FLOAT, "y" );
simpleDef.DeclareProperty( CDSP_PUBLIC, PTY_FLOAT, "z" );


Environment env;
env.RegisterClass( simpleDef );

ClassInstance *inst = env.CreateInstance( "Vector" );
inst->Property( "x" ).Set( 100.0f );
inst->Property( "y" ).Set( 200.0f );
std::cout << "x: " << inst->Property( "x" ).GetFloat();
std::cout << "y: " << inst->Property( "y" ).GetFloat();
std::cout << "z: " << inst->Property( "z" ).GetFloat();
Sign in to follow this  


1 Comment


Recommended Comments

I do something kinda-sorta-but-not-really like that for my configurations class. I store properties as key/value pairs in a map, where the key and value are both strings, and I can query each value as a string, an int, a float, a double, etc...

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now