Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

xmlreader.cc File Reference

#include "libxml/parser.h"
#include "libxml/parserInternals.h"
#include "libparser.hh"
#include <cstdarg>
#include <ctype.h>
#include <cassert>
#include <vector>
#include <map>
#include <sstream>
#include "tags.cc"

Defines

#define CHAR   xmlChar
 SAX specific type for strings.


Typedefs

typedef map< char *, char *,
compare_str > 
locationmap_t
 The map of locations for quick lookup id -> name.


Enumerations

enum  tag_t {
  TAG_NTA, TAG_IMPORTS, TAG_DECLARATION, TAG_TEMPLATE,
  TAG_INSTANTIATION, TAG_SYSTEM, TAG_NAME, TAG_PARAMETER,
  TAG_LOCATION, TAG_INIT, TAG_TRANSITION, TAG_URGENT,
  TAG_COMMITTED, TAG_SOURCE, TAG_TARGET, TAG_LABEL,
  TAG_NAIL
}
 Enumeration type for tags. More...

enum  state_t {
  ERR, UNKNOWN, INITIAL, NTA,
  IMPORTS, DECLARATION, TEMPLATE, INSTANTIATION,
  SYSTEM, NAME, PARAMETER, LOCATION,
  INIT, TRANSITION, LABEL, URGENT,
  COMMITTED, SOURCE, TARGET, NAIL
}
 We enumerate all possible states of state machine that listens to SAX. More...

enum  labelkind_t {
  L_NONE, L_INV, L_GUARD, L_SYNC,
  L_ASSIGN
}
 We enumerate all possible label kinds to get rid of strings and save the memory. More...


Functions

char * append (char *dest, int32_t &dlen, const CHAR *source, int32_t slen)
 Returns the source appended to dest keeping track of allocated memory.

bool isempty (const char *p)
 returns TRUE if string is NULL, zero length or contains only white spaces otherwise FALSE

bool isAlpha (char c)
bool isIdChr (char c)
char * symbol (const char *str)
 Extracts the alpha-numerical symbol used for variable/type identifiers.

const char * retrieve (const char **attrs, const char *name)
 Retrieves an attribute value from list of attributes given the name of attribute.

char * mystrdup (const char *str)
 Copies the string into a newly allocated memory area.

void NTA_startDocument (void *user_data)
 SAX calls before reading the document.

void NTA_endDocument (void *user_data)
 Final checks just before parsing quits.

void NTA_characters (void *user_data, const CHAR *ch, int32_t len)
 SAX passes tag content here, the content is broken by inner tags and XML entities.

bool checkSiblings (ParserState *s, bool cond)
void NTA_startElement (void *user_data, const CHAR *n, const CHAR **attrs)
 SAX notifies when the tag start is found (e.g.

void NTA_endElement (void *user_data, const CHAR *n)
 SAX notifies when it encounters the end of tag (e.g.

xmlEntityPtr NTA_getEntity (void *user_data, const CHAR *name)
 SAX uses to interpret the XML entities (e.g.

void NTA_warning (void *user_data, const char *msg,...)
 SAX passes its warnings here.

void NTA_error (void *user_data, const char *msg,...)
 SAX passes its errors here.

void NTA_fatalError (void *user_data, const char *msg,...)
 SAX passes its fatal errors here.

int32_t parseXMLBuffer (const char *buffer, ParserBuilder *pb, ErrorHandler *errHandler, bool newxta)
 Parse a buffer in the XML format, reporting the system to the given implementation of the the ParserBuilder interface and reporting errors to the ErrorHandler.

int32_t parseXMLFile (const char *filename, ParserBuilder *pb, ErrorHandler *errHandler, bool newxta)
 Parse the file with the given name assuming it is in the XML format, reporting the system to the given implementation of the the ParserBuilder interface and reporting errors to the ErrorHandler.


Variables

char errormsg [256]
xmlSAXHandler handler
 Function addresses passed to SAX.


Define Documentation

#define CHAR   xmlChar
 

SAX specific type for strings.

xmlChar is treated as char, as written in documentation. Please review the code when multibyte encodings are introduced!


Typedef Documentation

typedef map<char*,char*,compare_str> locationmap_t
 

The map of locations for quick lookup id -> name.


Enumeration Type Documentation

enum labelkind_t
 

We enumerate all possible label kinds to get rid of strings and save the memory.

Enumeration values:
L_NONE 
L_INV 
L_GUARD 
L_SYNC 
L_ASSIGN 

enum state_t
 

We enumerate all possible states of state machine that listens to SAX.

Enumeration values:
ERR 
UNKNOWN 
INITIAL 
NTA 
IMPORTS 
DECLARATION 
TEMPLATE 
INSTANTIATION 
SYSTEM 
NAME 
PARAMETER 
LOCATION 
INIT 
TRANSITION 
LABEL 
URGENT 
COMMITTED 
SOURCE 
TARGET 
NAIL 

enum tag_t
 

Enumeration type for tags.

We use gperf to generate a perfect hash function to map tag strings to one of these tags.

Enumeration values:
TAG_NTA 
TAG_IMPORTS 
TAG_DECLARATION 
TAG_TEMPLATE 
TAG_INSTANTIATION 
TAG_SYSTEM 
TAG_NAME 
TAG_PARAMETER 
TAG_LOCATION 
TAG_INIT 
TAG_TRANSITION 
TAG_URGENT 
TAG_COMMITTED 
TAG_SOURCE 
TAG_TARGET 
TAG_LABEL 
TAG_NAIL 


Function Documentation

char* append char *  dest,
int32_t &  dlen,
const CHAR *  source,
int32_t  slen
[static]
 

Returns the source appended to dest keeping track of allocated memory.

dest - the destination string, a new page will be allocated if NULL dlen - memory of bytes allocated for dest source - the source string, not necessary ended with '' slen - the byte number to be appended from source. returns the dest if there were enough memory, a new allocated string if not enough memory (the old is deleted!)

bool checkSiblings ParserState *  s,
bool  cond
[static]
 

bool isAlpha char  c  )  [static]
 

bool isempty const char *  p  )  [static]
 

returns TRUE if string is NULL, zero length or contains only white spaces otherwise FALSE

bool isIdChr char  c  )  [static]
 

