Gromacs  2025-dev-20240913-b871546
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
gmx::anonymous_namespace{selectioncollection.cpp} Namespace Reference

Functions

bool promptLine (TextInputStream *inputStream, TextWriter *statusWriter, std::string *line)
 Reads a single selection line from stdin. More...
 
int runParserLoop (yyscan_t scanner, _gmx_sel_yypstate *parserState, bool bInteractive)
 Helper function for tokenizing the input and pushing them to the parser. More...
 
void printCurrentStatus (TextWriter *writer, gmx_ana_selcollection_t *sc, gmx_ana_indexgrps_t *grps, size_t firstSelection, int maxCount, const std::string &context, bool bFirst)
 Print current status in response to empty line in interactive input. More...
 
void printHelp (TextWriter *writer, gmx_ana_selcollection_t *sc, const std::string &line)
 Prints selection help in interactive selection input. More...
 
SelectionList runParser (yyscan_t scanner, TextInputStream *inputStream, bool bInteractive, int maxnr, const std::string &context)
 Helper function that runs the parser once the tokenizer has been initialized. More...
 
void checkExternalGroups (const SelectionTreeElementPointer &root, int natoms, ExceptionInitializer *errors)
 Checks that index groups have valid atom indices. More...
 
void checkTopologyProperties (const gmx_mtop_t *top, const SelectionTopologyProperties &props)
 Checks whether the given topology properties are available.
 
std::unique_ptr< TextWriterinitStatusWriter (TextOutputStream *statusStream)
 Helper function to initialize status writer for interactive selection parsing.
 

Function Documentation

void gmx::anonymous_namespace{selectioncollection.cpp}::checkExternalGroups ( const SelectionTreeElementPointer &  root,
int  natoms,
ExceptionInitializer *  errors 
)

Checks that index groups have valid atom indices.

Parameters
[in]rootRoot of selection tree to process.
[in]natomsMaximum number of atoms that the selections are set to evaluate.
errorsObject for reporting any error messages.
Exceptions
std::bad_allocif out of memory.

Recursively checks the selection tree for index groups. Each found group is checked that it only contains atom indices that match the topology/maximum number of atoms set for the selection collection. Any issues are reported to errors.

void gmx::anonymous_namespace{selectioncollection.cpp}::printCurrentStatus ( TextWriter *  writer,
gmx_ana_selcollection_t sc,
gmx_ana_indexgrps_t grps,
size_t  firstSelection,
int  maxCount,
const std::string &  context,
bool  bFirst 
)

Print current status in response to empty line in interactive input.

Parameters
[in]writerWriter to use for the output.
[in]scSelection collection data structure.
[in]grpsAvailable index groups.
[in]firstSelectionIndex of first selection from this interactive session.
[in]maxCountMaximum number of selections.
[in]contextContext to print for what the selections are for.
[in]bFirstWhether this is the header that is printed before any user input.

Prints the available index groups and currently provided selections.

void gmx::anonymous_namespace{selectioncollection.cpp}::printHelp ( TextWriter *  writer,
gmx_ana_selcollection_t sc,
const std::string &  line 
)

Prints selection help in interactive selection input.

Parameters
[in]writerWriter to use for the output.
[in]scSelection collection data structure.
[in]lineLine of user input requesting help (starting with help).

Initializes the selection help if not yet initialized, and finds the help topic based on words on the input line.

bool gmx::anonymous_namespace{selectioncollection.cpp}::promptLine ( TextInputStream *  inputStream,
TextWriter *  statusWriter,
std::string *  line 
)

Reads a single selection line from stdin.

Parameters
[in]inputStreamStream to read from (typically the StandardInputStream).
[in]statusWriterStream to print prompts to (if NULL, no output is done).
[out]lineThe read line in stored here.
Returns
true if something was read, false if at end of input.

Handles line continuation, reading also the continuing line(s) in one call.

SelectionList gmx::anonymous_namespace{selectioncollection.cpp}::runParser ( yyscan_t  scanner,
TextInputStream *  inputStream,
bool  bInteractive,
int  maxnr,
const std::string &  context 
)

Helper function that runs the parser once the tokenizer has been initialized.

Parameters
[in,out]scannerScanner data structure.
[in]inputStreamStream to use for input (currently only with bInteractive==true).
[in]bInteractiveWhether to use a line-based reading algorithm designed for interactive input.
[in]maxnrMaximum number of selections to parse (if -1, parse as many as provided by the user).
[in]contextContext to print for what the selections are for.
Returns
Vector of parsed selections.
Exceptions
std::bad_allocif out of memory.
InvalidInputErrorif there is a parsing error.

Used internally to implement parseInteractive(), parseFromFile() and parseFromString().

int gmx::anonymous_namespace{selectioncollection.cpp}::runParserLoop ( yyscan_t  scanner,
_gmx_sel_yypstate *  parserState,
bool  bInteractive 
)

Helper function for tokenizing the input and pushing them to the parser.

Parameters
scannerTokenizer data structure.
parserStateParser data structure.
[in]bInteractiveWhether to operate in interactive mode.

Repeatedly reads tokens using scanner and pushes them to the parser with parserState until there is no more input, or until enough input is given (only in interactive mode).