11 #include <boost/math/special_functions.hpp>
13 #include <yaml-cpp/yaml.h>
40 emitter_ = std::make_shared<YAML::Emitter>();
41 emitter_->SetDoublePrecision(std::numeric_limits<double>::digits10);
61 template <
class... t_Args>
101 if (
impl_->map_depth_ > 0 or not
impl_->skip_root_map_)
103 *
impl_->emitter_ << YAML::BeginMap;
112 *
impl_->emitter_ << YAML::Key << map_name;
113 *
impl_->emitter_ << YAML::Value;
121 if (
impl_->map_depth_ > 0 or not
impl_->skip_root_map_)
123 *
impl_->emitter_ << YAML::EndMap;
140 *
impl_->emitter_ << YAML::Flow;
142 *
impl_->emitter_ << YAML::BeginSeq;
149 *
impl_->emitter_ << YAML::EndSeq;
159 impl_->skip_root_map_ =
true;
170 if (not name.empty())
174 impl_->skip_root_map_ =
false;
178 #define ARILES2_BASIC_TYPE(type) \
179 void Writer::writeElement(const type &element, const Parameters &) \
181 *impl_->emitter_ << element; \
186 #undef ARILES2_BASIC_TYPE
189 #define ARILES2_BASIC_TYPE(type) \
190 void Writer::writeElement(const type &element, const Parameters &) \
192 if (boost::math::isnan(element)) \
194 *impl_->emitter_ << ".nan"; \
198 if (boost::math::isinf(element)) \
202 *impl_->emitter_ << "-.inf"; \
206 *impl_->emitter_ << ".inf"; \
211 *impl_->emitter_ << static_cast<double>(element); \
218 #undef ARILES2_BASIC_TYPE
224 *
impl_->emitter_ << element;
229 *
impl_->emitter_ << element;
void flush()
Flush the configuration to the output.
void endRoot(const std::string &name)
void startMap(const Parameters &, const std::size_t)
Starts a nested map in the configuration file.
Writer(const std::string &file_name)
void startRoot(const std::string &name, const Parameters &)
void startMapEntry(const std::string &map_name)
Starts a nested map in the configuration file.
void startArray(const std::size_t, const bool compact=false)
void endMap()
Ends a nested map in the configuration file.
std::shared_ptr< YAML::Emitter > EmitterPtr
EmitterPtr emitter_
instance of YAML emitter, is destroyed and reinitialized by flush()
void makeImplPtr(t_Args &&...args)
std::ostream * output_stream_
output stream
FileVisitorImplementation(const std::string &file_name)
virtual void endMapEntry()
void writeElement(const std::complex< t_Scalar > &entry, const Parameters ¶m)
#define CPPUT_ASSERT(condition,...)
#define ARILES2_BASIC_REAL_TYPES_LIST
#define ARILES2_BASIC_INTEGER_TYPES_LIST
visitor::Parameters Parameters
CPPUT_MACRO_SUBSTITUTE(ARILES2_BASIC_INTEGER_TYPES_LIST) CPPUT_MACRO_SUBSTITUTE(ARILES2_BASIC_REAL_TYPES_LIST) void Writer
#define CPPUT_TRACE_FUNCTION
#define CPPUT_TRACE_VALUE(value)