Public Types | Public Member Functions | Static Public Member Functions

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:
frepple::utils::NonCopyable

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 &, const string &)
 Keyword (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 *c)
static hashtype hash (const string &c)
static hashtype hash (const XMLCh *c)
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:

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 691 of file utils.h.


Member Typedef Documentation

Container for maintaining a list of all tags.

Definition at line 709 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 678 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 701 of file xmlparser.cpp.

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

Destructor.

Definition at line 744 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 756 of file xmlparser.cpp.

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

Returns the hash value of the tag.

Definition at line 726 of file utils.h.

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

Returns the name of the tag.

Definition at line 729 of file utils.h.

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

Return a reference to a table with all defined tags.

Definition at line 763 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 733 of file utils.h.

static hashtype frepple::utils::Keyword::hash ( const char *  c  )  [inline, 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.
Currently we use the hash functions provided by Xerces. We use 954991 as the hash modulus (954991 being the first prime number lower than 1000000)

Definition at line 755 of file utils.h.

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

This is the hash function.

See also:
hash(const char*)

Definition at line 765 of file utils.h.

static hashtype frepple::utils::Keyword::hash ( const XMLCh *  c  )  [inline, 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 777 of file utils.h.

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 770 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 745 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 742 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 739 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 736 of file utils.h.


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