B
Bart Simpson
I have the need to write a generic Argument class for passing arguments
to an engine. I have come up in the last 5 mins or so with something
like this:
class Argument
{
public:
enum Type { String = 0, RawPointer, Double, Long};
Argument()tr(0),len(0){}
virtual ~Argument() { if (ptr) delete ptr ; }
//Accessor/Modifiers here ...
private:
union { void * ptr ; // if string, must be null terminated
double ; long ; } data ;
std::string m_name ;
size_t m_len ;
Type m_type ;
};
Questions
==================
1. Am I reinventinting the wheel here - has someone (probably more
experienced) done this already ?
2. Die hard C background showing with the presence of void* - I would
like to make this a template class instead - but cant figure out how ...
to an engine. I have come up in the last 5 mins or so with something
like this:
class Argument
{
public:
enum Type { String = 0, RawPointer, Double, Long};
Argument()tr(0),len(0){}
virtual ~Argument() { if (ptr) delete ptr ; }
//Accessor/Modifiers here ...
private:
union { void * ptr ; // if string, must be null terminated
double ; long ; } data ;
std::string m_name ;
size_t m_len ;
Type m_type ;
};
Questions
==================
1. Am I reinventinting the wheel here - has someone (probably more
experienced) done this already ?
2. Die hard C background showing with the presence of void* - I would
like to make this a template class instead - but cant figure out how ...