char* mystrdup const char *  str  )  [static]
 

Copies the string into a newly allocated memory area.

The new string is allocated with new[].

void NTA_characters void *  user_data,
const CHAR *  ch,
int32_t  len
[static]
 

SAX passes tag content here, the content is broken by inner tags and XML entities.

void NTA_endDocument void *  user_data  )  [static]
 

Final checks just before parsing quits.

void NTA_endElement void *  user_data,
const CHAR *  n
[static]
 

SAX notifies when it encounters the end of tag (e.g.

input: => n="tag")

void NTA_error void *  user_data,
const char *  msg,
  ...
[static]
 

SAX passes its errors here.

void NTA_fatalError void *  user_data,
const char *  msg,
  ...
[static]
 

SAX passes its fatal errors here.

xmlEntityPtr NTA_getEntity void *  user_data,
const CHAR *  name
[static]
 

SAX uses to interpret the XML entities (e.g.

input:< => "<")

void NTA_startDocument void *  user_data  )  [static]
 

SAX calls before reading the document.

Used to initialize state before actual parse.

void NTA_startElement void *  user_data,
const CHAR *  n,
const CHAR **  attrs
[static]
 

SAX notifies when the tag start is found (e.g.

input:<tag> => n="tag")

void NTA_warning void *  user_data,
const char *  msg,
  ...
[static]
 

SAX passes its warnings here.

int32_t parseXMLBuffer const char *  buffer,
UTAP::ParserBuilder ,
UTAP::ErrorHandler ,
bool  newxta
 

Parse a buffer in the XML format, reporting the system to the given implementation of the the ParserBuilder interface and reporting errors to the ErrorHandler.

If newxta is true, then the 4.x syntax is used; otherwise the 3.x syntax is used. On success, this function returns with a positive value.

int32_t parseXMLFile const char *  filename,
UTAP::ParserBuilder ,
UTAP::ErrorHandler ,
bool  newxta
 

Parse the file with the given name assuming it is in the XML format, reporting the system to the given implementation of the the ParserBuilder interface and reporting errors to the ErrorHandler.

If newxta is true, then the 4.x syntax is used; otherwise the 3.x syntax is used. On success, this function returns with a positive value.

const char* retrieve const char **  attrs,
const char *  name
[static]
 

Retrieves an attribute value from list of attributes given the name of attribute.

attrs - the list of strings terminated with NULL, even members are attribute names, odd members are attribute values. name - the name of attribute

Returns NULL if attribute not found, or the value of the attribute (not a copy of the string!).

char* symbol const char *  str  )  [static]
 

Extracts the alpha-numerical symbol used for variable/type identifiers.

Identifier starts with alpha and further might contain digits, white spaces are ignored.

Throws a TypeException is identifier is invalid or a newly allocated string to be destroyed with delete [].


Variable Documentation

char errormsg[256] [static]
 

xmlSAXHandler handler [static]
 

Initial value:

{ NULL, NULL, NULL, NULL, NULL, NTA_getEntity, NULL, NULL, NULL, NULL, NULL, NULL, NTA_startDocument, NTA_endDocument, NTA_startElement, NTA_endElement, NULL, NTA_characters, NULL, NULL, NULL, NTA_warning, NTA_error, NTA_fatalError }
Function addresses passed to SAX.

SAX validates only the XML welformedness if all members a NULL. (NULL members are ignored).


Generated on Sat May 15 12:33:42 2004 for libutap by doxygen 1.3.7