Hammer  1.0.0
Helicity Amplitude Module for Matrix Element Reweighting
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HammerYaml.hh
Go to the documentation of this file.
1 ///
2 /// @file HammerYaml.hh
3 /// @brief Hammer YaML utility functions
4 ///
5 
6 //**** This file is a part of the HAMMER library
7 //**** Copyright (C) 2016 - 2020 The HAMMER Collaboration
8 //**** HAMMER is licensed under version 3 of the GPL; see COPYING for details
9 //**** Please note the MCnet academic guidelines; see GUIDELINES for details
10 
11 // -*- C++ -*-
12 #ifndef HAMMER_TOOLS_HAMMERYAML
13 #define HAMMER_TOOLS_HAMMERYAML
14 
15 #include <map>
16 #include <string>
17 
18 #include "yaml-cpp/yaml.h"
19 
20 namespace Hammer {
21 
22  template<typename T>
23  void writeDict2(YAML::Emitter& emitter, std::map<std::string, std::map<std::string, const T*>> dict2) {
24  for(auto& elem: dict2) {
25  emitter << YAML::Key << elem.first;
26  emitter << YAML::Value << YAML::BeginMap;
27  for(auto& elem2: elem.second) {
28  emitter << YAML::Key << elem2.first;
29  emitter << YAML::Value << *elem2.second;
30  }
31  emitter << YAML::EndMap;
32  }
33  }
34 
35  template<typename T>
36  void writeDict(YAML::Emitter& emitter, std::map<std::string, const T*> dict) {
37  for(auto& elem: dict) {
38  emitter << YAML::Key << elem.first;
39  emitter << YAML::Value << *elem.second;
40  }
41  }
42 
43 } // namespace Hammer
44 
45 #endif
void writeDict(YAML::Emitter &emitter, std::map< std::string, const T * > dict)
Definition: HammerYaml.hh:36
void writeDict2(YAML::Emitter &emitter, std::map< std::string, std::map< std::string, const T * >> dict2)
Definition: HammerYaml.hh:23