I am trying to have multiple sets of information for the same argument. For example
http://pastebin.com/H8ZAMnFZ
will show the full current directory or all the files in the directory of one extension. Instead of using this function multiple times to display types of different extensions, I'd rather have
listdir(".";".txt",".rtf",".doc")
and then change the code to allow for this. However with only commas separating the arguments, I can't think of a way to do this.
The main reason i ask is because in a for loop, the difference in arguments are seen by ';' not ',' and I was hoping this could be done similarly.
Yes i could send an array of strings, or a vector as you suggested, but I was hoping for an easily understood standard for the function, so that i don't have to go back to it in the future to understand the arguments. Thanks for the link, I haven't heard of that before.
But i feel it would be easier if i could just use a semicolon, so that i don't have to pass... well it would basically be a copy of ".txt",".rtf".".doc" in a different form.
Stringstreams provide a similar syntax. You can copy it in a class of your own you can use as argument.
Or you can put in the function some functionality that will parse a more complex string ( eg ".txt|.rtf|.doc" ) dividing each part separated by '|' ( or whatever character you choose ) into different strings
C++0x Will allow something like this: listdir ( ".", {".txt",".rtf",".doc"} )
if the second parameter is a vector or some other sequence container
bazzy, thanks! I didn't think about parsing the data with a unique character (which is ironic, considering the program is for parsing text...) That will work nicely.