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 &, 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 Keyword & | find (const char *) |
static tagtable & | getTags () |
static hashtype | hash (const XMLCh *c) |
static hashtype | hash (const string &c) |
static hashtype | hash (const char *c) |
static void | printTags () |
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 862 of file utils.h.
typedef map<hashtype,Keyword*> frepple::utils::Keyword::tagtable |
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.
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] |
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 763 of file xmlparser.cpp.
const XMLCh* frepple::utils::Keyword::getXMLCharacters | ( | ) | const [inline] |
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.
static hashtype frepple::utils::Keyword::hash | ( | const string & | c | ) | [inline, static] |
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)
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] |
const string& frepple::utils::Keyword::stringElement | ( | ) | const [inline] |
const string& frepple::utils::Keyword::stringEndElement | ( | ) | const [inline] |
const string& frepple::utils::Keyword::stringStartElement | ( | ) | const [inline] |