LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
quantities_fhicl.h
Go to the documentation of this file.
1 
9 #ifndef LARDATAALG_UTILITIES_QUANTITIES_FHICL_H
10 #define LARDATAALG_UTILITIES_QUANTITIES_FHICL_H
11 
12 // LArSoft libraries
13 #include "larcorealg/CoreUtils/StdUtils.h" // util::to_string()
15 
16 // support libraries
17 #include "fhiclcpp/coding.h"
18 
19 // C++ libraries
20 #include <any>
21 #include <string>
22 #include <string_view>
23 
25 
26  // --- BEGIN -- FHiCL encoding ---------------------------------------------
29 
30  // these utilities need to be defined in the same namespace as `Quantity`
31 
45  template <typename... Args>
46  void decode(std::any const& src, Quantity<Args...>& q);
47 
59  template <typename... Args>
60  ::fhicl::detail::ps_atom_t encode(Quantity<Args...> const& q);
61 
63  // --- END -- FHiCL encoding -----------------------------------------------
64 
65 } // namespace util::quantities::concepts
66 
67 // -----------------------------------------------------------------------------
68 // --- template implementation
69 // -----------------------------------------------------------------------------
70 template <typename... Args>
72 {
73  using quantity_t = Quantity<Args...>;
74 
75  std::string s;
77 
78  q = util::quantities::makeQuantity<quantity_t>(s);
79 
80 } // util::quantities::concepts::decode(Quantity)
81 
82 // -----------------------------------------------------------------------------
83 template <typename... Args>
85 {
87 } // util::quantities::concepts::encode()
88 
89 // -----------------------------------------------------------------------------
90 
91 #endif // LARDATAALG_UTILITIES_QUANTITIES_FHICL_H
::fhicl::detail::ps_atom_t encode(Interval< Args... > const &iv)
Encodes a quantity interval into a FHiCL parameter set atom.
Infrastructure for the quantities library.
Definition: intervals.h:25
decltype(auto) constexpr to_string(T &&obj)
ADL-aware version of std::to_string.
A value measured in the specified unit.
Definition: quantities.h:554
::fhicl::detail::ps_atom_t encode(Quantity< Args... > const &q)
Encodes a quantity into a FHiCL parameter set atom.
void decode(std::any const &src, Interval< Args... > &iv)
Decodes an interval.
Numeric variable proxies with embedded unit of measurement.
std::string ps_atom_t
Definition: coding.h:44
Functions pulling in STL customization if available.
void decode(std::any const &src, Quantity< Args... > &q)
Decodes a quantity.