votpp::Parser_Stream Class Reference

#include <votpp.hh>

List of all members.


Detailed Description

Parse a VOTable file as a stream.

This class can be used to parse a VOTable file, and read it as a stream, that is one node at a time. Each node is returnd as a pointer to a Element class (see its description) via the next() or node() methods.

The nodes provided by this class aren't linked to other nodes (as with the Parser_Tree class), so their Element::next(), Element::prev() and Element::parent() methods would always return NULL. Nor the nodes knows where they are in the VOTable tree so their Element::depth() method would always return zero.

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_Stream stream;
  Element *node;

  //Open the file
  stream.open("my_votable_file");

  //Loop through the stream
  while (node = stream.next()) {
    //...and print node content
    node->print(true);
  }

  //Finally close the stream.
  stream.close();

Note that the Element::print() method print only the content of current node because it has no link with child nodes.

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_Stream stream;
  Element *node;

  //Open the file
  stream.open("my_votable_file");

  //Loop through the stream
  while (node = stream.next()) {
    if (node->nodeType() == FITS) {
      Fits* fits = (Fits*) node;
      cout << "File location is: " << fits->Stream()->href() << endl;
    }
  }

  //Finally close the stream.
  stream.close();

Definition at line 1472 of file votpp.hh.


Public Member Functions

mcs::RecordSet * binstream ()
void close ()
 Close the file.
unsigned int depth ()
 Return the depth (in the VOTable tree) of current node.
std::string filename ()
 Return the FILENAME of the file actually used.
NodePointer next (bool skipSubTree=false)
 Parse the next node in the VOTable and return a pointer to the node.
NodePointer node ()
 Return a pointer to the current node.
enum Nodetype nodeType ()
 Return the current node type.
void open (std::string filename)
 Open a VOTable file from the specified filename.
 Parser_Stream ()
 Constructor.
void saveBinaryStream (string fn="")
NodePointer skip (unsigned int n=1)
 Skip n nodes and read the next node in the stream.
 ~Parser_Stream ()
 Destructor.

Private Member Functions

int next_xmlnode (bool skipSubTree)
int parse ()

Private Attributes

Binary binary
Column column
bool continue_read
Coosys coosys
Data data
Definitions definitions
Description description
Field field
FieldRef fieldref
Fits fits
bool flnewinfo
 True when some info have been read, the next() method won't return until this is true.
bool flopen
 Tell if a file is open.
Group group
Info info
VOTableReaderSplit input
mcs::RecordSet * lbinstream
unsigned int ldepth
std::string lfilename
 Actual FILENAME of the file being used.
Link link
Elementlnode
enum Nodetype lnodetype
 Actual node type.
Max max
Min min
unsigned int nodeord
 Actual node position in the stream.
Option option
Param param
ParamRef paramref
void * pInput
void * pReader
 The reader used to do the job.
Resource resource
Row row
Stream stream
Table table
Tabledata tabledata
Values values
VOTable votable

Constructor & Destructor Documentation

Parser_Stream::Parser_Stream (  ) 

Constructor.

Definition at line 475 of file VOTable.cc.

Parser_Stream::~Parser_Stream (  ) 

Destructor.

Definition at line 484 of file VOTable.cc.


Member Function Documentation

void Parser_Stream::close (  ) 

Close the file.

Definition at line 551 of file VOTable.cc.

unsigned int Parser_Stream::depth (  ) 

Return the depth (in the VOTable tree) of current node.

Definition at line 499 of file VOTable.cc.

string Parser_Stream::filename (  ) 

Return the FILENAME of the file actually used.

Definition at line 489 of file VOTable.cc.

NodePointer Parser_Stream::next ( bool  skipSubTree = false  ) 

Parse the next node in the VOTable and return a pointer to the node.

Parameters:
skipSubTree If true will ignore all child of current node and read the next node which is on the same depth level.
Returns:
The address of the newly read node, or NULL if end of file has been reached.

Definition at line 739 of file VOTable.cc.

NodePointer Parser_Stream::node (  ) 

Return a pointer to the current node.

You can convert this pointer to the appropriate type as shown in the Element documentation.

Definition at line 505 of file VOTable.cc.

enum Nodetype Parser_Stream::nodeType (  ) 

Return the current node type.

Definition at line 494 of file VOTable.cc.

void votpp::Parser_Stream::open ( std::string  filename  ) 

Open a VOTable file from the specified filename.

If the file cannot be opened an exception will be thrown.

NodePointer Parser_Stream::skip ( unsigned int  n = 1  ) 

Skip n nodes and read the next node in the stream.

Definition at line 776 of file VOTable.cc.


Member Data Documentation

bool votpp::Parser_Stream::flnewinfo [private]

True when some info have been read, the next() method won't return until this is true.

Definition at line 1496 of file votpp.hh.

bool votpp::Parser_Stream::flopen [private]

Tell if a file is open.

Definition at line 1493 of file votpp.hh.

std::string votpp::Parser_Stream::lfilename [private]

Actual FILENAME of the file being used.

Definition at line 1479 of file votpp.hh.

enum Nodetype votpp::Parser_Stream::lnodetype [private]

Actual node type.

Definition at line 1482 of file votpp.hh.

unsigned int votpp::Parser_Stream::nodeord [private]

Actual node position in the stream.

Definition at line 1485 of file votpp.hh.

void* votpp::Parser_Stream::pReader [private]

The reader used to do the job.

Definition at line 1488 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