Sort all includes in src/gromacs
[alexxy/gromacs.git] / src / gromacs / options / optionsassigner.cpp
index 3c297c7f70e1edff7f131f26d41c575e23505c3a..df3f1320d89da7ddb54996b610e7c5885d30a614 100644 (file)
@@ -1,10 +1,10 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2010,2011,2012, by the GROMACS development team, led by
- * David van der Spoel, Berk Hess, Erik Lindahl, and including many
- * others, as listed in the AUTHORS file in the top-level source
- * directory and at http://www.gromacs.org.
+ * Copyright (c) 2010,2011,2012,2013,2014, by the GROMACS development team, led by
+ * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+ * and including many others, as listed in the AUTHORS file in the
+ * top-level source directory and at http://www.gromacs.org.
  *
  * GROMACS is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -39,7 +39,9 @@
  * \author Teemu Murtola <teemu.murtola@gmail.com>
  * \ingroup module_options
  */
-#include "gromacs/options/optionsassigner.h"
+#include "gmxpre.h"
+
+#include "optionsassigner.h"
 
 #include <deque>
 
@@ -229,16 +231,25 @@ void OptionsAssigner::startSubSection(const char *name)
 }
 
 void OptionsAssigner::startOption(const char *name)
+{
+    if (!tryStartOption(name))
+    {
+        GMX_THROW(InvalidInputError("Unknown option " + std::string(name)));
+    }
+}
+
+bool OptionsAssigner::tryStartOption(const char *name)
 {
     GMX_RELEASE_ASSERT(impl_->currentOption_ == NULL, "finishOption() not called");
     AbstractOptionStorage *option = impl_->findOption(name);
     if (option == NULL)
     {
-        GMX_THROW(InvalidInputError("Unknown option"));
+        return false;
     }
     option->startSet();
     impl_->currentOption_     = option;
     impl_->currentValueCount_ = 0;
+    return true;
 }
 
 void OptionsAssigner::appendValue(const std::string &value)