In article <40435691-5738-4df3-8dfe-e81de017e9fa@
2g2000hsn.googlegroups.com>,
says...
> Hi there!
> I need a C++ library that can organize and write scientific (and
> numerical overall) data in tables. I have been fighting with
> std:
fstream and plain ASCII files, but it is difficult to position
> columns by an offset, impossible to draw table borders etc. I am
> currently thinking of a class that is able to write to an html file,
> e.g. As far as I know, html offers much better text (and table)
> layout. And the format is portable! What I need is a C++ facility to
> automate the generation process. It doesn't need to be html
> necessarily - as long as the output is nice, it will be ok. Even a pdf
> file could suit me. Any ideas?
As far as C++ cares, HTML is just a text file with some slightly unusual
contents.
If the format you're going to use is relatively fixed, so you don't mind
encoding its overall structure into the structure of your code, you can
pretty easily create some objects that emit an opening HTML tag in their
ctor, and a matching closing tag in their dtor.
Another alternative is to create some stream manipulators that emit HTML
tags as needed. You can either create separate manipulators for the
open/close tags, or you can create a manipulator that takes a parameter,
and encloses its parameter within the appropriate open/close tags.
> The next question: I also need to plot some scientific data. Say, I
> need the graphics in a vector format and not a raster pixels. I might
> consider importing the data in Excel for later editing, e.g. What C++
> library can do that?
If you want to export the data for reading by Excel, the obvious way
would be to emit a file of comma separated values. Reading CSV files is
a bit of a pain, but writing them is pretty trivial -- you basically
convert any embedded quote to a pair of quotes, enclose each value in
quotes, and put commas between the quoted fields. The hardest part is
probably keeping track of ends of lines and assuring you only put a
comma _between_ fields, not after the last field on a line.
A CSV file basically just includes your raw data, and it's up to the
user to pick the appropriate type of plot in Excel (or whatever). If you
know much about your data, you might be able to save your user trouble
by having your program specify plot types more directly. In this case,
something like gnuplot might be considerably easier to use in the long
term.
--
Later,
Jerry.
The universe is a figment of its own imagination.