Rename gmx Variant to Any
authorRoland Schulz <roland.schulz@intel.com>
Mon, 21 Jan 2019 19:15:38 +0000 (11:15 -0800)
committerMark Abraham <mark.j.abraham@gmail.com>
Wed, 23 Jan 2019 14:15:15 +0000 (15:15 +0100)
Aligns much better with the C++17 naming given that gmx::Any has
similar functionality as std::any and is different from std::variant.

Change-Id: Id81f402c91197a62ce8ae6212b863aabd9952f6f

24 files changed:
src/gromacs/options/abstractoption.cpp
src/gromacs/options/abstractoption.h
src/gromacs/options/abstractoptionstorage.h
src/gromacs/options/basicoptions.cpp
src/gromacs/options/basicoptionstorage.h
src/gromacs/options/optionsassigner.cpp
src/gromacs/options/optionsassigner.h
src/gromacs/options/optionstoragetemplate.h
src/gromacs/options/tests/abstractoptionstorage.cpp
src/gromacs/options/tests/optionsassigner.cpp
src/gromacs/options/treesupport.cpp
src/gromacs/options/valueconverter.h
src/gromacs/selection/selectionfileoptionstorage.h
src/gromacs/selection/selectionoption.cpp
src/gromacs/selection/selectionoptionstorage.h
src/gromacs/utility/any.cpp [moved from src/gromacs/utility/variant.cpp with 93% similarity]
src/gromacs/utility/any.h [moved from src/gromacs/utility/variant.h with 81% similarity]
src/gromacs/utility/keyvaluetree.h
src/gromacs/utility/keyvaluetreebuilder.h
src/gromacs/utility/keyvaluetreetransform.cpp
src/gromacs/utility/keyvaluetreetransform.h
src/testutils/refdata.cpp
src/testutils/refdata.h
src/testutils/tests/refdata_tests.cpp

index 6b8c75bfec264ee6b73c54c114b8c321746531f3..c8d77e18a9182d932a91b6280080024c5d271d1c 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2010,2011,2012,2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,2013,2014,2015,2016,2017,2019, 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.
@@ -45,9 +45,9 @@
 
 #include "gromacs/options/abstractoptionstorage.h"
 #include "gromacs/options/optionflags.h"
+#include "gromacs/utility/any.h"
 #include "gromacs/utility/exceptions.h"
 #include "gromacs/utility/gmxassert.h"
-#include "gromacs/utility/variant.h"
 
 #include "basicoptionstorage.h"
 
@@ -117,7 +117,7 @@ void AbstractOptionStorage::startSet()
     bSetValuesHadErrors_ = false;
 }
 
-void AbstractOptionStorage::appendValue(const Variant &value)
+void AbstractOptionStorage::appendValue(const Any &value)
 {
     GMX_RELEASE_ASSERT(bInSet_, "startSet() not called");
     try
@@ -261,7 +261,7 @@ std::string OptionInfo::formatDescription() const
     return description;
 }
 
-std::vector<Variant> OptionInfo::defaultValues() const
+std::vector<Any> OptionInfo::defaultValues() const
 {
     return option().defaultValues();
 }
@@ -271,7 +271,7 @@ std::vector<std::string> OptionInfo::defaultValuesAsStrings() const
     return option().defaultValuesAsStrings();
 }
 
-std::vector<Variant> OptionInfo::normalizeValues(const std::vector<Variant> &values) const
+std::vector<Any> OptionInfo::normalizeValues(const std::vector<Any> &values) const
 {
     return option().normalizeValues(values);
 }
index 575cd6efaddffba760057f6e1ef5f8fff885bfb4..5bc34cac5db6202934d66fdcd5506ac301dc5f29 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2010,2011,2012,2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,2013,2014,2015,2016,2017,2019, 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.
@@ -66,7 +66,7 @@ namespace gmx
 class AbstractOptionStorage;
 template <typename T> class OptionStorageTemplate;
 class OptionManagerContainer;
