Hello
I have to classes, an Executer with these methods:
- Executer()
- struct Execute(string s)
- Lookup(string name, int module, int num, ...)
and a Parser:
- Parser()
- struct Parse(string s)
The Exectuers Execute method calls the Parsers Parse method. The Parser then chucks the string into smaller bits (it explodes the string on the ;-sign) and returns a struct to the Execute method. This struct it uses to call the Lookup method. The struct that the Parse returns holds some standard information:
- An command name
- A senderId (a username, a mac address and a password)
- A variable number of arguments
And that is my problem. The Lookup method take variable arguments, but how do I handle the the hand over of these variable arguments by the struct? Im not an expert in C and C++. Should I mass the two classes togheter? So the Parser method could call the Execute method, sparing the struct away. Or maybe there is a way of parsing an unknown variable of arguments at runtime? By some sort of array?
EDIT I cant use the STL library from C++. I only use the C++ class and virtual feature. Im writing to an compiler where Im restricted to use almost all of the C libraries + the magic skills of C++ (virtual and class). SOory for not telling that right away.
EDIT 2 Im writing code to an embedded system and thereby using avr-gcc to compile my code. Thats why I cant use STL. The avr-gcc doesnt support this.