#include <stdio.h>
#include <functional>
#include <string>
#include <unordered_map>
#include <vector>
#include "gromacs/utility/basedefinitions.h"
#include "gromacs/utility/gmxassert.h"
|
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.
|
|
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.
- Parameters
-
[in,out] | symtab | Symbol 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.
- Parameters
-
[in] | symtab | Symbol table to search. |
[in] | index | Entry to find in table. |
- Returns
- 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().
- Parameters
-
[in] | symtab | Symbol table to search. |
[in] | name | String pointer into symtab . |
- Returns
- 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
.
- Parameters
-
[in] | fp | File to print to. |
[in] | indent | Number of spaces to use for indentation. |
[in] | title | Name for header text. |
[in] | symtab | Symbol 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.
- Parameters
-
[in,out] | symtab | Symbol table to add string to. |
[in] | name | String to add. |
- Returns
- Pointer to entry of string in symtab.
De-serialize StringTableEntry using the index into the table
.
- Parameters
-
[in] | serializer | The object containing the serialized index. |
[in] | table | The storage object holding all strings. |
- Returns
- The entry into the Table as StringTableEntry.