-class Variant;
+class Any;
 
 namespace internal
 {
@@ -491,12 +491,12 @@ class OptionInfo
          * Returns the default value(s) of the option.
          *
          * The returned values should all be of the same type, but returning
-         * each as a separate variant is currently simpler.
+         * each as a separate any is currently simpler.
          *
          * Currently, this can only be called before option values have been
          * assigned.
          */
-        std::vector<Variant> defaultValues() const;
+        std::vector<Any> defaultValues() const;
         /*! \brief
          * Returns the default value(s) of the option as strings.
          *
@@ -517,7 +517,7 @@ class OptionInfo
          * value of the option, and the current value in the option is not
          * changed.
          */
-        std::vector<Variant> normalizeValues(const std::vector<Variant> &values) const;
+        std::vector<Any> normalizeValues(const std::vector<Any> &values) const;
 
     protected:
         /*! \cond libapi */
index dd4e2eae764d2a4413f70d05794026bd2ec8724f..7a266bd4513423cb245a5fbb92f1cd4d64b34d32 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2010,2011,2012,2014,2015,2016, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,2014,2015,2016,2019, 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.
@@ -55,7 +55,7 @@ namespace gmx
 class AbstractOption;
 class OptionInfo;
 class Options;
-class Variant;
+class Any;
 
 /*! \libinternal \brief
  * Abstract base class for converting, validating, and storing option values.
@@ -140,11 +140,11 @@ class AbstractOptionStorage
          */
         virtual int valueCount() const = 0;
         //! \copydoc OptionInfo::defaultValues()
-        virtual std::vector<Variant> defaultValues() const = 0;
+        virtual std::vector<Any> defaultValues() const = 0;
         //! \copydoc OptionInfo::defaultValuesAsStrings()
         virtual std::vector<std::string> defaultValuesAsStrings() const = 0;
         //! \copydoc OptionInfo::normalizeValues()
-        virtual std::vector<Variant> normalizeValues(const std::vector<Variant> &values) const = 0;
+        virtual std::vector<Any> normalizeValues(const std::vector<Any> &values) const = 0;
 
         /*! \brief
          * Starts adding values from a new source for the option.
@@ -178,7 +178,7 @@ class AbstractOptionStorage
          * This method should only be called between startSet() and
          * finishSet().
          */
-        void appendValue(const Variant &value);
+        void appendValue(const Any &value);
         /*! \brief
          * Performs validation and/or actions once a set of values has been
          * added.
@@ -276,7 +276,7 @@ class AbstractOptionStorage
          *
          * \see OptionStorageTemplate::convertValue()
          */
-        virtual void convertValue(const Variant &value) = 0;
+        virtual void convertValue(const Any &value) = 0;
         /*! \brief
          * Performs validation and/or actions once a set of values has been
          * added.
index fa33e4f1e73abc80ce859bd6d278a2bae15e66fc..57bd2106f9c0206ee2e5dc6e273a50e5fd2cd980 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2010,2011,2012,2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,2013,2014,2015,2016,2017,2018,2019, 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.
@@ -610,9 +610,9 @@ std::string EnumOptionStorage::formatSingleValue(const int &value) const
     return allowed_[value];
 }
 
-Variant EnumOptionStorage::normalizeValue(const int &value) const
+Any EnumOptionStorage::normalizeValue(const int &value) const
 {
-    return Variant::create<std::string>(formatSingleValue(value));
+    return Any::create<std::string>(formatSingleValue(value));
 }
 
 void EnumOptionStorage::initConverter(ConverterType *converter)
index 847af90eb7183972d8ac9d262f321660989566ff..b1dfb5781e45a4e6455ae9ba022596646aa4061c 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2010,2011,2012,2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,2013,2014,2015,2016,2017,2018,2019, 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.
@@ -244,7 +244,7 @@ class EnumOptionStorage : public OptionStorageTemplateSimple<int>
         std::string typeString() const override { return "enum"; }
         std::string formatExtraDescription() const override;
         std::string formatSingleValue(const int &value) const override;
-        Variant normalizeValue(const int &value) const override;
+        Any normalizeValue(const int &value) const override;
 
         //! \copydoc EnumOptionInfo::allowedValues()
         const std::vector<std::string> &allowedValues() const { return allowed_; }
index 45cd89a55596a72cb46921893c3053a1f648233d..f9cb896873d49ec42703fbd5f95f9630211f86d8 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2010,2011,2012,2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,2013,2014,2015,2016,2017,2019, 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.
@@ -47,9 +47,9 @@
 
 #include "gromacs/options/abstractoptionstorage.h"
 #include "gromacs/options/options.h"
+#include "gromacs/utility/any.h"
 #include "gromacs/utility/exceptions.h"
 #include "gromacs/utility/gmxassert.h"
-#include "gromacs/utility/variant.h"
 
 #include "options-impl.h"
 
@@ -203,10 +203,10 @@ bool OptionsAssigner::tryStartOption(const char *name)
 
 void OptionsAssigner::appendValue(const std::string &value)
 {
-    appendValue(Variant(value));
+    appendValue(Any(value));
 }
 
-void OptionsAssigner::appendValue(const Variant &value)
+void OptionsAssigner::appendValue(const Any &value)
 {
     AbstractOptionStorage *option = impl_->currentOption_;
     GMX_RELEASE_ASSERT(option != nullptr, "startOption() not called");
@@ -224,7 +224,7 @@ void OptionsAssigner::finishOption()
         if (impl_->currentValueCount_ == 0)
         {
             // Should not throw, otherwise something is wrong.
-            option->appendValue(Variant::create<bool>(!impl_->reverseBoolean_));
+            option->appendValue(Any::create<bool>(!impl_->reverseBoolean_));
         }
         else if (impl_->reverseBoolean_)
         {
index cdefa7258276df7cb263d018d996e6535bbfbaad..a07892fe047ee2959c54cf0b8ca05fa46e04c80f 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2010,2011,2012,2013,2014,2015,2016, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,2013,2014,2015,2016,2019, 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.
@@ -53,7 +53,7 @@ namespace gmx
 {
 
 class Options;
-class Variant;
+class Any;
 
 /*! \libinternal \brief
  * Decorator class for assigning values to Options.
@@ -167,13 +167,13 @@ class OptionsAssigner
          * OptionStorageTemplate::convertValue() method of the storage class
          * implementing the option where the value is assigned to.
          */
-        void appendValue(const Variant &value);
+        void appendValue(const Any &value);
         /*! \brief
          * Appends a value to the value list of the current option.
          *
          * \param[in] value  Value to assign.
          *
-         * See appendValue(const Variant &) for more details.
+         * See appendValue(const Any &) for more details.
          */
         void appendValue(const std::string &value);
         /*! \brief
index 5659fae1201d8b69e175855d7ecac7b7a61b6597..0081912bcf3f9c769f2a985cce0926890d7f5ea3 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2010,2011,2012,2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,2013,2014,2015,2016,2017,2018,2019, 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.
 #include "gromacs/options/abstractoption.h"
 #include "gromacs/options/abstractoptionstorage.h"
 #include "gromacs/options/valuestore.h"
+#include "gromacs/utility/any.h"
 #include "gromacs/utility/arrayref.h"
 #include "gromacs/utility/basedefinitions.h"
 #include "gromacs/utility/exceptions.h"
 #include "gromacs/utility/gmxassert.h"
-#include "gromacs/utility/variant.h"
 
 #include "valueconverter.h"
 
@@ -102,7 +102,7 @@ class OptionStorageTemplate : public AbstractOptionStorage
         //! \copydoc gmx::AbstractOptionStorage::valueCount()
         int valueCount() const override { return store_->valueCount(); }
         //! \copydoc gmx::AbstractOptionStorage::defaultValues()
-        std::vector<Variant> defaultValues() const override;
+        std::vector<Any> defaultValues() const override;
         /*! \copydoc gmx::AbstractOptionStorage::defaultValuesAsStrings()
          *
          * OptionStorageTemplate implements handling of defaultValueIfSet()
@@ -151,7 +151,7 @@ class OptionStorageTemplate : public AbstractOptionStorage
          * should be considered whether the implementation can be made strongly
          * exception safe.
          */
-        void convertValue(const Variant &value) override = 0;
+        void convertValue(const Any &value) override = 0;
         /*! \brief
          * Processes values for a set after all have been converted.
          *
@@ -257,7 +257,7 @@ class OptionStorageTemplate : public AbstractOptionStorage
         /*! \brief
          * Provides derived classes access to the current list of values.
          *
-         * The non-const variant should only be used from processAll() in
+         * The non-const any should only be used from processAll() in
          * derived classes if necessary.
          */
         ArrayRef<T>       values() { return store_->values(); }
@@ -327,11 +327,11 @@ class OptionStorageTemplateSimple : public OptionStorageTemplate<T>
         {
         }
 
-        std::vector<Variant>
-        normalizeValues(const std::vector<Variant> &values) const override
+        std::vector<Any>
+        normalizeValues(const std::vector<Any> &values) const override
         {
             const_cast<MyBase *>(this)->ensureConverterInitialized();
-            std::vector<Variant> result;
+            std::vector<Any> result;
             result.reserve(values.size());
             for (const auto &value : values)
             {
@@ -367,16 +367,16 @@ class OptionStorageTemplateSimple : public OptionStorageTemplate<T>
          * This can be overridden to serialize a different type than `T`
          * when using the option with KeyValueTreeObject.
          */
-        virtual Variant normalizeValue(const T &value) const
+        virtual Any normalizeValue(const T &value) const
         {
-            return Variant::create<T>(processValue(value));
+            return Any::create<T>(processValue(value));
         }
 
     private:
-        void convertValue(const Variant &variant) override
+        void convertValue(const Any &any) override
         {
             ensureConverterInitialized();
-            this->addValue(processValue(converter_.convert(variant)));
+            this->addValue(processValue(converter_.convert(any)));
         }
         void ensureConverterInitialized()
         {
@@ -472,9 +472,9 @@ std::unique_ptr<IOptionValueStore<T> > OptionStorageTemplate<T>::createStore(
 
 
 template <typename T>
-std::vector<Variant> OptionStorageTemplate<T>::defaultValues() const
+std::vector<Any> OptionStorageTemplate<T>::defaultValues() const
 {
-    std::vector<Variant> result;
+    std::vector<Any> result;
     if (hasFlag(efOption_NoDefaultValue))
     {
         return result;
@@ -483,7 +483,7 @@ std::vector<Variant> OptionStorageTemplate<T>::defaultValues() const
                        "Current option implementation can only provide default values before assignment");
     for (const auto &value : values())
     {
-        result.push_back(Variant::create<T>(value));
+        result.push_back(Any::create<T>(value));
     }
     return normalizeValues(result);
 }
index 336075277337d4cbd74b1bda21434db934499c30..de0037b6040d035e6acb4e385ec56ba29f825fd9 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2010,2011,2012,2013,2014,2016,2018, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,2013,2014,2016,2018,2019, 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.
@@ -110,13 +110,13 @@ class MockOptionStorage : public gmx::OptionStorageTemplate<std::string>
         {
             return "";
         }
-        std::vector<gmx::Variant>
-        normalizeValues(const std::vector<gmx::Variant> &values) const override
+        std::vector<gmx::Any>
+        normalizeValues(const std::vector<gmx::Any> &values) const override
         {
             return values;
         }
 
-        void convertValue(const gmx::Variant &value) override
+        void convertValue(const gmx::Any &value) override
         {
             convertValue(value.cast<std::string>());
         }
index e8de95d92fe9ec807e3e76ad0cabec773c512d82..ad1df797612571add31c77e5655a308812900ecf 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2010,2011,2012,2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,2013,2014,2015,2016,2017,2019, 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.
@@ -57,9 +57,9 @@
 #include "gromacs/options/basicoptions.h"
 #include "gromacs/options/options.h"
 #include "gromacs/options/optionsection.h"
+#include "gromacs/utility/any.h"
 #include "gromacs/utility/exceptions.h"
 #include "gromacs/utility/stringutil.h"
-#include "gromacs/utility/variant.h"
 
 #include "testutils/testasserts.h"
 
@@ -654,7 +654,7 @@ TEST(OptionsAssignerDoubleTest, StoresValueFromFloat)
     gmx::OptionsAssigner assigner(&options);
     EXPECT_NO_THROW(assigner.start());
     ASSERT_NO_THROW(assigner.startOption("p"));
-    ASSERT_NO_THROW(assigner.appendValue(gmx::Variant::create<float>(2.7)));
+    ASSERT_NO_THROW(assigner.appendValue(gmx::Any::create<float>(2.7)));
     EXPECT_NO_THROW(assigner.finishOption());
     EXPECT_NO_THROW(assigner.finish());
     EXPECT_NO_THROW(options.finish());
index bacc788d34fa4892bf268da062b522443938c24d..aeb94fbe378fb3a4d598c3aa93412bf50a643a34 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2016,2017,2018,2019, 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.
@@ -104,7 +104,7 @@ class TreeAssignHelper
                     assigner_.startOption(prop.key().c_str());
                     try
                     {
-                        assigner_.appendValue(prop.value().asVariant());
+                        assigner_.appendValue(prop.value().asAny());
                     }
                     catch (UserInputError &ex)
                     {
@@ -136,7 +136,7 @@ class TreeAssignHelper
                 assigner_.startOption(key.c_str());
                 for (const KeyValueTreeValue &value : array.values())
                 {
-                    assigner_.appendValue(value.asVariant());
+                    assigner_.appendValue(value.asAny());
                 }
                 assigner_.finishOption();
             }
@@ -250,7 +250,7 @@ class TreeAdjustHelper : private OptionsVisitor
             const std::string &name = option.name();
             if (currentSourceObject_ == nullptr || !currentSourceObject_->keyExists(name))
             {
-                std::vector<Variant> values = option.defaultValues();
+                std::vector<Any> values = option.defaultValues();
                 if (values.size() == 1)
                 {
                     currentObjectBuilder_.addRawValue(name, std::move(values[0]));
@@ -258,7 +258,7 @@ class TreeAdjustHelper : private OptionsVisitor
                 else if (values.size() > 1)
                 {
                     auto arrayBuilder = currentObjectBuilder_.addArray(name);
-                    for (Variant &value : values)
+                    for (Any &value : values)
                     {
                         arrayBuilder.addRawValue(std::move(value));
                     }
@@ -268,19 +268,19 @@ class TreeAdjustHelper : private OptionsVisitor
             {
                 const KeyValueTreeValue &value = (*currentSourceObject_)[name];
                 GMX_RELEASE_ASSERT(!value.isObject(), "Value objects not supported in this context");
-                std::vector<Variant>     values;
+                std::vector<Any>         values;
                 if (value.isArray())
                 {
                     for (const auto &arrayValue : value.asArray().values())
                     {
                         GMX_RELEASE_ASSERT(!value.isObject() && !value.isArray(),
                                            "Complex values not supported in this context");
-                        values.push_back(arrayValue.asVariant());
+                        values.push_back(arrayValue.asAny());
                     }
                 }
                 else
                 {
-                    values.push_back(value.asVariant());
+                    values.push_back(value.asAny());
                 }
                 values = option.normalizeValues(values);
                 if (values.empty())
index 0374890b10cc28db50c00060c840a26c722ff5b3..03c7a72c1274206bfab626e95e8454ff8b0b1a7c 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2016, by the GROMACS development team, led by
+ * Copyright (c) 2016,2019, 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.
 #include <map>
 #include <typeindex>
 
+#include "gromacs/utility/any.h"
 #include "gromacs/utility/exceptions.h"
-#include "gromacs/utility/variant.h"
 
 namespace gmx
 {
 
 /*! \libinternal \brief
- * Helper for converting from Variant to a given type.
+ * Helper for converting from Any to a given type.
  *
  * \tparam OutType  Type this converter converts to.
  *
  * Default-constructed converter only supports identity mapping from the a
- * Variant holding `OutType`.  To add support for additional input types,
+ * Any holding `OutType`.  To add support for additional input types,
  * provide conversion functions with addConverter().  To use a non-identity
  * mapping for an `OutType` -> `OutType` conversion, provide an alternative
  * conversion from `OutType` with addConverter().
@@ -71,13 +71,13 @@ class OptionValueConverterSimple
 {
     public:
         /*! \brief
-         * Converts a Variant value to the output type.
+         * Converts a Any value to the output type.
          *
          * \returns  Converted value.
-         * \throws InvalidInputError If the input Variant has a type that is
+         * \throws InvalidInputError If the input Any has a type that is
          *     not recognized by any conversion.
          */
-        OutType convert(const Variant &value) const
+        OutType convert(const Any &value) const
         {
             std::type_index type(value.type());
             auto            iter = converters_.find(type);
@@ -102,7 +102,7 @@ class OptionValueConverterSimple
         void addConverter(std::function<OutType(const InType &)> func)
         {
             converters_[std::type_index(typeid(InType))] =
-                [func] (const Variant &value)
+                [func] (const Any &value)
                 {
                     return func(value.cast<InType>());
                 };
@@ -116,14 +116,14 @@ class OptionValueConverterSimple
         void addCastConversion()
         {
             converters_[std::type_index(typeid(InType))] =
-                [] (const Variant &value)
+                [] (const Any &value)
                 {
                     return static_cast<OutType>(value.cast<InType>());
                 };
         }
 
     private:
-        typedef std::function<OutType(const Variant &value)> ConversionFunction;
+        typedef std::function<OutType(const Any &value)> ConversionFunction;
 
         std::map<std::type_index, ConversionFunction> converters_;
 };
index 5fe30043f99a8bfbd63db06f1b9cdf82ad983780..01c243c4a0f86bdfc78b77f3fac62bfa48786c2d 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2012,2013,2014,2016,2018, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014,2016,2018,2019, 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.
@@ -71,14 +71,14 @@ class SelectionFileOptionStorage : public AbstractOptionStorage
         OptionInfo &optionInfo() override { return info_; }
         std::string typeString() const override { return "file"; }
         int valueCount() const override { return 0; }
-        std::vector<Variant> defaultValues() const override { return {}; }
+        std::vector<Any> defaultValues() const override { return {}; }
         std::vector<std::string> defaultValuesAsStrings() const override { return {}; }
-        std::vector<Variant>
-        normalizeValues(const std::vector<Variant> &values) const override { return values; }
+        std::vector<Any>
+        normalizeValues(const std::vector<Any> &values) const override { return values; }
 
     private:
         void clearSet() override;
-        void convertValue(const Variant &value) override;
+        void convertValue(const Any &value) override;
         void processSet() override;
         void processAll() override {}
 
index 2635cbe78a856c4d7d0c8389381b3b0f75321d31..3e43983fbbbc70348870857672683a9853aa1695 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2010,2011,2012,2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,2013,2014,2015,2016,2017,2018,2019, 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.
@@ -84,8 +84,8 @@ std::string SelectionOptionStorage::formatSingleValue(const Selection &value) co
 }
 
 
-std::vector<Variant>
-SelectionOptionStorage::normalizeValues(const std::vector<Variant> & /*values*/) const
+std::vector<Any>
+SelectionOptionStorage::normalizeValues(const std::vector<Any> & /*values*/) const
 {
     GMX_THROW(NotImplementedError("Selection options not supported in this context"));
 }
@@ -125,7 +125,7 @@ void SelectionOptionStorage::addSelections(
 }
 
 
-void SelectionOptionStorage::convertValue(const Variant &value)
+void SelectionOptionStorage::convertValue(const Any &value)
 {
     manager_.convertOptionValue(this, value.cast<std::string>(), false);
 }
@@ -287,7 +287,7 @@ void SelectionFileOptionStorage::clearSet()
     bValueParsed_ = false;
 }
 
-void SelectionFileOptionStorage::convertValue(const Variant &value)
+void SelectionFileOptionStorage::convertValue(const Any &value)
 {
     if (bValueParsed_)
     {
index b6bdcc2f5d60c5e51706f2dcc2d621e5ad6c73f0..3c53237b9d0b82940de0cf0a904b9721494da47f 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2010,2011,2012,2013,2014,2015,2016,2018, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,2013,2014,2015,2016,2018,2019, 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.
@@ -77,8 +77,8 @@ class SelectionOptionStorage : public OptionStorageTemplate<Selection>
         OptionInfo &optionInfo() override { return info_; }
         std::string typeString() const override { return "selection"; }
         std::string formatSingleValue(const Selection &value) const override;
-        std::vector<Variant>
-        normalizeValues(const std::vector<Variant> &values) const override;
+        std::vector<Any>
+        normalizeValues(const std::vector<Any> &values) const override;
 
         /*! \brief
          * Adds selections to the storage.
@@ -128,7 +128,7 @@ class SelectionOptionStorage : public OptionStorageTemplate<Selection>
         void setSelectionFlag(SelectionFlag flag, bool bSet);
 
     private:
-        void convertValue(const Variant &value) override;
+        void convertValue(const Any &value) override;
         void processSetValues(ValueList *values) override;
         void processAll() override;
 
similarity index 93%
rename from src/gromacs/utility/variant.cpp
rename to src/gromacs/utility/any.cpp
index 05c3ff59d822588dddc37325bf00b65df3d1c73e..39b82eaa3fa6a84fe5165ccbf63ef7abf7ad88be 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2017,2018,2019, 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.
  */
 /*! \internal \file
  * \brief
- * Implements functionality from variant.h.
+ * Implements functionality from any.h.
  *
  * \author Teemu Murtola <teemu.murtola@gmail.com>
  * \ingroup module_utility
  */
 #include "gmxpre.h"
 
-#include "variant.h"
+#include "any.h"
 
 #include <string>
 
@@ -52,7 +52,7 @@ namespace gmx
 {
 
 //! \cond libapi
-std::string simpleValueToString(const Variant &value)
+std::string simpleValueToString(const Any &value)
 {
     if (value.isType<bool>())
     {
similarity index 81%
rename from src/gromacs/utility/variant.h
rename to src/gromacs/utility/any.h
index 5cd738bcdab972be71b9b20fb1c63548f9192a1c..05ece95265f890771a6b7f7769f7d48aa9911361 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2016,2017,2018,2019, 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.
  */
 /*! \libinternal \file
  * \brief
- * Declares gmx::Variant.
+ * Declares gmx::Any.
  *
  * \author Teemu Murtola <teemu.murtola@gmail.com>
  * \inlibraryapi
  * \ingroup module_utility
  */
-#ifndef GMX_UTILITY_VARIANT_H
-#define GMX_UTILITY_VARIANT_H
+#ifndef GMX_UTILITY_ANY_H
+#define GMX_UTILITY_ANY_H
 
 #include <memory>
 #include <string>
@@ -59,11 +59,11 @@ namespace gmx
 /*! \libinternal \brief
  * Represents a dynamically typed value of an arbitrary type.
  *
- * To create a variant, either initialize it as empty, or with the create()
+ * To create a any, either initialize it as empty, or with the create()
  * method (or the equivalent constructor, if the type parameter can be deduced
  * and is clear to the reader from the context).
  *
- * To query the type of the contents in the variant, use isEmpty(), type(), and
+ * To query the type of the contents in the any, use isEmpty(), type(), and
  * isType().
  *
  * To access the value, you need to know the type as a compile-time constant
@@ -76,11 +76,11 @@ namespace gmx
  *
  * \ingroup module_utility
  */
-class Variant
+class Any
 {
     public:
         /*! \brief
-         * Creates a variant that holds the given value.
+         * Creates a any that holds the given value.
          *
          * \throws std::bad_alloc if out of memory.
          *
@@ -88,9 +88,9 @@ class Variant
          * contrary to the templated constructor.
          */
         template <typename T>
-        static Variant create(const T &value) { return Variant(value); }
+        static Any create(const T &value) { return Any(value); }
         /*! \brief
-         * Creates a variant that holds the given value.
+         * Creates a any that holds the given value.
          *
          * \throws std::bad_alloc if out of memory.
          *
@@ -98,40 +98,40 @@ class Variant
          * method avoids copying when move-construction is possible.
          */
         template <typename T>
-        static Variant create(T &&value) { return Variant(std::forward<T>(value)); }
+        static Any create(T &&value) { return Any(std::forward<T>(value)); }
 
-        //! Creates an empty variant value.
-        Variant() {}
+        //! Creates an empty any value.
+        Any() {}
         /*! \brief
-         * Creates a variant that holds the given value.
+         * Creates a any that holds the given value.
          *
          * \throws std::bad_alloc if out of memory.
          */
-        template <typename T, typename = typename std::enable_if<!std::is_same<T, Variant>::value>::type>
-        explicit Variant(T &&value)
+        template <typename T, typename = typename std::enable_if<!std::is_same<T, Any>::value>::type>
+        explicit Any(T &&value)
             : content_(new Content<typename std::decay<T>::type>(std::forward<T>(value)))
         {
         }
         /*! \brief
-         * Creates a deep copy of a variant.
+         * Creates a deep copy of a any.
          *
          * \throws std::bad_alloc if out of memory.
          */
-        Variant(const Variant &other) : content_(other.cloneContent()) {}
-        //! Move-constructs a variant.
-        Variant(Variant &&other) noexcept : content_(std::move(other.content_)) {}
+        Any(const Any &other) : content_(other.cloneContent()) {}
+        //! Move-constructs a any.
+        Any(Any &&other) noexcept : content_(std::move(other.content_)) {}
         /*! \brief
-         * Assigns the variant.
+         * Assigns the any.
          *
          * \throws std::bad_alloc if out of memory.
          */
-        Variant &operator=(const Variant &other)
+        Any &operator=(const Any &other)
         {
             content_ = other.cloneContent();
             return *this;
         }
-        //! Move-assigns the variant.
-        Variant &operator=(Variant &&other) noexcept
+        //! Move-assigns the any.
+        Any &operator=(Any &&other) noexcept
         {
             content_ = std::move(other.content_);
             return *this;
@@ -168,9 +168,9 @@ class Variant
         /*! \brief
          * Gets the value when the type is known.
          *
-         * \tparam T  Type to get (which must match what the variant stores).
+         * \tparam T  Type to get (which must match what the any stores).
          *
-         * Asserts if the variant is empty or does not contain the requested type.
+         * Asserts if the any is empty or does not contain the requested type.
          */
         template <typename T>
         const T &cast() const
@@ -197,9 +197,9 @@ class Variant
         /*! \brief
          * Gets the value when the type is known as a modifiable reference.
          *
-         * \tparam T  Type to get (which must match what the variant stores).
+         * \tparam T  Type to get (which must match what the any stores).
          *
-         * Asserts if the variant is empty or does not contain the requested type.
+         * Asserts if the any is empty or does not contain the requested type.
          */
         template <typename T>
         T &castRef()
@@ -242,14 +242,14 @@ class Variant
 
 //! \cond libapi
 /*! \brief
- * Converts a Variant value to a string.
+ * Converts a Any value to a string.
  *
  * As the name suggests, only some types of "simple" values (such as int) are
  * supported.  Asserts for unsupported types.
  *
  * \ingroup module_utility
  */
-std::string simpleValueToString(const Variant &value);
+std::string simpleValueToString(const Any &value);
 //! \endcond
 
 } // namespace gmx
index 293289d663ab49777fff640f98a546b457f269f0..0ce225ea75539b6a321aae3a5d5afd7cd47883ad 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2016,2017,2018,2019, 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.
@@ -71,8 +71,8 @@
 #include <utility>
 #include <vector>
 
+#include "gromacs/utility/any.h"
 #include "gromacs/utility/real.h"
-#include "gromacs/utility/variant.h"
 
 namespace gmx
 {
@@ -184,13 +184,13 @@ class KeyValueTreeValue
         template <typename T>
         const T                  &cast() const { return value_.cast<T>(); }
 
-        //! Returns the raw Variant value (always possible).
-        const Variant            &asVariant() const { return value_; }
+        //! Returns the raw Any value (always possible).
+        const Any            &asAny() const { return value_; }
 
     private:
-        explicit KeyValueTreeValue(Variant &&value) : value_(std::move(value)) {}
+        explicit KeyValueTreeValue(Any &&value) : value_(std::move(value)) {}
 
-        Variant             value_;
+        Any             value_;
 
         friend class KeyValueTreeBuilder;
         friend class KeyValueTreeObjectBuilder;
@@ -350,7 +350,7 @@ void compareKeyValueTrees(TextWriter               *writer,
 static inline std::string
 simpleValueToString(const KeyValueTreeValue &value)
 {
-    return simpleValueToString(value.asVariant());
+    return simpleValueToString(value.asAny());
 }
 
 //! \endcond
index 145f4935d266c6af4faa407c8781e8eeabb5c619..d5c16dce8591a2f4b0901361528956758a834af2 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2016,2017,2019, 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.
@@ -56,9 +56,9 @@
 #include <utility>
 #include <vector>
 
+#include "gromacs/utility/any.h"
 #include "gromacs/utility/gmxassert.h"
 #include "gromacs/utility/keyvaluetree.h"
-#include "gromacs/utility/variant.h"
 
 namespace gmx
 {
@@ -92,7 +92,7 @@ class KeyValueTreeBuilder
         template <typename T>
         static KeyValueTreeValue createValue(const T &value)
         {
-            return KeyValueTreeValue(Variant::create<T>(value));
+            return KeyValueTreeValue(Any::create<T>(value));
         }
         /*! \brief
          * Helper function for other builders to create default-constructed
@@ -101,7 +101,7 @@ class KeyValueTreeBuilder
         template <typename T>
         static KeyValueTreeValue createValue()
         {
-            return KeyValueTreeValue(Variant::create<T>(T()));
+            return KeyValueTreeValue(Any::create<T>(T()));
         }
 
         KeyValueTreeObject root_;
@@ -131,10 +131,10 @@ class KeyValueTreeValueBuilder
         template <typename T>
         void setValue(const T &value)
         {
-            value_ = Variant::create<T>(value);
+            value_ = Any::create<T>(value);
         }
-        //! Assigns a Variant value to the built value.
-        void setVariantValue(Variant &&value)
+        //! Assigns a Any value to the built value.
+        void setAnyValue(Any &&value)
         {
             value_ = std::move(value);
         }
@@ -161,7 +161,7 @@ class KeyValueTreeValueBuilder
         KeyValueTreeValue build() { return KeyValueTreeValue(std::move(value_)); }
 
     private:
-        Variant value_;
+        Any value_;
 };
 
 class KeyValueTreeArrayBuilderBase
@@ -173,11 +173,11 @@ class KeyValueTreeArrayBuilderBase
         {
         }
 
-        //! Appends a raw Variant value to the array.
-        KeyValueTreeValue &addRawValue(Variant &&value)
+        //! Appends a raw Any value to the array.
+        KeyValueTreeValue &addRawValue(Any &&value)
         {
             KeyValueTreeValueBuilder builder;
-            builder.setVariantValue(std::move(value));
+            builder.setAnyValue(std::move(value));
             array_->values_.push_back(builder.build());
             return array_->values_.back();
         }
@@ -285,8 +285,8 @@ class KeyValueTreeObjectBuilder
         {
             addProperty(key, std::move(value));
         }
-        //! Adds a property with given key from a Variant value.
-        void addRawValue(const std::string &key, Variant &&value)
+        //! Adds a property with given key from a Any value.
+        void addRawValue(const std::string &key, Any &&value)
         {
             addProperty(key, KeyValueTreeValue(std::move(value)));
         }
@@ -439,13 +439,13 @@ inline KeyValueTreeObjectBuilder KeyValueTreeBuilder::rootObject()
 
 inline KeyValueTreeObjectBuilder KeyValueTreeValueBuilder::createObject()
 {
-    value_ = Variant::create<KeyValueTreeObject>(KeyValueTreeObject());
+    value_ = Any::create<KeyValueTreeObject>(KeyValueTreeObject());
     return KeyValueTreeObjectBuilder(&value_.castRef<KeyValueTreeObject>());
 }
 
 inline KeyValueTreeArrayBuilder KeyValueTreeValueBuilder::createArray()
 {
-    value_ = Variant::create<KeyValueTreeArray>(KeyValueTreeArray());
+    value_ = Any::create<KeyValueTreeArray>(KeyValueTreeArray());
     return KeyValueTreeArrayBuilder(&value_.castRef<KeyValueTreeArray>());
 }
 
index d183901634618f5aae763137fc8381c24ed8b8f3..ff884942f6461cd6ccfaa81d9e345d4c85986ecc 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2016,2017,2018,2019, 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.
@@ -565,24 +565,24 @@ void KeyValueTreeTransformRuleBuilder::setKeyMatchType(StringCompareType keyMatc
     data_->keyMatchRule_ = true;
 }
 
-void KeyValueTreeTransformRuleBuilder::addTransformToVariant(
-        const std::function<Variant(const Variant &)> &transform)
+void KeyValueTreeTransformRuleBuilder::addTransformToAny(
+        const std::function<Any(const Any &)> &transform)
 {
     data_->transform_ =
         [transform] (KeyValueTreeValueBuilder *builder, const KeyValueTreeValue &value)
         {
-            builder->setVariantValue(transform(value.asVariant()));
+            builder->setAnyValue(transform(value.asAny()));
         };
 }
 
 void KeyValueTreeTransformRuleBuilder::addTransformToObject(
-        const std::function<void(KeyValueTreeObjectBuilder *, const Variant &)> &transform)
+        const std::function<void(KeyValueTreeObjectBuilder *, const Any &)> &transform)
 {
     data_->transform_ =
         [transform] (KeyValueTreeValueBuilder *builder, const KeyValueTreeValue &value)
         {
             KeyValueTreeObjectBuilder obj = builder->createObject();
-            transform(&obj, value.asVariant());
+            transform(&obj, value.asAny());
         };
 }
 
index b40cd161824414bcc74cb24793d6e66abc5a81c3..577c147db054a13db3d764f5d3149ddfb11bd288 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2016,2017,2018,2019, 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.
@@ -50,9 +50,9 @@
 #include <typeindex>
 #include <vector>
 
+#include "gromacs/utility/any.h"
 #include "gromacs/utility/classhelpers.h"
 #include "gromacs/utility/keyvaluetree.h"
-#include "gromacs/utility/variant.h"
 
 namespace gmx
 {
@@ -201,10 +201,10 @@ class KeyValueTreeTransformRuleBuilder
                  */
                 void transformWith(std::function<ToType(const FromType &)> transform)
                 {
-                    builder_->addTransformToVariant(
-                            [transform] (const Variant &value)
+                    builder_->addTransformToAny(
+                            [transform] (const Any &value)
                             {
-                                return Variant::create<ToType>(transform(value.cast<FromType>()));
+                                return Any::create<ToType>(transform(value.cast<FromType>()));
                             });
                 }
         };
@@ -234,7 +234,7 @@ class KeyValueTreeTransformRuleBuilder
                 void transformWith(std::function<void(KeyValueTreeObjectBuilder *, const FromType &)> transform)
                 {
                     builder_->addTransformToObject(
-                            [transform] (KeyValueTreeObjectBuilder *builder, const Variant &value)
+                            [transform] (KeyValueTreeObjectBuilder *builder, const Any &value)
                             {
                                 transform(builder, value.cast<FromType>());
                             });
@@ -346,8 +346,8 @@ class KeyValueTreeTransformRuleBuilder
         void setExpectedType(const std::type_index &type);
         void setToPath(const KeyValueTreePath &path);
         void setKeyMatchType(StringCompareType keyMatchType);
-        void addTransformToVariant(const std::function<Variant(const Variant &)> &transform);
-        void addTransformToObject(const std::function<void(KeyValueTreeObjectBuilder *, const Variant &)> &transform);
+        void addTransformToAny(const std::function<Any(const Any &)> &transform);
+        void addTransformToObject(const std::function<void(KeyValueTreeObjectBuilder *, const Any &)> &transform);
 
         class Data;
 
index af51f8a0280b788e618b0a4dfd18e91aa9858720..98043304be8de5e236f1b4e6e534c5401e6f8db4 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2011,2012,2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2011,2012,2013,2014,2015,2016,2017,2018,2019, 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.
 
 #include "gromacs/options/basicoptions.h"
 #include "gromacs/options/ioptionscontainer.h"
+#include "gromacs/utility/any.h"
 #include "gromacs/utility/exceptions.h"
 #include "gromacs/utility/gmxassert.h"
 #include "gromacs/utility/keyvaluetree.h"
 #include "gromacs/utility/path.h"
 #include "gromacs/utility/real.h"
 #include "gromacs/utility/stringutil.h"
-#include "gromacs/utility/variant.h"
 
 #include "testutils/refdata-checkers.h"
 #include "testutils/refdata-impl.h"
@@ -976,35 +976,35 @@ void TestReferenceChecker::checkVector(const double value[3], const char *id)
 }
 
 
-void TestReferenceChecker::checkVariant(const Variant &variant, const char *id)
+void TestReferenceChecker::checkAny(const Any &any, const char *id)
 {
-    if (variant.isType<bool>())
+    if (any.isType<bool>())
     {
-        checkBoolean(variant.cast<bool>(), id);
+        checkBoolean(any.cast<bool>(), id);
     }
-    else if (variant.isType<int>())
+    else if (any.isType<int>())
     {
-        checkInteger(variant.cast<int>(), id);
+        checkInteger(any.cast<int>(), id);
     }
-    else if (variant.isType<int64_t>())
+    else if (any.isType<int64_t>())
     {
-        checkInt64(variant.cast<int64_t>(), id);
+        checkInt64(any.cast<int64_t>(), id);
     }
-    else if (variant.isType<float>())
+    else if (any.isType<float>())
     {
-        checkFloat(variant.cast<float>(), id);
+        checkFloat(any.cast<float>(), id);
     }
-    else if (variant.isType<double>())
+    else if (any.isType<double>())
     {
-        checkDouble(variant.cast<double>(), id);
+        checkDouble(any.cast<double>(), id);
     }
-    else if (variant.isType<std::string>())
+    else if (any.isType<std::string>())
     {
-        checkString(variant.cast<std::string>(), id);
+        checkString(any.cast<std::string>(), id);
     }
     else
     {
-        GMX_THROW(TestException("Unsupported variant type"));
+        GMX_THROW(TestException("Unsupported any type"));
     }
 }
 
@@ -1033,7 +1033,7 @@ void TestReferenceChecker::checkKeyValueTreeValue(const KeyValueTreeValue &value
     }
     else
     {
-        checkVariant(value.asVariant(), id);
+        checkAny(value.asAny(), id);
     }
 }
 
index c1040949d737bc54c3b04bcad96b24f78b19fe5e..d6c04e448e11e6bd106c1384e99e3ecb262898dc 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2011,2012,2013,2014,2015,2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2011,2012,2013,2014,2015,2016,2017,2018,2019, 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.
@@ -58,7 +58,7 @@ namespace gmx
 class IOptionsContainer;
 class KeyValueTreeObject;
 class KeyValueTreeValue;
-class Variant;
+class Any;
 
 namespace test
 {
@@ -374,8 +374,8 @@ class TestReferenceChecker
         void checkVector(const double value[3], const char *id);
         //! Check a single floating-point value from a string.
         void checkRealFromString(const std::string &value, const char *id);
-        //! Checks a variant value that contains a supported simple type.
-        void checkVariant(const Variant &value, const char *id);
+        //! Checks a any value that contains a supported simple type.
+        void checkAny(const Any &value, const char *id);
         //! Checks a key-value tree rooted at a object.
         void checkKeyValueTreeObject(const KeyValueTreeObject &tree, const char *id);
         //! Checks a generic key-value tree value.
index f81272a73aaf876b06ffe42fe6367c6162ee8bad..c7f4e3758ec0781c0ca16f30065ab6d47666a479 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2011,2012,2013,2014,2015,2016,2017, by the GROMACS development team, led by
+ * Copyright (c) 2011,2012,2013,2014,2015,2016,2017,2019, 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.
@@ -49,9 +49,9 @@
 #include <gtest/gtest.h>
 #include <gtest/gtest-spi.h>
 
+#include "gromacs/utility/any.h"
 #include "gromacs/utility/keyvaluetree.h"
 #include "gromacs/utility/keyvaluetreebuilder.h"
-#include "gromacs/utility/variant.h"
 
 #include "testutils/testasserts.h"
 #include "testutils/testexceptions.h"
@@ -344,24 +344,24 @@ TEST(ReferenceDataTest, HandlesUncheckedDataInCompound)
 }
 
 
-TEST(ReferenceDataTest, HandlesVariants)
+TEST(ReferenceDataTest, HandlesAnys)
 {
-    using gmx::Variant;
+    using gmx::Any;
     {
         TestReferenceData    data(gmx::test::erefdataUpdateAll);
         TestReferenceChecker checker(data.rootChecker());
-        checker.checkVariant(Variant::create<bool>(true), "bool");
-        checker.checkVariant(Variant::create<int>(1), "int");
-        checker.checkVariant(Variant::create<double>(3.5), "real");
-        checker.checkVariant(Variant::create<std::string>("foo"), "str");
+        checker.checkAny(Any::create<bool>(true), "bool");
+        checker.checkAny(Any::create<int>(1), "int");
+        checker.checkAny(Any::create<double>(3.5), "real");
+        checker.checkAny(Any::create<std::string>("foo"), "str");
     }
     {
         TestReferenceData    data(gmx::test::erefdataCompare);
         TestReferenceChecker checker(data.rootChecker());
-        checker.checkVariant(Variant::create<bool>(true), "bool");
-        checker.checkVariant(Variant::create<int>(1), "int");
-        checker.checkVariant(Variant::create<double>(3.5), "real");
-        checker.checkVariant(Variant::create<std::string>("foo"), "str");
+        checker.checkAny(Any::create<bool>(true), "bool");
+        checker.checkAny(Any::create<int>(1), "int");
+        checker.checkAny(Any::create<double>(3.5), "real");
+        checker.checkAny(Any::create<std::string>("foo"), "str");
     }
 }
 
@@ -430,44 +430,44 @@ TEST(ReferenceDataTest, HandlesKeyValueTreeMissingKey)
 }
 
 
-TEST(ReferenceDataTest, HandlesVariantsWithIncorrectValue)
+TEST(ReferenceDataTest, HandlesAnysWithIncorrectValue)
 {
-    using gmx::Variant;
+    using gmx::Any;
     {
         TestReferenceData    data(gmx::test::erefdataUpdateAll);
         TestReferenceChecker checker(data.rootChecker());
-        checker.checkVariant(Variant::create<bool>(true), "bool");
-        checker.checkVariant(Variant::create<int>(1), "int");
-        checker.checkVariant(Variant::create<double>(3.5), "real");
-        checker.checkVariant(Variant::create<std::string>("foo"), "str");
+        checker.checkAny(Any::create<bool>(true), "bool");
+        checker.checkAny(Any::create<int>(1), "int");
+        checker.checkAny(Any::create<double>(3.5), "real");
+        checker.checkAny(Any::create<std::string>("foo"), "str");
     }
     {
         TestReferenceData    data(gmx::test::erefdataCompare);
         TestReferenceChecker checker(data.rootChecker());
-        EXPECT_NONFATAL_FAILURE(checker.checkVariant(Variant::create<bool>(false), "bool"), "");
-        EXPECT_NONFATAL_FAILURE(checker.checkVariant(Variant::create<int>(2), "int"), "");
-        EXPECT_NONFATAL_FAILURE(checker.checkVariant(Variant::create<double>(2.5), "real"), "");
-        EXPECT_NONFATAL_FAILURE(checker.checkVariant(Variant::create<std::string>("bar"), "str"), "");
+        EXPECT_NONFATAL_FAILURE(checker.checkAny(Any::create<bool>(false), "bool"), "");
+        EXPECT_NONFATAL_FAILURE(checker.checkAny(Any::create<int>(2), "int"), "");
+        EXPECT_NONFATAL_FAILURE(checker.checkAny(Any::create<double>(2.5), "real"), "");
+        EXPECT_NONFATAL_FAILURE(checker.checkAny(Any::create<std::string>("bar"), "str"), "");
     }
 }
 
 
-TEST(ReferenceDataTest, HandlesVariantsWithIncorrectType)
+TEST(ReferenceDataTest, HandlesAnysWithIncorrectType)
 {
-    using gmx::Variant;
+    using gmx::Any;
     {
         TestReferenceData    data(gmx::test::erefdataUpdateAll);
         TestReferenceChecker checker(data.rootChecker());
-        checker.checkVariant(Variant::create<bool>(true), "bool");
-        checker.checkVariant(Variant::create<int>(1), "int");
-        checker.checkVariant(Variant::create<double>(3.5), "real");
+        checker.checkAny(Any::create<bool>(true), "bool");
+        checker.checkAny(Any::create<int>(1), "int");
+        checker.checkAny(Any::create<double>(3.5), "real");
     }
     {
         TestReferenceData    data(gmx::test::erefdataCompare);
         TestReferenceChecker checker(data.rootChecker());
-        EXPECT_NONFATAL_FAILURE(checker.checkVariant(Variant::create<int>(1), "bool"), "");
-        EXPECT_NONFATAL_FAILURE(checker.checkVariant(Variant::create<bool>(true), "int"), "");
-        EXPECT_NONFATAL_FAILURE(checker.checkVariant(Variant::create<int>(2), "real"), "");
+        EXPECT_NONFATAL_FAILURE(checker.checkAny(Any::create<int>(1), "bool"), "");
+        EXPECT_NONFATAL_FAILURE(checker.checkAny(Any::create<bool>(true), "int"), "");
+        EXPECT_NONFATAL_FAILURE(checker.checkAny(Any::create<int>(2), "real"), "");
     }
 }