votpp::Element Class Reference

#include <votpp.hh>

Inheritance diagram for votpp::Element:

Inheritance graph
[legend]

List of all members.


Detailed Description

Base class for all classes representing VOTable node.

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 ()
ElementmakeCopy ()
 Return the address of a copy of actual node.
Elementnext ()
 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.
Elementparent ()
 Return a pointer to the parent node in the tree.
Elementprev ()
 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
Elementlnext
 Pointer to next object in the VOTable tree.
enum Nodetype lnodetype
 Actual node type.
unsigned int lord
Elementlparent
 Pointer to parent object in the VOTable tree.
Elementlprev
 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

Constructor & Destructor Documentation

Element::~Element (  )  [virtual]

Destructor.

Definition at line 31 of file VOTable.cc.


Member Function Documentation

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 (  ) 

Return the address of a copy of actual node.

Definition at line 246 of file VOTable.cc.

Element * Element::next (  ) 

Return a pointer to the next node in the tree.

Definition at line 63 of file VOTable.cc.

enum Nodetype Element::nodeType (  ) 

Return the actual node type.

Definition at line 46 of file VOTable.cc.

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 (  ) 

Return a pointer to the parent node in the tree.

Definition at line 65 of file VOTable.cc.

Element * Element::prev (  ) 

Return a pointer to the previous node in the tree.

Definition at line 64 of file VOTable.cc.

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  ) 

Set the pointer to the next node.

Definition at line 55 of file VOTable.cc.

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.


Member Data Documentation

enum EncodingType votpp::Element::def_encoding [static, protected]

Default value for "Encoding type" attributes.

Definition at line 317 of file votpp.hh.

const bool Element::def_inclusive = true [static, protected]

Default value for "inclusive" attributes.

Definition at line 308 of file votpp.hh.

enum Resource_type votpp::Element::def_Resource_type [static, protected]

Default value for "Resource type" attributes.

Definition at line 302 of file votpp.hh.

enum Stream_actuate votpp::Element::def_Stream_actuate [static, protected]

Default value for "Stream actuate" attributes.

Definition at line 314 of file votpp.hh.

enum Stream_type votpp::Element::def_Stream_type [static, protected]

Default value for "Stream type" attributes.

Definition at line 311 of file votpp.hh.

enum Values_Type votpp::Element::def_Values_type [static, protected]

Default value for "Values type" attributes.

Definition at line 305 of file votpp.hh.

string votpp::Element::lclassname [protected]

String representation of class name associated with actual node type.

Definition at line 327 of file votpp.hh.

Element* votpp::Element::lnext [protected]

Pointer to next object in the VOTable tree.

Definition at line 330 of file votpp.hh.

enum Nodetype votpp::Element::lnodetype [protected]

Actual node type.

Definition at line 324 of file votpp.hh.

Element* votpp::Element::lparent [protected]

Pointer to parent object in the VOTable tree.

Definition at line 336 of file votpp.hh.

Element* votpp::Element::lprev [protected]

Pointer to previous object in the VOTable tree.

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