frepple::utils::Keyword Class Reference

This class defines a keyword for the frePPLe data model. More...

#include <utils.h>

Inheritance diagram for frepple::utils::Keyword:

List of all members.

Public Types

typedef map< hashtype, Keyword * > tagtable

Public Member Functions

hashtype getHash () const
const string & getName () const
const XMLCh * getXMLCharacters () const
 Keyword (const string &)
 Keyword (const string &, const string &)
const string & stringAttribute () const
const string & stringElement () const
const string & stringEndElement () const
const string & stringStartElement () const
 ~Keyword ()

Static Public Member Functions

static const Keywordfind (const char *)
static tagtablegetTags ()
static hashtype hash (const char *)
static hashtype hash (const string &c)
static hashtype hash (const XMLCh *)
static void printTags ()

Detailed Description

This class defines a keyword for the frePPLe data model.

The keywords are used to define the attribute names for the objects.
They are used as:

  • Element and attribute names in XML documents
  • Attribute names in the Python extension.

Special for this class is the requirement to have a "perfect" hash function, i.e. a function that returns a distinct number for each defined tag. The class prints a warning message when the hash function doesn't satisfy this criterion.

Definition at line 619 of file utils.h.


Member Typedef Documentation

Container for maintaining a list of all tags.

Definition at line 637 of file utils.h.


Constructor & Destructor Documentation

frepple::utils::Keyword::Keyword ( const string &  name)

This is the constructor.
The tag doesn't belong to an XML namespace.

Definition at line 669 of file xmlparser.cpp.

frepple::utils::Keyword::Keyword ( const string &  name,
const string &  nspace 
)

This is the constructor. The tag belongs to the XML namespace passed as second argument.
Note that we still require the first argument to be unique, since it is used as a keyword for the Python extensions.

Definition at line 692 of file xmlparser.cpp.

frepple::utils::Keyword::~Keyword ( )

Destructor.

Definition at line 735 of file xmlparser.cpp.


Member Function Documentation

const Keyword & frepple::utils::Keyword::find ( const char *  name) [static]

Finds a tag when passed a certain string. If no tag exists yet, it will be created.

Definition at line 747 of file xmlparser.cpp.

hashtype frepple::utils::Keyword::getHash ( ) const [inline]

Returns the hash value of the tag.

Definition at line 654 of file utils.h.

const string& frepple::utils::Keyword::getName ( ) const [inline]

Returns the name of the tag.

Definition at line 657 of file utils.h.

Keyword::tagtable & frepple::utils::Keyword::getTags ( ) [static]

Return a reference to a table with all defined tags.

Definition at line 754 of file xmlparser.cpp.

const XMLCh* frepple::utils::Keyword::getXMLCharacters ( ) const [inline]

Returns a pointer to an array of XML characters. This format is used by Xerces for the internal representation of character strings.

Definition at line 661 of file utils.h.

hashtype frepple::utils::Keyword::hash ( const char *  c) [static]

This is the hash function. See the note on the perfectness of this function at the start. This function should be as simple as possible while still garantueeing the perfectness.
The hash function is based on the Xerces-C implementation, with the difference that the hash calculated by our function is portable between platforms.
The hash modulus is 954991 (which is the biggest prime number lower than 1000000).

Definition at line 761 of file xmlparser.cpp.

static hashtype frepple::utils::Keyword::hash ( const string &  c) [inline, static]

This is the hash function.

See also:
hash(const char*)

Definition at line 689 of file utils.h.

hashtype frepple::utils::Keyword::hash ( const XMLCh *  t) [static]

This is the hash function taken an XML character string as input.
The function is expected to return exactly the same result as when a character pointer is passed as argument.

See also:
hash(const char*)

Definition at line 776 of file xmlparser.cpp.

void frepple::utils::Keyword::printTags ( ) [static]

Prints a list of all tags that have been defined. This can be useful for debugging and also for creating a good hashing function.
GNU gperf is a program that can generate a perfect hash function for a given set of symbols.

Definition at line 797 of file xmlparser.cpp.

const string& frepple::utils::Keyword::stringAttribute ( ) const [inline]

Returns a string to start an XML attribute with this tag: TAG="

Definition at line 673 of file utils.h.

const string& frepple::utils::Keyword::stringElement ( ) const [inline]

Returns a string to start an XML element with this tag: <TAG>

Definition at line 670 of file utils.h.

const string& frepple::utils::Keyword::stringEndElement ( ) const [inline]

Returns a string to end an XML element with this tag: </TAG>

Definition at line 667 of file utils.h.

const string& frepple::utils::Keyword::stringStartElement ( ) const [inline]

Returns a string to start an XML element with this tag: <TAG

Definition at line 664 of file utils.h.


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

Documentation generated for frePPLe by  doxygen