Sort includes outside src/gromacs
[alexxy/gromacs.git] / src / testutils / cmdlinetest.cpp
index d098f3f7603ac934cfdbc9ebd15d284dbd698ebb..5192ee7853a65e73500bd562c7a916f6cd08da22 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2012,2013, by the GROMACS development team, led by
+ * Copyright (c) 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.
  * \author Teemu Murtola <teemu.murtola@gmail.com>
  * \ingroup module_testutils
  */
+#include "gmxpre.h"
+
 #include "cmdlinetest.h"
 
 #include <cstdlib>
 #include <cstring>
-#include <sstream>
 
 #include <new>
+#include <sstream>
 #include <vector>
 
+#include "gromacs/commandline/cmdlineprogramcontext.h"
+#include "gromacs/utility/arrayref.h"
 #include "gromacs/utility/gmxassert.h"
-#include "gromacs/utility/programinfo.h"
 
 namespace gmx
 {
@@ -106,8 +109,8 @@ CommandLine::CommandLine()
 {
 }
 
-CommandLine::CommandLine(const char *const cmdline[], size_t count)
-    : impl_(new Impl(cmdline, count))
+CommandLine::CommandLine(const ConstArrayRef<const char *> &cmdline)
+    : impl_(new Impl(cmdline.data(), cmdline.size()))
 {
 }
 
@@ -120,6 +123,11 @@ CommandLine::~CommandLine()
 {
 }
 
+void CommandLine::initFromArray(const ConstArrayRef<const char *> &cmdline)
+{
+    impl_.reset(new Impl(cmdline.data(), cmdline.size()));
+}
+
 void CommandLine::append(const char *arg)
 {
     GMX_RELEASE_ASSERT(impl_->argc_ == static_cast<int>(impl_->args_.size()),
@@ -203,7 +211,7 @@ const char *CommandLine::arg(int i) const
 
 std::string CommandLine::toString() const
 {
-    return ProgramInfo(argc(), argv()).commandLine();
+    return CommandLineProgramContext(argc(), argv()).commandLine();
 }
 
 } // namespace test