}
/*!
+ * \param[in] fp Where to print the output.
* \param[in] g Index groups to print.
* \param[in] maxn Maximum number of indices to print
* (-1 = print all, 0 = print only names).
*/
void
-gmx_ana_indexgrps_print(gmx_ana_indexgrps_t *g, int maxn)
+gmx_ana_indexgrps_print(FILE *fp, gmx_ana_indexgrps_t *g, int maxn)
{
int i;
for (i = 0; i < g->nr; ++i)
{
- fprintf(stderr, " %2d: ", i);
- gmx_ana_index_dump(&g->g[i], i, maxn);
+ fprintf(fp, " %2d: ", i);
+ gmx_ana_index_dump(fp, &g->g[i], i, maxn);
}
}
}
/*!
+ * \param[in] fp Where to print the output.
* \param[in] g Index group to print.
* \param[in] i Group number to use if the name is NULL.
* \param[in] maxn Maximum number of indices to print (-1 = print all).
*/
void
-gmx_ana_index_dump(gmx_ana_index_t *g, int i, int maxn)
+gmx_ana_index_dump(FILE *fp, gmx_ana_index_t *g, int i, int maxn)
{
int j, n;
if (g->name)
{
- fprintf(stderr, "\"%s\"", g->name);
+ fprintf(fp, "\"%s\"", g->name);
}
else
{
- fprintf(stderr, "Group %d", i+1);
+ fprintf(fp, "Group %d", i+1);
}
- fprintf(stderr, " (%d atoms)", g->isize);
+ fprintf(fp, " (%d atoms)", g->isize);
if (maxn != 0)
{
- fprintf(stderr, ":");
+ fprintf(fp, ":");
n = g->isize;
if (maxn >= 0 && n > maxn)
{
}
for (j = 0; j < n; ++j)
{
- fprintf(stderr, " %d", g->index[j]+1);
+ fprintf(fp, " %d", g->index[j]+1);
}
if (n < g->isize)
{
- fprintf(stderr, " ...");
+ fprintf(fp, " ...");
}
}
- fprintf(stderr, "\n");
+ fprintf(fp, "\n");
}
/*!
/** Writes out a list of index groups. */
void
-gmx_ana_indexgrps_print(gmx_ana_indexgrps_t *g, int maxn);
+gmx_ana_indexgrps_print(FILE *fp, gmx_ana_indexgrps_t *g, int maxn);
/*@}*/
/*! \name Functions for handling gmx_ana_index_t
/** Writes out the contents of a index group. */
void
-gmx_ana_index_dump(gmx_ana_index_t *g, int i, int maxn);
+gmx_ana_index_dump(FILE *fp, gmx_ana_index_t *g, int i, int maxn);
/** Checks whether all indices are between 0 and \p natoms. */
void
if (grps)
{
fprintf(stderr, "Available index groups:\n");
- gmx_ana_indexgrps_print(_gmx_sel_lexer_indexgrps(scanner), 0);
+ gmx_ana_indexgrps_print(stderr, _gmx_sel_lexer_indexgrps(scanner), 0);
}
if (sc->nvars > 0 || !sc->sel.empty())
{
{
gmx_ana_selcollection_t *sc = _gmx_sel_lexer_selcollection(scanner);
- _gmx_sel_print_help(sc->symtab, topic);
+ _gmx_sel_print_help(stderr, sc->symtab, topic);
if (topic)
{
sfree(topic);
void
-Selection::printInfo() const
+Selection::printInfo(FILE *fp) const
{
- fprintf(stderr, "\"%s\" (%d position%s, %d atom%s%s)", _sel.name,
+ fprintf(fp, "\"%s\" (%d position%s, %d atom%s%s)", _sel.name,
_sel.p.nr, _sel.p.nr == 1 ? "" : "s",
_sel.g->isize, _sel.g->isize == 1 ? "" : "s",
_sel.bDynamic ? ", dynamic" : "");
- fprintf(stderr, "\n");
+ fprintf(fp, "\n");
}
void
-Selection::printDebugInfo(int nmaxind) const
+Selection::printDebugInfo(FILE *fp, int nmaxind) const
{
- fprintf(stderr, " ");
- printInfo();
- fprintf(stderr, " ");
- gmx_ana_index_dump(_sel.g, -1, nmaxind);
+ fprintf(fp, " ");
+ printInfo(fp);
+ fprintf(fp, " ");
+ gmx_ana_index_dump(fp, _sel.g, -1, nmaxind);
- fprintf(stderr, " Block (size=%d):", _sel.p.m.mapb.nr);
+ fprintf(fp, " Block (size=%d):", _sel.p.m.mapb.nr);
if (!_sel.p.m.mapb.index)
{
- fprintf(stderr, " (null)");
+ fprintf(fp, " (null)");
}
else
{
if (nmaxind >= 0 && n > nmaxind)
n = nmaxind;
for (int i = 0; i <= n; ++i)
- fprintf(stderr, " %d", _sel.p.m.mapb.index[i]);
+ fprintf(fp, " %d", _sel.p.m.mapb.index[i]);
if (n < _sel.p.m.mapb.nr)
- fprintf(stderr, " ...");
+ fprintf(fp, " ...");
}
- fprintf(stderr, "\n");
+ fprintf(fp, "\n");
int n = _sel.p.m.nr;
if (nmaxind >= 0 && n > nmaxind)
n = nmaxind;
- fprintf(stderr, " RefId:");
+ fprintf(fp, " RefId:");
if (!_sel.p.m.refid)
{
- fprintf(stderr, " (null)");
+ fprintf(fp, " (null)");
}
else
{
for (int i = 0; i < n; ++i)
- fprintf(stderr, " %d", _sel.p.m.refid[i]);
+ fprintf(fp, " %d", _sel.p.m.refid[i]);
if (n < _sel.p.m.nr)
- fprintf(stderr, " ...");
+ fprintf(fp, " ...");
}
- fprintf(stderr, "\n");
+ fprintf(fp, "\n");
- fprintf(stderr, " MapId:");
+ fprintf(fp, " MapId:");
if (!_sel.p.m.mapid)
{
- fprintf(stderr, " (null)");
+ fprintf(fp, " (null)");
}
else
{
for (int i = 0; i < n; ++i)
- fprintf(stderr, " %d", _sel.p.m.mapid[i]);
+ fprintf(fp, " %d", _sel.p.m.mapid[i]);
if (n < _sel.p.m.nr)
- fprintf(stderr, " ...");
+ fprintf(fp, " ...");
}
- fprintf(stderr, "\n");
+ fprintf(fp, "\n");
}
} // namespace gmx
*/
bool initCoveredFraction(e_coverfrac_t type);
- //! Prints out one-line description of the selection.
- void printInfo() const;
+ /*! \brief
+ * Prints out one-line description of the selection.
+ *
+ * \param[in] fp Where to print the information.
+ */
+ void printInfo(FILE *fp) const;
/*! \brief
* Prints out extended information about the selection for debugging.
*
+ * \param[in] fp Where to print the information.
* \param[in] nmaxind Maximum number of values to print in lists
* (-1 = print all).
*/
- void printDebugInfo(int nmaxind) const;
+ void printDebugInfo(FILE *fp, int nmaxind) const;
gmx_ana_selection_t _sel;
/*! \brief
* Prints a brief list of keywords (selection methods) available.
*
+ * \param[in] fp Where to write the list.
* \param[in] symtab Symbol table to use to find available keywords.
* \param[in] type Only methods that return this type are printed.
* \param[in] bMod If FALSE, \ref SMETH_MODIFIER methods are excluded, otherwise
* only them are printed.
*/
static void
-print_keyword_list(gmx_sel_symtab_t *symtab, e_selvalue_t type,
+print_keyword_list(FILE *fp, gmx_sel_symtab_t *symtab, e_selvalue_t type,
gmx_bool bMod)
{
gmx_sel_symrec_t *symbol;
|| (!bMod && !(method->flags & SMETH_MODIFIER)));
if (bShow)
{
- fprintf(stderr, " %c ",
+ fprintf(fp, " %c ",
(method->help.nlhelp > 0 && method->help.help) ? '*' : ' ');
if (method->help.syntax)
{
- fprintf(stderr, "%s\n", method->help.syntax);
+ fprintf(fp, "%s\n", method->help.syntax);
}
else
{
const char *symname = _gmx_sel_sym_name(symbol);
- fprintf(stderr, "%s", symname);
+ fprintf(fp, "%s", symname);
if (strcmp(symname, method->name) != 0)
{
- fprintf(stderr, " (synonym for %s)", method->name);
+ fprintf(fp, " (synonym for %s)", method->name);
}
- fprintf(stderr, "\n");
+ fprintf(fp, "\n");
}
}
symbol = _gmx_sel_next_symbol(symbol, SYMBOL_METHOD);
}
/*!
- * \param[in] symtab Symbol table to use to find available keywords.
+ * \param[in] fp Where to write the help.
+ * \param[in] symtab Symbol table to use to find available keywords.
* \param[in] topic Topic to print help on, or NULL for general help.
*
- * \p sc is used to get information on which keywords are available in the
+ * \p symtab is used to get information on which keywords are available in the
* present context.
*/
void
-_gmx_sel_print_help(gmx_sel_symtab_t *symtab, const char *topic)
+_gmx_sel_print_help(FILE *fp, gmx_sel_symtab_t *symtab, const char *topic)
{
const t_selection_help_item *item = NULL;
size_t i;
for (i = 0; i < asize(helpitems); ++i)
{
item = &helpitems[i];
- _gmx_sel_print_help(symtab, item->topic);
+ _gmx_sel_print_help(fp, symtab, item->topic);
if (i != asize(helpitems) - 1)
{
- fprintf(stderr, "\n\n");
+ fprintf(fp, "\n\n");
}
}
return;
if (method->help.nlhelp > 0 && method->help.help
&& strncmp(method->name, topic, strlen(topic)) == 0)
{
- print_tty_formatted(stderr, method->help.nlhelp,
+ print_tty_formatted(fp, method->help.nlhelp,
method->help.help, 0, NULL, NULL, FALSE);
return;
}
symbol = _gmx_sel_next_symbol(symbol, SYMBOL_METHOD);
}
- fprintf(stderr, "No help available for '%s'.\n", topic);
+ fprintf(fp, "No help available for '%s'.\n", topic);
return;
}
/* Print the help */
- print_tty_formatted(stderr, item->nl, item->text, 0, NULL, NULL, FALSE);
+ print_tty_formatted(fp, item->nl, item->text, 0, NULL, NULL, FALSE);
/* Special handling of certain pages */
if (!topic)
{
int len = 0;
/* Print the subtopics on the main page */
- fprintf(stderr, "\nAvailable subtopics:\n");
+ fprintf(fp, "\nAvailable subtopics:\n");
for (i = 1; i < asize(helpitems); ++i)
{
int len1 = strlen(helpitems[i].topic) + 2;
len += len1;
if (len > 79)
{
- fprintf(stderr, "\n");
+ fprintf(fp, "\n");
len = len1;
}
- fprintf(stderr, " %s", helpitems[i].topic);
+ fprintf(fp, " %s", helpitems[i].topic);
}
- fprintf(stderr, "\n");
+ fprintf(fp, "\n");
}
else if (strcmp(item->topic, "keywords") == 0)
{
/* Print the list of keywords */
- fprintf(stderr, "\nKeywords that select atoms by an integer property:\n");
- fprintf(stderr, "(use in expressions or like \"atomnr 1 to 5 7 9\")\n");
- print_keyword_list(symtab, INT_VALUE, FALSE);
+ fprintf(fp, "\nKeywords that select atoms by an integer property:\n");
+ fprintf(fp, "(use in expressions or like \"atomnr 1 to 5 7 9\")\n");
+ print_keyword_list(fp, symtab, INT_VALUE, FALSE);
- fprintf(stderr, "\nKeywords that select atoms by a numeric property:\n");
- fprintf(stderr, "(use in expressions or like \"occupancy 0.5 to 1\")\n");
- print_keyword_list(symtab, REAL_VALUE, FALSE);
+ fprintf(fp, "\nKeywords that select atoms by a numeric property:\n");
+ fprintf(fp, "(use in expressions or like \"occupancy 0.5 to 1\")\n");
+ print_keyword_list(fp, symtab, REAL_VALUE, FALSE);
- fprintf(stderr, "\nKeywords that select atoms by a string property:\n");
- fprintf(stderr, "(use like \"name PATTERN [PATTERN] ...\")\n");
- print_keyword_list(symtab, STR_VALUE, FALSE);
+ fprintf(fp, "\nKeywords that select atoms by a string property:\n");
+ fprintf(fp, "(use like \"name PATTERN [PATTERN] ...\")\n");
+ print_keyword_list(fp, symtab, STR_VALUE, FALSE);
- fprintf(stderr, "\nAdditional keywords that directly select atoms:\n");
- print_keyword_list(symtab, GROUP_VALUE, FALSE);
+ fprintf(fp, "\nAdditional keywords that directly select atoms:\n");
+ print_keyword_list(fp, symtab, GROUP_VALUE, FALSE);
- fprintf(stderr, "\nKeywords that directly evaluate to positions:\n");
- fprintf(stderr, "(see also \"help positions\")\n");
- print_keyword_list(symtab, POS_VALUE, FALSE);
+ fprintf(fp, "\nKeywords that directly evaluate to positions:\n");
+ fprintf(fp, "(see also \"help positions\")\n");
+ print_keyword_list(fp, symtab, POS_VALUE, FALSE);
- fprintf(stderr, "\nAdditional keywords:\n");
- print_keyword_list(symtab, POS_VALUE, TRUE);
- print_keyword_list(symtab, NO_VALUE, TRUE);
+ fprintf(fp, "\nAdditional keywords:\n");
+ print_keyword_list(fp, symtab, POS_VALUE, TRUE);
+ print_keyword_list(fp, symtab, NO_VALUE, TRUE);
}
}
#ifndef GMX_SELECTION_HELP_H
#define GMX_SELECTION_HELP_H
+#include <stdio.h>
+
struct gmx_sel_symtab_t;
/** Prints help for writing selections. */
void
-_gmx_sel_print_help(struct gmx_sel_symtab_t *symtab, const char *topic);
+_gmx_sel_print_help(FILE *fp, struct gmx_sel_symtab_t *symtab, const char *topic);
#endif
fprintf(stderr, "\nSelections:\n");
for (size_t g = 0; g < _selections.size(); ++g)
{
- _selections[g]->printDebugInfo(_nmaxind);
+ _selections[g]->printDebugInfo(stderr, _nmaxind);
}
fprintf(stderr, "\n");
}
{
const Selection *sel = _selections[g];
- gmx_ana_index_dump(sel->indexGroup(), g, _nmaxind);
+ gmx_ana_index_dump(stderr, sel->indexGroup(), g, _nmaxind);
fprintf(stderr, " Positions (%d pcs):\n", sel->posCount());
n = sel->posCount();
if (_nmaxind >= 0 && n > _nmaxind)