KiCad PCB EDA Suite
hashtables.h File Reference
#include <eda_item.h>
#include <wx/string.h>
#include <unordered_map>

Go to the source code of this file.


struct  iequal_to
 Equality test for "const char*" type used in very specialized KEYWORD_MAP below. More...
struct  fnv_1a
 Very fast and efficient hash function for "const char*" type, used in specialized KEYWORD_MAP below. More...
 Hash function for wxString, counterpart of std::string hash. More...


#define DECL_HASH_FOR_SWIG(TypeName, KeyType, ValueType)   typedef std::unordered_map<KeyType, ValueType> TypeName;
 Declare a std::unordered_map but no swig template. More...


typedef std::unordered_map< const char *, int, fnv_1a, iequal_toKEYWORD_MAP
 A hashtable made of a const char* and an int. More...
typedef std::unordered_map< std::string, EDA_RECTRECT_MAP
 Map a C string to an EDA_RECT. More...

Macro Definition Documentation


#define DECL_HASH_FOR_SWIG (   TypeName,
)    typedef std::unordered_map<KeyType, ValueType> TypeName;

Declare a std::unordered_map but no swig template.

Definition at line 116 of file hashtables.h.

Typedef Documentation


typedef std::unordered_map< const char*, int, fnv_1a, iequal_to > KEYWORD_MAP

A hashtable made of a const char* and an int.

The use of this type outside very specific circumstances is foolish since there is no storage provided for the actual C string itself.

This type assumes use with type KEYWORD that is created by CMake and that table creates constant storage for C strings (and pointers to those C strings). Here we are only interested in the C strings themselves and only the pointers are duplicated within the hashtable. If the strings were not constant and fixed, this type would not work. Also note that normally a hashtable (i.e. unordered_map) using a const char* key would simply compare the 32 bit or 64 bit pointers themselves, rather than the C strings which they are known to point to in this context. I force the latter behavior by supplying both "hash" and "equality" overloads to the hashtable (unordered_map) template.

Dick Hollenbeck

Definition at line 138 of file hashtables.h.


typedef std::unordered_map< std::string, EDA_RECT > RECT_MAP

Map a C string to an EDA_RECT.

The key is the classname of the derived wxformbuilder dialog.

Definition at line 142 of file hashtables.h.