O
OneLG13
I have a program that uses a scripting language that does not support formating
strings with a printf syntax. Thus, I am writing a plugin to add the
functionality. The entry point and argument passing of the scripting language
to my plugin does not use standard c va_arg/list arguments for arbitrary number
of arguments but a c++ container object to achieve a similar approach.
I thought I could just construct my own array with the arguments (by looking
for the % specifications in the format string provided) and then just pass it
to sprintf, like:
char ret[1024];
sprintf( ret, fmt, args );
Where fmt is the string the user provided to be used as format, and args is the
list of arguments (a mix of ints, doubles, char*, etc. stored in a char* array
(?) ).
However, I am unsure how to create this list of options. That is, is there a
way I can safely create a va_list of arguments manually? And do it portably so
that the code works on linux/win32?
I can hack something that will work for a limited number of arguments, but I am
looking for something nicer that would allow any arbitrary number of arguments.
Any suggestions appreciated.
strings with a printf syntax. Thus, I am writing a plugin to add the
functionality. The entry point and argument passing of the scripting language
to my plugin does not use standard c va_arg/list arguments for arbitrary number
of arguments but a c++ container object to achieve a similar approach.
I thought I could just construct my own array with the arguments (by looking
for the % specifications in the format string provided) and then just pass it
to sprintf, like:
char ret[1024];
sprintf( ret, fmt, args );
Where fmt is the string the user provided to be used as format, and args is the
list of arguments (a mix of ints, doubles, char*, etc. stored in a char* array
(?) ).
However, I am unsure how to create this list of options. That is, is there a
way I can safely create a va_list of arguments manually? And do it portably so
that the code works on linux/win32?
I can hack something that will work for a limited number of arguments, but I am
looking for something nicer that would allow any arbitrary number of arguments.
Any suggestions appreciated.