#include <votpp.hh>
Each node of a VOTable is represented in the C++ code by a class with the same name of the node (for example VOTable, Info, Tabledata, etc...). Each class has the same attributes as the VOTable node counterpart, this way you can access VOTable data using a syntax which closely resemble the VOTable names:
VOTable->Description()->value() VOTable->Resource(2)->Table(1)->Data()-> TableData()->Row(0)->Column(5)->value() ...etc...
All these classes derives from the Element class which provides some basic methods common to all nodes. Furthermore the nodes read with Parser_Stream and Parser_Tree are returned as pointer to Element objects. Then you can use the nodeType() method to distinguish between different node types, and cast it to the appropriate type. An example follows:
//Declare a pointer to each node type VOTable *VOTable; Resource *Resource; Description *Description; Definitions *Definitions; Info *Info; Param *Param; Table *Table; Field *Field; Group *Group; FieldRef *FieldRef; ParamRef *ParamRef; Values *Values; Min *Min; Max *Max; Option *Option; Link *Link; Data *Data; Tabledata *Tabledata; Column *Column; Row *Row; Fits *Fits; Binary *Binary; Stream *Stream; Coosys *Coosys; //Create a VOTable stream reader. Parser_Stream stream; //Open file and start parsing... //Get pointer to current node... Element* node = stream.node(); //...and cast it to appropriate type switch (node->nodetype()) { case VOTABLE: VOTable = (VOTable *) node; break; case RESOURCE: Resource = (Resource *) node; break; case DESCRIPTION: Description = (Description*) node; break; case DEFINITIONS: Definitions = (Definitions*) node; break; case INFO: Info = (Info *) node; break; case PARAM: Param = (Param *) node; break; case TABLE: Table = (Table *) node; break; case FIELD: Field = (Field *) node; break; case GROUP: Group = (Group *) node; break; case FIELDref: FieldRef = (FieldRef *) node; break; case PARAMref: ParamRef = (ParamRef *) node; break; case VALUES: Values = (Values *) node; break; case MIN: Min = (Min *) node; break; case MAX: Max = (Max *) node; break; case OPTION: Option = (Option *) node; break; case LINK: Link = (Link *) node; break; case DATA: Data = (Data *) node; break; case TABLEDATA: Tabledata = (Tabledata *) node; break; case TD: Column = (Column *) node; break; case TR: Row = (Row *) node; break; case FITS: Fits = (Fits *) node; break; case BINARY: Binary = (Binary *) node; break; case STREAM: Stream = (Stream *) node; break; case COOSYS: Coosys = (Coosys *) node; break; }
Definition at line 297 of file votpp.hh.
Public Member Functions | |
string | className () |
Return the name of the class associated with actual node type. | |
unsigned int | depth () |
Return the depth of actual node in the tree. | |
virtual void | done () |
Element * | makeCopy () |
Return the address of a copy of actual node. | |
Element * | next () |
Return a pointer to the next node in the tree. | |
enum Nodetype | nodeType () |
Return the actual node type. | |
unsigned int | ord () |
Return the ordering id for the node. | |
Element * | parent () |
Return a pointer to the parent node in the tree. | |
Element * | prev () |
Return a pointer to the previous node in the tree. | |
virtual void | print (bool verbose) |
Print node content. | |
virtual void | reset () |
Free all resources associated with the node, that is empty all attribute's value. | |
virtual bool | setAttribute (std::string name, std::string value) |
Set an atttribute value. | |
virtual bool | setChild (Element *child) |
Set the pointer to the child node. | |
bool | setNext (Element *next) |
Set the pointer to the next node. | |
virtual | ~Element () |
Destructor. | |
Static Public Member Functions | |
static std::string | space_indent (int d) |
Provide pspace for indentation. | |
static bool | sto_bool (std::string s) |
Return return true if the string was "yes" or "1", otherwise return false. | |
static enum Coosys_system | sto_Coosys_system (std::string s) |
Parse a string and return the corresponding coordinate system. | |
static enum Datatype | sto_Datatype (std::string s) |
Parse a string and return the corresponding data type. | |
static enum EncodingType | sto_EncodingType (std::string s) |
Parse a string and return the corresponding encoding type. | |
static enum Field_type | sto_Field_type (std::string s) |
Parse a string and return the corresponding field type. | |
static enum Link_content_role | sto_Link_content_role (std::string s) |
Parse a string and return the corresponding link content role. | |
static enum Nodetype | sto_Nodetype (std::string s) |
Parse a string and return the corresponding node type. | |
static enum Resource_type | sto_Resource_type (std::string s) |
Parse a string and return the corresponding resource type. | |
static enum Stream_actuate | sto_Stream_actuate (std::string s) |
Parse a string and return the corresponding stream actuate method. | |
static enum Stream_type | sto_Stream_type (std::string s) |
Parse a string and return the corresponding stream type. | |
static enum Values_Type | sto_Values_type (std::string s) |
Parse a string and return the corresponding value type. | |
Protected Member Functions | |
virtual void | hk_reset () |
virtual void | hk_setAttribute (std::string name, std::string value) |
virtual void | hk_setChild (Element *child) |
void | setParentInChild (Element *child) |
Protected Attributes | |
string | lclassname |
String representation of class name associated with actual node type. | |
unsigned int | ldepth |
Element * | lnext |
Pointer to next object in the VOTable tree. | |
enum Nodetype | lnodetype |
Actual node type. | |
unsigned int | lord |
Element * | lparent |
Pointer to parent object in the VOTable tree. | |
Element * | lprev |
Pointer to previous object in the VOTable tree. | |
Static Protected Attributes | |
static const std::string | def_empty = "" |
static enum EncodingType | def_encoding |
Default value for "Encoding type" attributes. | |
static const bool | def_inclusive = true |
Default value for "inclusive" attributes. | |
static enum Resource_type | def_Resource_type |
Default value for "Resource type" attributes. | |
static enum Stream_actuate | def_Stream_actuate |
Default value for "Stream actuate" attributes. | |
static enum Stream_type | def_Stream_type |
Default value for "Stream type" attributes. | |
static enum Values_Type | def_Values_type |
Default value for "Values type" attributes. | |
Friends | |
class | Parser_Stream |
Element::~Element | ( | ) | [virtual] |
string Element::className | ( | ) |
Return the name of the class associated with actual node type.
Definition at line 47 of file VOTable.cc.
unsigned int Element::depth | ( | ) |
Return the depth of actual node in the tree.
VOTable nodes are at depth 0.
Definition at line 71 of file VOTable.cc.
Element * Element::makeCopy | ( | ) |
Element * Element::next | ( | ) |
enum Nodetype Element::nodeType | ( | ) |
unsigned int Element::ord | ( | ) |
Return the ordering id for the node.
This information can be used with Parser_Stream::skip() method to quickly locate the node inside a stream.
Definition at line 75 of file VOTable.cc.
Element * Element::parent | ( | ) |
Element * Element::prev | ( | ) |
void Element::print | ( | bool | verbose | ) | [virtual] |
Print node content.
This method prints on standard output all the node content, as long as each attribute's value. It also display indentation using the space_indent() and depth() method.
Once the node content had been print, it also call the print() method on all available child nodes.
Reimplemented in votpp::Description, votpp::Coosys, votpp::Info, votpp::Link, votpp::FieldRef, votpp::ParamRef, votpp::Stream, votpp::Column, votpp::Min, votpp::Max, votpp::Option, votpp::Row, votpp::Tabledata, votpp::Fits, votpp::Binary, votpp::Values, votpp::Field, votpp::Param, votpp::Group, votpp::Data, votpp::Table, votpp::Resource, votpp::Definitions, and votpp::VOTable.
Definition at line 49 of file VOTable.cc.
void Element::reset | ( | ) | [virtual] |
Free all resources associated with the node, that is empty all attribute's value.
Reimplemented in votpp::Description, votpp::Coosys, votpp::Info, votpp::Link, votpp::FieldRef, votpp::ParamRef, votpp::Stream, votpp::Column, votpp::Min, votpp::Max, votpp::Option, votpp::Row, votpp::Tabledata, votpp::Fits, votpp::Binary, votpp::Values, votpp::Field, votpp::Param, votpp::Group, votpp::Data, votpp::Table, votpp::Resource, votpp::Definitions, and votpp::VOTable.
Definition at line 50 of file VOTable.cc.
virtual bool votpp::Element::setAttribute | ( | std::string | name, | |
std::string | value | |||
) | [virtual] |
Set an atttribute value.
bool Element::setChild | ( | Element * | child | ) | [virtual] |
Set the pointer to the child node.
Reimplemented in votpp::Description, votpp::Coosys, votpp::Info, votpp::Link, votpp::FieldRef, votpp::ParamRef, votpp::Stream, votpp::Column, votpp::Min, votpp::Max, votpp::Option, votpp::Row, votpp::Tabledata, votpp::Fits, votpp::Binary, votpp::Values, votpp::Field, votpp::Param, votpp::Group, votpp::Data, votpp::Table, votpp::Resource, votpp::Definitions, and votpp::VOTable.
Definition at line 54 of file VOTable.cc.
bool Element::setNext | ( | Element * | next | ) |
string Element::space_indent | ( | int | d | ) | [static] |
Provide pspace for indentation.
This method is used to display the correct indentation between different level for VOTable nodes.
The string returned contain a number of spaces that equal four time the value in the parameter plus a four character long field with the value itself, padded with zeros.
Definition at line 79 of file VOTable.cc.
static bool votpp::Element::sto_bool | ( | std::string | s | ) | [static] |
Return return true if the string was "yes" or "1", otherwise return false.
static enum Coosys_system votpp::Element::sto_Coosys_system | ( | std::string | s | ) | [static] |
Parse a string and return the corresponding coordinate system.
static enum Datatype votpp::Element::sto_Datatype | ( | std::string | s | ) | [static] |
Parse a string and return the corresponding data type.
static enum EncodingType votpp::Element::sto_EncodingType | ( | std::string | s | ) | [static] |
Parse a string and return the corresponding encoding type.
static enum Field_type votpp::Element::sto_Field_type | ( | std::string | s | ) | [static] |
Parse a string and return the corresponding field type.
static enum Link_content_role votpp::Element::sto_Link_content_role | ( | std::string | s | ) | [static] |
Parse a string and return the corresponding link content role.
static enum Nodetype votpp::Element::sto_Nodetype | ( | std::string | s | ) | [static] |
Parse a string and return the corresponding node type.
static enum Resource_type votpp::Element::sto_Resource_type | ( | std::string | s | ) | [static] |
Parse a string and return the corresponding resource type.
static enum Stream_actuate votpp::Element::sto_Stream_actuate | ( | std::string | s | ) | [static] |
Parse a string and return the corresponding stream actuate method.
static enum Stream_type votpp::Element::sto_Stream_type | ( | std::string | s | ) | [static] |
Parse a string and return the corresponding stream type.
static enum Values_Type votpp::Element::sto_Values_type | ( | std::string | s | ) | [static] |
Parse a string and return the corresponding value type.
enum EncodingType votpp::Element::def_encoding [static, protected] |
const bool Element::def_inclusive = true [static, protected] |
enum Resource_type votpp::Element::def_Resource_type [static, protected] |
enum Stream_actuate votpp::Element::def_Stream_actuate [static, protected] |
enum Stream_type votpp::Element::def_Stream_type [static, protected] |
enum Values_Type votpp::Element::def_Values_type [static, protected] |
string votpp::Element::lclassname [protected] |
Element* votpp::Element::lnext [protected] |
enum Nodetype votpp::Element::lnodetype [protected] |
Element* votpp::Element::lparent [protected] |
Element* votpp::Element::lprev [protected] |
VOTPP (VOTable C++ Parser) ver. 0.3.2-alpha1
|