PROFASI  Version 1.5
Public Member Functions | List of all members
prf_xml::XML_Mini Class Reference

A small class to do the book keeping for XML parsing. More...

#include <prf_xml.hh>

Public Member Functions

 XML_Mini ()
 Default constructor.
size_t read_file (std::string fl)
 Read XML file as a list of Chunk s.
XML_Nodebuild_tree ()
 Build XML tree and return pointer to the root element.
size_t parse_data (std::string &dat)
 Takes a string, and parses it into a list of Chunk objects.
void clear ()
 Clear all data.

Detailed Description

Divides the task into simple logical blocks like reading the file into a list of chunks and then building the XML tree from the chunks. Not really intended for extensive use. Use the interface function get_xml_tree() instead. This is a helper class for the implementation of the functionality in get_xml_tree()

See Also

Member Function Documentation

XML_Node * XML_Mini::build_tree ( )

Constructs an XML tree out of a list of chunks perviously collected using read_file(). Here is the algorithm:

  1. Check that no chunk contains errors
  2. Remove special tags to a separate list
  3. Initialize empty node list "node_buffer"
  4. Search for sequences of tags that read begin, text ... end. In other words, a begin followed by an end with only text in between.
  5. Construct a node using this range of chunks, and remove them from the list.
  6. If the constructed node contains errors (begin and end tag names don't match, name or attribute syntax invalid or the enclosed text has errors) delete the newly created node and put parser state to ERROR.
  7. If an error free node was successfully created, browse the node_buffer for previously created nodes to find nodes enclosed by the newly created node. If any are found, add them as children and remove them from the node_buffer. Finally add the new node to the node_buffer
  8. Repeat everything from step 4 onwards. Go back to the start of the survibing chunk list if the end of the list is encountered and the parser is not in an ERROR state. Continue until the list of Chunks is empty or the process stagnates.
  9. If there is exactly one element in the node_buffer, return it as the root element. Else return NULL
size_t XML_Mini::read_file ( std::string  fl)

Reads an XML file specified by its name and makes a list of Chunk objects out of it. Each of these chunks, by construction, either does not contain any < or > tags, or they appear simultaneously as the first and last characters respectively.

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

PROFASI: Protein Folding and Aggregation Simulator, Version 1.5
© (2005-2016) Anders Irbäck and Sandipan Mohanty
Documentation generated on Mon Jul 18 2016 using Doxygen version 1.8.2