Gromacs
2026.0-dev-20241113-4b16639
|
#include "gmxpre.h"
#include "gromacs/topology/symtab.h"
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <filesystem>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
#include "gromacs/utility/basedefinitions.h"
#include "gromacs/utility/cstringutil.h"
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/gmxassert.h"
#include "gromacs/utility/iserializer.h"
#include "gromacs/utility/smalloc.h"
#include "gromacs/utility/stringutil.h"
#include "gromacs/utility/txtdump.h"
Implements new and legacy symbol table routines.
Functions | |
StringTableEntry | readStringTableEntry (gmx::ISerializer *serializer, const StringTable &table) |
De-serialize StringTableEntry using the index into the table . More... | |
static char * | trim_string (const char *s, char *out, int maxlen) |
Remove leading and trailing whitespace from string and enforce maximum length. More... | |
int | lookup_symtab (t_symtab *symtab, char **name) |
Returns unique handle for name . More... | |
char ** | get_symtab_handle (t_symtab *symtab, int name) |
Returns text string corresponding to index . More... | |
static t_symbuf * | new_symbuf () |
Returns a new initialized entry into the symtab linked list. | |
static char ** | enter_buf (t_symtab *symtab, char *name) |
Low level function to enter new string into legacy symtab. More... | |
char ** | put_symtab (t_symtab *symtab, const char *name) |
Enters a string into the symbol table. More... | |
void | open_symtab (t_symtab *symtab) |
Initialises the symbol table symtab. | |
void | close_symtab (t_symtab gmx_unused *symtab) |
t_symtab * | duplicateSymtab (const t_symtab *symtab) |
Returns a deep copy of symtab . | |
void | done_symtab (t_symtab *symtab) |
Frees the space allocated by the symbol table, including all entries in it. | |
void | free_symtab (t_symtab *symtab) |
Frees the space allocated by the symbol table itself. | |
void | pr_symtab (FILE *fp, int indent, const char *title, t_symtab *symtab) |
Prints human readable form of symtab . More... | |
Variables | |
constexpr int | c_trimSize = 1024 |
Maximum size of character string in table. | |
constexpr int | c_maxBufSize = 5 |
Maximum number of entries in each element of the linked list. | |
|
static |
Low level function to enter new string into legacy symtab.
[in,out] | symtab | Symbol table to add entry to. |
[in] | name | New string to add to symtab. |
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] | symtab | Symbol table to search. |
[in] | index | Entry to find in table. |
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] | symtab | Symbol table to search. |
[in] | name | String pointer into symtab . |
void pr_symtab | ( | FILE * | fp, |
int | indent, | ||
const char * | title, | ||
t_symtab * | symtab | ||
) |
Prints human readable form of symtab
.
[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.
[in,out] | symtab | Symbol table to add string to. |
[in] | name | String to add. |
StringTableEntry readStringTableEntry | ( | gmx::ISerializer * | serializer, |
const StringTable & | table | ||
) |
De-serialize StringTableEntry using the index into the table
.
[in] | serializer | The object containing the serialized index. |
[in] | table | The storage object holding all strings. |
|
static |
Remove leading and trailing whitespace from string and enforce maximum length.
[in] | s | String to trim. |
[in,out] | out | String to return. |
[in] | maxlen | Maximum string length to use. |