This class defines a keyword for the frePPLe data model. More...
#include <utils.h>

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 Keyword & | find (const char *) |
static tagtable & | getTags () |
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.
Member Typedef Documentation
typedef map<hashtype,Keyword*> frepple::utils::Keyword::tagtable |
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 670 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 693 of file xmlparser.cpp.
frepple::utils::Keyword::~Keyword | ( | ) |
Destructor.
Definition at line 736 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 748 of file xmlparser.cpp.
hashtype frepple::utils::Keyword::getHash | ( | ) | const [inline] |
const string& frepple::utils::Keyword::getName | ( | ) | const [inline] |
Keyword::tagtable & frepple::utils::Keyword::getTags | ( | ) | [static] |
Return a reference to a table with all defined tags.
Definition at line 755 of file xmlparser.cpp.
const XMLCh* frepple::utils::Keyword::getXMLCharacters | ( | ) | const [inline] |
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 762 of file xmlparser.cpp.
static hashtype frepple::utils::Keyword::hash | ( | const string & | c | ) | [inline, static] |
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 777 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 798 of file xmlparser.cpp.
const string& frepple::utils::Keyword::stringAttribute | ( | ) | const [inline] |
const string& frepple::utils::Keyword::stringElement | ( | ) | const [inline] |
const string& frepple::utils::Keyword::stringEndElement | ( | ) | const [inline] |
const string& frepple::utils::Keyword::stringStartElement | ( | ) | const [inline] |
The documentation for this class was generated from the following files:
Documentation generated for frePPLe by
