Gromacs  2021-beta2-UNCHECKED
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Typedefs | Functions
symtab.h File Reference
#include <stdio.h>
#include <functional>
#include <string>
#include <unordered_map>
#include <vector>
#include "gromacs/utility/gmxassert.h"
+ Include dependency graph for symtab.h:
+ This graph shows which files directly or indirectly include this file:


Declares modern and legacy symbol table used to store strings of characters.

David van der Spoel
Paul Bauer


class  StringTable
 A class to store strings for lookup. More...
class  StringTableEntry
 Helper class to access members in StringTable. More...
class  StringTableBuilder
 Builds a memory efficient storage for strings of characters. More...
struct  t_symbuf
 Legacy symbol table entry as linked list. More...


using StringTablePair = std::pair< std::string, int >
 Convenience typedef for pair stored in map.
using StringReference = std::reference_wrapper< const std::string >
 Convenience typedef for string reference wrapper.


StringTableEntry readStringTableEntry (gmx::ISerializer *serializer, const StringTable &table)
 De-serialize StringTableEntry using the index into the table. More...
void open_symtab (t_symtab *symtab)
 Initialises the symbol table symtab.
void close_symtab (t_symtab *symtab)
 Undoes the effect of open_symtab() More...
t_symtab * duplicateSymtab (const t_symtab *symtab)
 Returns a deep copy of symtab.
void free_symtab (t_symtab *symtab)
 Frees the space allocated by the symbol table itself.
void done_symtab (t_symtab *symtab)
 Frees the space allocated by the symbol table, including all entries in it.
char ** put_symtab (t_symtab *symtab, const char *name)
 Enters a string into the symbol table. More...
int lookup_symtab (t_symtab *symtab, char **name)
 Returns unique handle for name. More...
char ** get_symtab_handle (t_symtab *symtab, int index)
 Returns text string corresponding to index. More...
void pr_symtab (FILE *fp, int indent, const char *title, t_symtab *symtab)
 Prints human readable form of symtab. More...

Function Documentation

void close_symtab ( t_symtab *  symtab)

Undoes the effect of open_symtab()

After invoking this function, no value can be added to the symbol table, only values can be retrieved using get_symtab_handle().

Note that this does no work.

[in,out]symtabSymbol table to close.
char** get_symtab_handle ( t_symtab *  symtab,
int  index 

Returns text string corresponding to index.

index needs to be value obtained from call to lookup_symtab(). get_symtab_handle() and lookup_symtab() are inverse functions.

[in]symtabSymbol table to search.
[in]indexEntry to find in table.
String pointer into symtab corresponding to the entry.
int lookup_symtab ( t_symtab *  symtab,
char **  name 

Returns unique handle for name.

Looks up the string pointer name in the symbol table and returns the index in it to the matching entry. Gives fatal error if name is not found. name has to be entered first using put_symtab().

[in]symtabSymbol table to search.
[in]nameString pointer into symtab.
Unique index to position in symbol table.
void pr_symtab ( FILE *  fp,
int  indent,
const char *  title,
t_symtab *  symtab 

Prints human readable form of symtab.

[in]fpFile to print to.
[in]indentNumber of spaces to use for indentation.
[in]titleName for header text.
[in]symtabSymbol table to print out.
char** put_symtab ( t_symtab *  symtab,
const char *  name 

Enters a string into the symbol table.

If the string name was not present before, a reference to a copy is returned, else a reference to the earlier entered value is returned. Strings are trimmed of spaces.

[in,out]symtabSymbol table to add string to.
[in]nameString to add.
Pointer to entry of string in symtab.
StringTableEntry readStringTableEntry ( gmx::ISerializer serializer,
const StringTable table 

De-serialize StringTableEntry using the index into the table.

[in]serializerThe object containing the serialized index.
[in]tableThe storage object holding all strings.
The entry into the Table as StringTableEntry.