Better selection stdin handling.
[gromacs/qmmm-gamess-us.git] / src / gmxlib / selection / symrec.h
blob8284169b96bbf2b8e6fb02a78a052b6c4c5b8c3c
1 /*
3 * This source code is part of
5 * G R O M A C S
7 * GROningen MAchine for Chemical Simulations
9 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
10 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
11 * Copyright (c) 2001-2009, The GROMACS development team,
12 * check out http://www.gromacs.org for more information.
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * If you want to redistribute modifications, please consider that
20 * scientific software is very special. Version control is crucial -
21 * bugs must be traceable. We will be happy to consider code for
22 * inclusion in the official distribution, but derived work must not
23 * be called official GROMACS. Details are found in the README & COPYING
24 * files - if they are missing, get the official version at www.gromacs.org.
26 * To help us fund GROMACS development, we humbly ask that you cite
27 * the papers on the package - you can find them in the top README file.
29 * For more info, check our website at http://www.gromacs.org
31 /*! \internal \file
32 * \brief Handling of selection parser symbol table.
34 * This is an implementation header: there should be no need to use it outside
35 * this directory.
37 #ifndef SELECTION_SYMREC_H
38 #define SELECTION_SYMREC_H
40 struct t_selelem;
41 struct gmx_ana_selmethod_t;
43 /** Defines the type of the symbol. */
44 typedef enum
46 SYMBOL_RESERVED, /**< The symbol is a reserved keyword. */
47 SYMBOL_VARIABLE, /**< The symbol is a variable. */
48 SYMBOL_METHOD, /**< The symbol is a selection method. */
49 SYMBOL_POS, /**< The symbol is a position keyword. */
50 } e_symbol_t;
52 /** Symbol table for the selection parser. */
53 typedef struct gmx_sel_symtab_t gmx_sel_symtab_t;
54 /** Single symbol for the selection parser. */
55 typedef struct gmx_sel_symrec_t gmx_sel_symrec_t;
57 /** Returns the name of a symbol. */
58 char *
59 _gmx_sel_sym_name(gmx_sel_symrec_t *sym);
60 /** Returns the type of a symbol. */
61 e_symbol_t
62 _gmx_sel_sym_type(gmx_sel_symrec_t *sym);
63 /** Returns the method associated with a \ref SYMBOL_METHOD symbol. */
64 struct gmx_ana_selmethod_t *
65 _gmx_sel_sym_value_method(gmx_sel_symrec_t *sym);
66 /** Returns the method associated with a \ref SYMBOL_VARIABLE symbol. */
67 struct t_selelem *
68 _gmx_sel_sym_value_var(gmx_sel_symrec_t *sym);
70 /** Creates a new symbol table. */
71 int
72 _gmx_sel_symtab_create(gmx_sel_symtab_t **tabp);
73 /** Frees all memory allocated for a symbol table. */
74 void
75 _gmx_sel_symtab_free(gmx_sel_symtab_t *tab);
76 /** Finds a symbol by name. */
77 gmx_sel_symrec_t *
78 _gmx_sel_find_symbol(gmx_sel_symtab_t *tab, const char *name, bool bExact);
79 /** Finds a symbol by name. */
80 gmx_sel_symrec_t *
81 _gmx_sel_find_symbol_len(gmx_sel_symtab_t *tab, const char *name, size_t len,
82 bool bExact);
83 /** Returns the first symbol of a given type. */
84 gmx_sel_symrec_t *
85 _gmx_sel_first_symbol(gmx_sel_symtab_t *tab, e_symbol_t type);
86 /** Returns the next symbol of a given type. */
87 gmx_sel_symrec_t *
88 _gmx_sel_next_symbol(gmx_sel_symrec_t *after, e_symbol_t type);
89 /** Adds a new variable symbol. */
90 gmx_sel_symrec_t *
91 _gmx_sel_add_var_symbol(gmx_sel_symtab_t *tab, const char *name,
92 struct t_selelem *sel);
93 /** Adds a new method symbol. */
94 gmx_sel_symrec_t *
95 _gmx_sel_add_method_symbol(gmx_sel_symtab_t *tab, const char *name,
96 struct gmx_ana_selmethod_t *method);
98 #endif