votpp::Parser_Tree Class Reference

#include <votpp.hh>

List of all members.


Detailed Description

Parse a VOTable file as a tree.

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.
VOTableroot ()
 ~Parser_Tree ()
 Destructor.

Private Member Functions

void addNodes (Element *node, unsigned int d)

Private Attributes

bool flmodified
 True if the table has been modified.
VOTablelroot
 Pointer to the root node.
bool smartmode
 If "smart" mode is anebled.
Parser_Stream stream
 The underlying stream object.

Constructor & Destructor Documentation

Parser_Tree::Parser_Tree ( bool  smartmode = true  ) 

Constructor.

Definition at line 795 of file VOTable.cc.

Parser_Tree::~Parser_Tree (  ) 

Destructor.

Definition at line 802 of file VOTable.cc.


Member Function Documentation

void Parser_Tree::free (  ) 

Free all memory allocated for the tree.

Definition at line 807 of file VOTable.cc.

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.


Member Data Documentation

bool votpp::Parser_Tree::flmodified [private]

True if the table has been modified.

Definition at line 1656 of file votpp.hh.

VOTable* votpp::Parser_Tree::lroot [private]

Pointer to the root node.

Definition at line 1665 of file votpp.hh.

bool votpp::Parser_Tree::smartmode [private]

If "smart" mode is anebled.

Definition at line 1659 of file votpp.hh.

Parser_Stream votpp::Parser_Tree::stream [private]

The underlying stream object.

Definition at line 1662 of file votpp.hh.


The documentation for this class was generated from the following files:

VOTPP (VOTable C++ Parser) ver. 0.3.2-alpha1
Documentation generated on Sun Nov 18 12:06:20 UTC 2007