22#if defined(SCAFACOS) or defined(SCAFACOS_DIPOLES)
33#include <boost/variant.hpp>
54 :
public boost::static_visitor<std::vector<std::string>> {
55 auto operator()(std::string
const &value)
const {
return result_type{value}; }
57 template <
typename T,
typename = std::enable_if_t<!std::is_arithmetic_v<T>>>
59 throw std::runtime_error(
"Cannot convert " + Utils::demangle<T>());
62 template <
typename T,
typename = std::enable_if_t<std::is_same_v<T,
int>>>
75 for (
auto const &v :
values) {
76 values_str.emplace_back(boost::apply_visitor(*
this, v).front());
81 template <
typename T,
typename = std::enable_if_t<std::is_arithmetic_v<T>>>
84 for (
auto const &v :
values) {
91 std::string to_str(
int const value)
const {
return std::to_string(value); }
93 std::string to_str(
double const value)
const {
95 serializer << std::scientific << std::setprecision(17);
102 :
public boost::static_visitor<std::unordered_map<std::string, Variant>> {
105 template <
typename T>
108 return (
obj.empty()) ? result_type{} : invalid(
obj);
116 template <
typename T>
auto invalid(T
const &
obj)
const {
124 throw std::invalid_argument(
125 "ScaFaCoS methods require at least 1 parameter");
131 for (
auto const &value : boost::apply_visitor(
visitor, kv.second)) {
149std::unordered_map<std::string, Variant>
159 auto const numbers = std::string(
"-0123456789");
162 std::istringstream
buffer;
164 for (std::string line; std::getline(
buffer, line,
',');) {
171 if ((
numbers.find(
it->front()) == std::string::npos)
and
ScafacosContextBase provides the public interface of the ScaFaCoS bridge.
This file contains the defaults for ESPResSo.
std::unordered_map< std::string, Variant > deserialize_parameters(std::string const ¶meters)
Convert flattened parameters to a map.
std::string serialize_parameters(Variant const &pack)
Flatten a parameter map.
std::vector< std::string > available_methods()
Fetch list of methods compiled in ScaFaCoS.
std::optional< Variant > string_to_number(std::string const &s)
PackedVariant pack(const Variant &v)
Transform a Variant to a PackedVariant.
T get_value(Variant const &v)
Extract value of specific type T from a Variant.
boost::make_recursive_variant< None, bool, int, std::size_t, double, std::string, ObjectRef, Utils::Vector3b, Utils::Vector3i, Utils::Vector2d, Utils::Vector3d, Utils::Vector4d, std::vector< int >, std::vector< double >, std::vector< boost::recursive_variant_ >, std::unordered_map< int, boost::recursive_variant_ >, std::unordered_map< std::string, boost::recursive_variant_ > >::type Variant
Possible types for parameters.
static std::vector< std::string > available_methods()
auto operator()(T const &value) const
auto operator()(std::vector< T > const &values) const
auto operator()(std::vector< Variant > const &values) const
auto operator()(result_type const &values) const
auto operator()(double const &value) const
result_type operator()(T const &) const
auto operator()(std::string const &value) const
auto operator()(result_type const &obj) const
auto operator()(std::unordered_map< T, Variant > const &obj) const
auto operator()(T const &obj) const