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 () |
Additional Inherited Members | |
![]() | |
NonCopyable () | |
~NonCopyable () |
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.
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 696 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 719 of file xmlparser.cpp.
frepple::utils::Keyword::~Keyword | ( | ) |
Destructor.
Definition at line 762 of file xmlparser.cpp.
|
static |
Finds a tag when passed a certain string. If no tag exists yet, it will be created.
Definition at line 774 of file xmlparser.cpp.
|
inline |
|
inline |
|
static |
Return a reference to a table with all defined tags.
Definition at line 781 of file xmlparser.cpp.
|
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.
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 788 of file xmlparser.cpp.
|
inlinestatic |
|
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.
Definition at line 803 of file xmlparser.cpp.
|
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 824 of file xmlparser.cpp.
|
inline |
|
inline |
|
inline |
|
inline |