Added a sfree_guard for exception safety.

Added a helper class for calling sfree() on scope exit.  This is useful
for exception safety in code that calls old C functions, as well as in
piecewise conversion of old code to use exceptions.

Change-Id: Ie31483734b66895ad8148eff3db0300ae28b38b4
Remove most uses of t_selelem::refcount.

This is a prerequisite for using smart pointers to manage the selection
evaluation tree, as it's difficult to keep a similar reference count
up-to-date and (or use pointer reference counts for the purposes it is
currently used for).

Related to #655 and #880.

Change-Id: I9e6ae98067f8fe96d39aea6df076e2675ecb8a1f
Use smart pointers to manage the selection tree.

Changed t_selelem to gmx::SelectionTreeElement and t_selelem * to
gmx::SelectionTreeElementPointer (or a const reference).  The latter is
a boost::shared_ptr because there may be multiple references to some
elements in the evaluation tree.  Some exceptions to the above rule are
present, because it was not straightforward to change those parts.

Prerequisite for using exceptions throughout the selection code, which
in turn is a prerequisite for many tasks that would introduce more C++
there.

There are some parts that are not yet exception-safe, but may throw
std::bad_alloc as the result of these changes.  Will fix those in
subsequent commits.

Related to #655 and #880.

Change-Id: Ib36c08bac1ab2c9818604e45e2eb14a90069efdb
Moved selection parser helpers into separate file.

Makes parser.y much more streamlined, as there is now nearly only Bison
declarations and the actual semantic actions.  Also, editing the helpers
no longer requires regenerating the parser (which most likely also
changes the line numbers in parser.cpp, which is typically the largest
part of such changes).

Change-Id: I60e76b95725fb9f647f3cddf64773b3f94185b06
Rationalize selection element name handling.

The name of SelectionTreeElement is now a plain std::string that manages
its own memory instead of pointing to memory managed somewhere else.
The original design has been a pain to maintain at times, as the memory
for the name easily gets freed, leaving a dangling pointer.

Change-Id: I7b975c67ce9eee7f981128e29d8d9dd75fc70c89
C++ classes for selection parser symbol table.

Convert the implementation of selection parser symbol table to use C++
classes.
 - Removes a few exception safety issues that were present in the
   initialization, as well as direct prints to stderr.
 - Documentation now follows the new Doxygen layout.
 - Removes some underscore-prefixed global names.

Related to #655 and #880.

Change-Id: Iecb690fa2e413c9dc487aacffac62a248ea3867a
C++ classes for selection parser parameters.

Converted t_selexpr_param to gmx::SelectionParserParameter and
introduced smart pointers and standard containers to manage all memory
related to these objects.  Solves several exception safety issues in the
selection parser.

Related to #655 and #880.

Change-Id: Ia4c477f1313b49cd1da3b0407bec6e7a1a8b9296
C++ classes for selection parser values.

Converted t_selexpr_value to gmx::SelectionParserValue and introduced
smart pointers and standard containers to manage all memory related to
these objects.

Related to #655 and #880.

Change-Id: Ide2d9db80e89f36c94dccc25085d49959e4115a8
Handle SelectionParserParameter as a value type.

Now that SelectionParserValue is also a C++ object, it is
straightforward to treat SelectionParserParameter as a (movable, but not
copyable) value type instead of storing it through a smart pointer in a
container.  Leads to more consistent and less complex code.

Related to #655 and #880.

Change-Id: I377bac05b1bd990ad95b38887f0f7b825bf0a805
Fix internal error with selection "resname help".

- Always recognize "help" as a help request token, which then causes a
  syntax error in invalid context instead of an internal error in the
  tokenizer symbol table lookup.
- Change the internal error in question to use an exception for error
  reporting to make it possible to easily check it in a unit test.

Change-Id: I4a4057840b47a818cc840654945e84ec536e35b0
Remove remaining GMX_ERROR uses.

Replaced those still left in selection parsing code by exceptions or
assertions.

Related to #655 and #880.

Change-Id: I89bff0c03eb15176e699529888aaae532f0c4138
Add syntax to force selection string matching mode.

The selection syntax for string keyword matching no longer depends on
whether regular expression support is available.  Instead, an error is
now given if the string looks like a regexp (the logic for the deduction
is not changed), but regexp support is not available.  Added syntax to
force the string matching to use either literal, wildcard, or regexp
matching.

This change allows removing a few more direct prints to stderr (related
to #655).

Closes #938.

Change-Id: I7b998050c8b00b5f1229ed23a0a15685c514010f
Enable C++ use in selection methods.

The method that frees the internal data structure for a selection method
now also has the responsibility of freeing the data structure itself.
This makes it possible to allocate the data structure using operator new
in the initialization function, and then correctly free it.

Prerequisite for using C++ types in selection methods before #652 is
implemented.

Change-Id: I99e5a907cbdc4975d20becb0fb1d33e0026c135c
Fix SelectionParserParameter move constructor problem.

C++11 only declares move constructors implicitly if a class does not
have a user-defined destructor.

Change-Id: I3c12b0e93920c102d77bb436c417ceef90a9c6c6
More generic way to obtain OptionInfo for options.

Options::addOption() now returns a pointer to the OptionInfo object that
corresponds to the created option.  This provides a nicer and more
generic way compared to SelectionOption::getAdjuster(), and hopefully
makes it easier for static analysis and compilers to understand that the
info object always gets initialized to a non-NULL value.

Since this change requires the declaration of the corresponding info
object to be available whenever addOption() is called, one could also
get rid of the separate *optioninfo.h headers and merge them to the
corresponding *option.h headers.  This would reduce the number of files
for one option type, and possibly make it a bit easier to maintain.
Didn't do that in this change to keep it more clear.

Change-Id: I143592ed3a0750d3908c6bc8897179d9059ea546
Remove obsolete .gitignore entries.

Now that binaries are built under bin/ and libraries under lib/, most
.gitignore files are unnecessary (and they didn't work previously that
well, either).

Change-Id: Id438f45e896a0d0018c80feafc32242067248855
Reorganize CommandLineHelpWriter implementation.

Instead of separate classes to write out descriptions and different
types of options, there is now three main local classes:
 - OptionsFilter: has output format independent logic to do the
   filterting that was previously implemented in each class separately.
 - OptionsFormatterInterface: interface that OptionsFilter uses to do
   output format specific formatting for the options.
 - OptionsConsoleFormatter: implements the above interface to produce
   the console help that was previously done by the separate classes.

Prerequisite for #969 independent of the chosen solution.
May need additional work as part of that issue.

Change-Id: Ica506f3567b4527f210c48c1b43069d4b64007ec
Allow 'atomname' and 'atomtype' in selections.

'atomname' is now synonymous to 'name', and similarly for 'atomtype' and
'type'.  This reduces confusion, as the code uses atomname and atomtype
internally.  Also use the aliases in tests.

Change-Id: Ifa96840c1fc9c519be53b1bb5aae4f4910cdb0ff
Merge "Fix SelectionParserParameter move constructor problem."
Merge "Reorganize CommandLineHelpWriter implementation."