Is there a generally accepted means of generating reports in C
and/or C++?
In particular, I have an application with many parameterized text
strings that get displayed to a user. These could be as simple as
"The value of x is 19.2134", to a lengthy paragraph describing
something in detail.
The strings may appear in plain text form, or need to be put into a
structured document for nicer formatting (e.g. HTML).
The quick and dirty way to accomplish what I want is to just have
inline code, ala
fprintf(report_file, "The value of x is %lf\n", x);
Obviously, if there are any number of these types of reports, it
becomes a maintenance nightmare.
I'd like to keep my raw verbage (e.g. "The value of x is ") in some
type of separate data source (i.e. not part of the source code). Be
it individual plain text files, XML data or even a database, is
fine---it's the mechanism that cleanly (and flexibly) ties the
verbage to the parameters generated by the program.
Scripting languages tend to support this type of thing very
well---particularly PHP, where I can imbed variables in HTML
templates pretty easily.
I'd like this to be relatively simple as well. Some ideas I've had
are along the lines of having a "store" (database, flat files, XML,
etc) of strings, and the strings have special codes to represent
variable data.
For example, I might have a file that contains this:
The value of x is ::VARIABLE_X::
And write some function or class that would know to replace
"::VARIABLE_X::" with something appropriate.
But even with this "solution", the text store has to know something
about the code and/or the code has to know something about the info
contained in the text store.
I'd like as clean a separation between the text store and the code
as possible.
Anyone have any suggestions on ways to achieve something like this?
Thanks!
Matt
--
Matt Garman
email at: http://raw-sewage.net/index.php?file=email