I’m writing a command line interpreter and I’m trying to setup formats for individual commands. I have things like the name of the command, the maximum amount of parameters and the minimum amount of parameters. I want to have sort of collection, a sort of prototype of what kind of types the parameters are. My first thought was just to declare a vector without the generics, but then I realized this isn’t Java.
Let’s say I have a command such as ‘read test.dat 2’ I would want a structure showing that the typical read command has a string and then an integer.
Any ideas?
I’m not really clear about what you are asking so I may be getting this wrong.
From your description ,it sounds as if you have an abstract notion of commands, and that they have names and an expected structure in terms of parameters. From your description, it sounds like you would want a list of type identifiers and indications on whether they are optional.
Then, you could just instantiate a command object for each command you expect to work with, and add all of them to a collection of commands.
Alternatively, use a map collection to map from command names to the actual command objects. Each command object can also hold a reference to a handler object to actually execute the command.