#include <votpp.hh>
This class can be used to parse a VOTable file, and read it as a whole in a dynamic allocated tree. Only one node is returned by this class: the root node, which is of type VOTABLE. All other nodes can be reached using the Element::next(), Element::prev() and Element::parent() methods.
Suppose you want to simply parse a file and print its content on standard output, the code would look like this:
//Create an instance of the class Parser_Tree tree; Element *node; //Open the file tree.open("my_votable_file"); //Print the tree content tree.root()->print(true); //Finally close the stream. tree.close();
Note that the Element::print() method print the content of all nodes in the tree.
If you want to search for any specific node, say for the address of a FITS file contained in the VOTable you can use a code like this:
//Create an instance of the class Parser_Tree tree; Element *node; //Open the file tree.open("my_votable_file"); //Loop through the stream node = tree.root(); do { if (node->nodeType() == FITS) { Fits* fits = (Fits*) node; cout << "File location is: " << fits->Stream()->href() << endl; } } while (node = node->next()); //Finally close the stream. stream.close();
Definition at line 1653 of file votpp.hh.
Public Member Functions | |
void | free () |
Free all memory allocated for the tree. | |
void | open (std::string filename) |
Open a table from the specified filename. | |
Parser_Tree (bool smartmode=true) | |
Constructor. | |
VOTable * | root () |
~Parser_Tree () | |
Destructor. | |
Private Member Functions | |
void | addNodes (Element *node, unsigned int d) |
Private Attributes | |
bool | flmodified |
True if the table has been modified. | |
VOTable * | lroot |
Pointer to the root node. | |
bool | smartmode |
If "smart" mode is anebled. | |
Parser_Stream | stream |
The underlying stream object. |
Parser_Tree::Parser_Tree | ( | bool | smartmode = true |
) |
Parser_Tree::~Parser_Tree | ( | ) |
void Parser_Tree::free | ( | ) |
void votpp::Parser_Tree::open | ( | std::string | filename | ) |
Open a table from the specified filename.
Once you open a file it will be completely parsed and all information will be stored in a dynamically allocated tree in memory. You can access this tree from the root node using the root() method.
You don't need to "close" the file because it is automatically "closed" once the parsing is completed.
bool votpp::Parser_Tree::flmodified [private] |
VOTable* votpp::Parser_Tree::lroot [private] |
bool votpp::Parser_Tree::smartmode [private] |
Parser_Stream votpp::Parser_Tree::stream [private] |
VOTPP (VOTable C++ Parser) ver. 0.3.2-alpha1
|