From: Roland Schulz Date: Mon, 21 Jan 2019 19:15:38 +0000 (-0800) Subject: Rename gmx Variant to Any X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=commitdiff_plain;h=50e81a307fac3970834f4e7654f2e92996ea8cad;p=alexxy%2Fgromacs.git Rename gmx Variant to Any 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 --- diff --git a/src/gromacs/options/abstractoption.cpp b/src/gromacs/options/abstractoption.cpp index 6b8c75bfec..c8d77e18a9 100644 --- a/src/gromacs/options/abstractoption.cpp +++ b/src/gromacs/options/abstractoption.cpp @@ -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 OptionInfo::defaultValues() const +std::vector OptionInfo::defaultValues() const { return option().defaultValues(); } @@ -271,7 +271,7 @@ std::vector OptionInfo::defaultValuesAsStrings() const return option().defaultValuesAsStrings(); } -std::vector OptionInfo::normalizeValues(const std::vector &values) const +std::vector OptionInfo::normalizeValues(const std::vector &values) const { return option().normalizeValues(values); } diff --git a/src/gromacs/options/abstractoption.h b/src/gromacs/options/abstractoption.h index 575cd6efad..5bc34cac5d 100644 --- a/src/gromacs/options/abstractoption.h +++ b/src/gromacs/options/abstractoption.h @@ -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 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 defaultValues() const; + std::vector 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 normalizeValues(const std::vector &values) const; + std::vector normalizeValues(const std::vector &values) const; protected: /*! \cond libapi */ diff --git a/src/gromacs/options/abstractoptionstorage.h b/src/gromacs/options/abstractoptionstorage.h index dd4e2eae76..7a266bd451 100644 --- a/src/gromacs/options/abstractoptionstorage.h +++ b/src/gromacs/options/abstractoptionstorage.h @@ -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 defaultValues() const = 0; + virtual std::vector defaultValues() const = 0; //! \copydoc OptionInfo::defaultValuesAsStrings() virtual std::vector defaultValuesAsStrings() const = 0; //! \copydoc OptionInfo::normalizeValues() - virtual std::vector normalizeValues(const std::vector &values) const = 0; + virtual std::vector normalizeValues(const std::vector &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. diff --git a/src/gromacs/options/basicoptions.cpp b/src/gromacs/options/basicoptions.cpp index fa33e4f1e7..57bd2106f9 100644 --- a/src/gromacs/options/basicoptions.cpp +++ b/src/gromacs/options/basicoptions.cpp @@ -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(formatSingleValue(value)); + return Any::create(formatSingleValue(value)); } void EnumOptionStorage::initConverter(ConverterType *converter) diff --git a/src/gromacs/options/basicoptionstorage.h b/src/gromacs/options/basicoptionstorage.h index 847af90eb7..b1dfb5781e 100644 --- a/src/gromacs/options/basicoptionstorage.h +++ b/src/gromacs/options/basicoptionstorage.h @@ -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 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 &allowedValues() const { return allowed_; } diff --git a/src/gromacs/options/optionsassigner.cpp b/src/gromacs/options/optionsassigner.cpp index 45cd89a555..f9cb896873 100644 --- a/src/gromacs/options/optionsassigner.cpp +++ b/src/gromacs/options/optionsassigner.cpp @@ -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(!impl_->reverseBoolean_)); + option->appendValue(Any::create(!impl_->reverseBoolean_)); } else if (impl_->reverseBoolean_) { diff --git a/src/gromacs/options/optionsassigner.h b/src/gromacs/options/optionsassigner.h index cdefa72582..a07892fe04 100644 --- a/src/gromacs/options/optionsassigner.h +++ b/src/gromacs/options/optionsassigner.h @@ -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 diff --git a/src/gromacs/options/optionstoragetemplate.h b/src/gromacs/options/optionstoragetemplate.h index 5659fae120..0081912bcf 100644 --- a/src/gromacs/options/optionstoragetemplate.h +++ b/src/gromacs/options/optionstoragetemplate.h @@ -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. @@ -50,11 +50,11 @@ #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 defaultValues() const override; + std::vector 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 values() { return store_->values(); } @@ -327,11 +327,11 @@ class OptionStorageTemplateSimple : public OptionStorageTemplate { } - std::vector - normalizeValues(const std::vector &values) const override + std::vector + normalizeValues(const std::vector &values) const override { const_cast(this)->ensureConverterInitialized(); - std::vector result; + std::vector result; result.reserve(values.size()); for (const auto &value : values) { @@ -367,16 +367,16 @@ class OptionStorageTemplateSimple : public OptionStorageTemplate * 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(processValue(value)); + return Any::create(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 > OptionStorageTemplate::createStore( template -std::vector OptionStorageTemplate::defaultValues() const +std::vector OptionStorageTemplate::defaultValues() const { - std::vector result; + std::vector result; if (hasFlag(efOption_NoDefaultValue)) { return result; @@ -483,7 +483,7 @@ std::vector OptionStorageTemplate::defaultValues() const "Current option implementation can only provide default values before assignment"); for (const auto &value : values()) { - result.push_back(Variant::create(value)); + result.push_back(Any::create(value)); } return normalizeValues(result); } diff --git a/src/gromacs/options/tests/abstractoptionstorage.cpp b/src/gromacs/options/tests/abstractoptionstorage.cpp index 3360752773..de0037b604 100644 --- a/src/gromacs/options/tests/abstractoptionstorage.cpp +++ b/src/gromacs/options/tests/abstractoptionstorage.cpp @@ -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 { return ""; } - std::vector - normalizeValues(const std::vector &values) const override + std::vector + normalizeValues(const std::vector &values) const override { return values; } - void convertValue(const gmx::Variant &value) override + void convertValue(const gmx::Any &value) override { convertValue(value.cast()); } diff --git a/src/gromacs/options/tests/optionsassigner.cpp b/src/gromacs/options/tests/optionsassigner.cpp index e8de95d92f..ad1df79761 100644 --- a/src/gromacs/options/tests/optionsassigner.cpp +++ b/src/gromacs/options/tests/optionsassigner.cpp @@ -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(2.7))); + ASSERT_NO_THROW(assigner.appendValue(gmx::Any::create(2.7))); EXPECT_NO_THROW(assigner.finishOption()); EXPECT_NO_THROW(assigner.finish()); EXPECT_NO_THROW(options.finish()); diff --git a/src/gromacs/options/treesupport.cpp b/src/gromacs/options/treesupport.cpp index bacc788d34..aeb94fbe37 100644 --- a/src/gromacs/options/treesupport.cpp +++ b/src/gromacs/options/treesupport.cpp @@ -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 values = option.defaultValues(); + std::vector 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 values; + std::vector 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()) diff --git a/src/gromacs/options/valueconverter.h b/src/gromacs/options/valueconverter.h index 0374890b10..03c7a72c12 100644 --- a/src/gromacs/options/valueconverter.h +++ b/src/gromacs/options/valueconverter.h @@ -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. @@ -46,19 +46,19 @@ #include #include +#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 func) { converters_[std::type_index(typeid(InType))] = - [func] (const Variant &value) + [func] (const Any &value) { return func(value.cast()); }; @@ -116,14 +116,14 @@ class OptionValueConverterSimple void addCastConversion() { converters_[std::type_index(typeid(InType))] = - [] (const Variant &value) + [] (const Any &value) { return static_cast(value.cast()); }; } private: - typedef std::function ConversionFunction; + typedef std::function ConversionFunction; std::map converters_; }; diff --git a/src/gromacs/selection/selectionfileoptionstorage.h b/src/gromacs/selection/selectionfileoptionstorage.h index 5fe30043f9..01c243c4a0 100644 --- a/src/gromacs/selection/selectionfileoptionstorage.h +++ b/src/gromacs/selection/selectionfileoptionstorage.h @@ -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 defaultValues() const override { return {}; } + std::vector defaultValues() const override { return {}; } std::vector defaultValuesAsStrings() const override { return {}; } - std::vector - normalizeValues(const std::vector &values) const override { return values; } + std::vector + normalizeValues(const std::vector &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 {} diff --git a/src/gromacs/selection/selectionoption.cpp b/src/gromacs/selection/selectionoption.cpp index 2635cbe78a..3e43983fbb 100644 --- a/src/gromacs/selection/selectionoption.cpp +++ b/src/gromacs/selection/selectionoption.cpp @@ -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 -SelectionOptionStorage::normalizeValues(const std::vector & /*values*/) const +std::vector +SelectionOptionStorage::normalizeValues(const std::vector & /*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(), false); } @@ -287,7 +287,7 @@ void SelectionFileOptionStorage::clearSet() bValueParsed_ = false; } -void SelectionFileOptionStorage::convertValue(const Variant &value) +void SelectionFileOptionStorage::convertValue(const Any &value) { if (bValueParsed_) { diff --git a/src/gromacs/selection/selectionoptionstorage.h b/src/gromacs/selection/selectionoptionstorage.h index b6bdcc2f5d..3c53237b9d 100644 --- a/src/gromacs/selection/selectionoptionstorage.h +++ b/src/gromacs/selection/selectionoptionstorage.h @@ -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 OptionInfo &optionInfo() override { return info_; } std::string typeString() const override { return "selection"; } std::string formatSingleValue(const Selection &value) const override; - std::vector - normalizeValues(const std::vector &values) const override; + std::vector + normalizeValues(const std::vector &values) const override; /*! \brief * Adds selections to the storage. @@ -128,7 +128,7 @@ class SelectionOptionStorage : public OptionStorageTemplate 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; diff --git a/src/gromacs/utility/variant.cpp b/src/gromacs/utility/any.cpp similarity index 93% rename from src/gromacs/utility/variant.cpp rename to src/gromacs/utility/any.cpp index 05c3ff59d8..39b82eaa3f 100644 --- a/src/gromacs/utility/variant.cpp +++ b/src/gromacs/utility/any.cpp @@ -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. @@ -34,14 +34,14 @@ */ /*! \internal \file * \brief - * Implements functionality from variant.h. + * Implements functionality from any.h. * * \author Teemu Murtola * \ingroup module_utility */ #include "gmxpre.h" -#include "variant.h" +#include "any.h" #include @@ -52,7 +52,7 @@ namespace gmx { //! \cond libapi -std::string simpleValueToString(const Variant &value) +std::string simpleValueToString(const Any &value) { if (value.isType()) { diff --git a/src/gromacs/utility/variant.h b/src/gromacs/utility/any.h similarity index 81% rename from src/gromacs/utility/variant.h rename to src/gromacs/utility/any.h index 5cd738bcda..05ece95265 100644 --- a/src/gromacs/utility/variant.h +++ b/src/gromacs/utility/any.h @@ -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. @@ -34,14 +34,14 @@ */ /*! \libinternal \file * \brief - * Declares gmx::Variant. + * Declares gmx::Any. * * \author Teemu Murtola * \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 #include @@ -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 - 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 - static Variant create(T &&value) { return Variant(std::forward(value)); } + static Any create(T &&value) { return Any(std::forward(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 ::value>::type> - explicit Variant(T &&value) + template ::value>::type> + explicit Any(T &&value) : content_(new Content::type>(std::forward(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 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 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 diff --git a/src/gromacs/utility/keyvaluetree.h b/src/gromacs/utility/keyvaluetree.h index 293289d663..0ce225ea75 100644 --- a/src/gromacs/utility/keyvaluetree.h +++ b/src/gromacs/utility/keyvaluetree.h @@ -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 #include +#include "gromacs/utility/any.h" #include "gromacs/utility/real.h" -#include "gromacs/utility/variant.h" namespace gmx { @@ -184,13 +184,13 @@ class KeyValueTreeValue template const T &cast() const { return value_.cast(); } - //! 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 diff --git a/src/gromacs/utility/keyvaluetreebuilder.h b/src/gromacs/utility/keyvaluetreebuilder.h index 145f4935d2..d5c16dce85 100644 --- a/src/gromacs/utility/keyvaluetreebuilder.h +++ b/src/gromacs/utility/keyvaluetreebuilder.h @@ -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 #include +#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 static KeyValueTreeValue createValue(const T &value) { - return KeyValueTreeValue(Variant::create(value)); + return KeyValueTreeValue(Any::create(value)); } /*! \brief * Helper function for other builders to create default-constructed @@ -101,7 +101,7 @@ class KeyValueTreeBuilder template static KeyValueTreeValue createValue() { - return KeyValueTreeValue(Variant::create(T())); + return KeyValueTreeValue(Any::create(T())); } KeyValueTreeObject root_; @@ -131,10 +131,10 @@ class KeyValueTreeValueBuilder template void setValue(const T &value) { - value_ = Variant::create(value); + value_ = Any::create(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()); + value_ = Any::create(KeyValueTreeObject()); return KeyValueTreeObjectBuilder(&value_.castRef()); } inline KeyValueTreeArrayBuilder KeyValueTreeValueBuilder::createArray() { - value_ = Variant::create(KeyValueTreeArray()); + value_ = Any::create(KeyValueTreeArray()); return KeyValueTreeArrayBuilder(&value_.castRef()); } diff --git a/src/gromacs/utility/keyvaluetreetransform.cpp b/src/gromacs/utility/keyvaluetreetransform.cpp index d183901634..ff884942f6 100644 --- a/src/gromacs/utility/keyvaluetreetransform.cpp +++ b/src/gromacs/utility/keyvaluetreetransform.cpp @@ -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 &transform) +void KeyValueTreeTransformRuleBuilder::addTransformToAny( + const std::function &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 &transform) + const std::function &transform) { data_->transform_ = [transform] (KeyValueTreeValueBuilder *builder, const KeyValueTreeValue &value) { KeyValueTreeObjectBuilder obj = builder->createObject(); - transform(&obj, value.asVariant()); + transform(&obj, value.asAny()); }; } diff --git a/src/gromacs/utility/keyvaluetreetransform.h b/src/gromacs/utility/keyvaluetreetransform.h index b40cd16182..577c147db0 100644 --- a/src/gromacs/utility/keyvaluetreetransform.h +++ b/src/gromacs/utility/keyvaluetreetransform.h @@ -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 #include +#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 transform) { - builder_->addTransformToVariant( - [transform] (const Variant &value) + builder_->addTransformToAny( + [transform] (const Any &value) { - return Variant::create(transform(value.cast())); + return Any::create(transform(value.cast())); }); } }; @@ -234,7 +234,7 @@ class KeyValueTreeTransformRuleBuilder void transformWith(std::function transform) { builder_->addTransformToObject( - [transform] (KeyValueTreeObjectBuilder *builder, const Variant &value) + [transform] (KeyValueTreeObjectBuilder *builder, const Any &value) { transform(builder, value.cast()); }); @@ -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 &transform); - void addTransformToObject(const std::function &transform); + void addTransformToAny(const std::function &transform); + void addTransformToObject(const std::function &transform); class Data; diff --git a/src/testutils/refdata.cpp b/src/testutils/refdata.cpp index af51f8a028..98043304be 100644 --- a/src/testutils/refdata.cpp +++ b/src/testutils/refdata.cpp @@ -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. @@ -54,13 +54,13 @@ #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()) + if (any.isType()) { - checkBoolean(variant.cast(), id); + checkBoolean(any.cast(), id); } - else if (variant.isType()) + else if (any.isType()) { - checkInteger(variant.cast(), id); + checkInteger(any.cast(), id); } - else if (variant.isType()) + else if (any.isType()) { - checkInt64(variant.cast(), id); + checkInt64(any.cast(), id); } - else if (variant.isType()) + else if (any.isType()) { - checkFloat(variant.cast(), id); + checkFloat(any.cast(), id); } - else if (variant.isType()) + else if (any.isType()) { - checkDouble(variant.cast(), id); + checkDouble(any.cast(), id); } - else if (variant.isType()) + else if (any.isType()) { - checkString(variant.cast(), id); + checkString(any.cast(), 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); } } diff --git a/src/testutils/refdata.h b/src/testutils/refdata.h index c1040949d7..d6c04e448e 100644 --- a/src/testutils/refdata.h +++ b/src/testutils/refdata.h @@ -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. diff --git a/src/testutils/tests/refdata_tests.cpp b/src/testutils/tests/refdata_tests.cpp index f81272a73a..c7f4e3758e 100644 --- a/src/testutils/tests/refdata_tests.cpp +++ b/src/testutils/tests/refdata_tests.cpp @@ -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 #include +#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(true), "bool"); - checker.checkVariant(Variant::create(1), "int"); - checker.checkVariant(Variant::create(3.5), "real"); - checker.checkVariant(Variant::create("foo"), "str"); + checker.checkAny(Any::create(true), "bool"); + checker.checkAny(Any::create(1), "int"); + checker.checkAny(Any::create(3.5), "real"); + checker.checkAny(Any::create("foo"), "str"); } { TestReferenceData data(gmx::test::erefdataCompare); TestReferenceChecker checker(data.rootChecker()); - checker.checkVariant(Variant::create(true), "bool"); - checker.checkVariant(Variant::create(1), "int"); - checker.checkVariant(Variant::create(3.5), "real"); - checker.checkVariant(Variant::create("foo"), "str"); + checker.checkAny(Any::create(true), "bool"); + checker.checkAny(Any::create(1), "int"); + checker.checkAny(Any::create(3.5), "real"); + checker.checkAny(Any::create("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(true), "bool"); - checker.checkVariant(Variant::create(1), "int"); - checker.checkVariant(Variant::create(3.5), "real"); - checker.checkVariant(Variant::create("foo"), "str"); + checker.checkAny(Any::create(true), "bool"); + checker.checkAny(Any::create(1), "int"); + checker.checkAny(Any::create(3.5), "real"); + checker.checkAny(Any::create("foo"), "str"); } { TestReferenceData data(gmx::test::erefdataCompare); TestReferenceChecker checker(data.rootChecker()); - EXPECT_NONFATAL_FAILURE(checker.checkVariant(Variant::create(false), "bool"), ""); - EXPECT_NONFATAL_FAILURE(checker.checkVariant(Variant::create(2), "int"), ""); - EXPECT_NONFATAL_FAILURE(checker.checkVariant(Variant::create(2.5), "real"), ""); - EXPECT_NONFATAL_FAILURE(checker.checkVariant(Variant::create("bar"), "str"), ""); + EXPECT_NONFATAL_FAILURE(checker.checkAny(Any::create(false), "bool"), ""); + EXPECT_NONFATAL_FAILURE(checker.checkAny(Any::create(2), "int"), ""); + EXPECT_NONFATAL_FAILURE(checker.checkAny(Any::create(2.5), "real"), ""); + EXPECT_NONFATAL_FAILURE(checker.checkAny(Any::create("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(true), "bool"); - checker.checkVariant(Variant::create(1), "int"); - checker.checkVariant(Variant::create(3.5), "real"); + checker.checkAny(Any::create(true), "bool"); + checker.checkAny(Any::create(1), "int"); + checker.checkAny(Any::create(3.5), "real"); } { TestReferenceData data(gmx::test::erefdataCompare); TestReferenceChecker checker(data.rootChecker()); - EXPECT_NONFATAL_FAILURE(checker.checkVariant(Variant::create(1), "bool"), ""); - EXPECT_NONFATAL_FAILURE(checker.checkVariant(Variant::create(true), "int"), ""); - EXPECT_NONFATAL_FAILURE(checker.checkVariant(Variant::create(2), "real"), ""); + EXPECT_NONFATAL_FAILURE(checker.checkAny(Any::create(1), "bool"), ""); + EXPECT_NONFATAL_FAILURE(checker.checkAny(Any::create(true), "int"), ""); + EXPECT_NONFATAL_FAILURE(checker.checkAny(Any::create(2), "real"), ""); } }