#include <votpp.hh>
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 |
Element * | lnode |
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 |
Parser_Stream::Parser_Stream | ( | ) |
Parser_Stream::~Parser_Stream | ( | ) |
void Parser_Stream::close | ( | ) |
unsigned int Parser_Stream::depth | ( | ) |
string Parser_Stream::filename | ( | ) |
NodePointer Parser_Stream::next | ( | bool | skipSubTree = false |
) |
Parse the next node in the VOTable and return a pointer to the node.
skipSubTree | If true will ignore all child of current node and read the next node which is on the same depth level. |
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 | ( | ) |
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 |
) |
bool votpp::Parser_Stream::flnewinfo [private] |
bool votpp::Parser_Stream::flopen [private] |
std::string votpp::Parser_Stream::lfilename [private] |
enum Nodetype votpp::Parser_Stream::lnodetype [private] |
unsigned int votpp::Parser_Stream::nodeord [private] |
void* votpp::Parser_Stream::pReader [private] |
VOTPP (VOTable C++ Parser) ver. 0.3.2-alpha1
|