|
[Rivet-svn] r4292 - trunk/src/Coreblackhole at projects.hepforge.org blackhole at projects.hepforge.orgWed May 15 11:58:49 BST 2013
Author: buckley Date: Wed May 15 11:58:49 2013 New Revision: 4292 Log: A bit more yaml-cpp v3 backporting Modified: trunk/src/Core/AnalysisInfo.cc Modified: trunk/src/Core/AnalysisInfo.cc ============================================================================== --- trunk/src/Core/AnalysisInfo.cc Wed May 15 11:40:29 2013 (r4291) +++ trunk/src/Core/AnalysisInfo.cc Wed May 15 11:58:49 2013 (r4292) @@ -53,7 +53,7 @@ // Simple scalars (test for nullness before casting) #if YAMLCPP_API_VERSION == 3 /// @todo Fix - #define TRY_GETINFO(KEY, VAR) try { if (doc[KEY] { string val; doc[KEY].second >> val; ai->_ ## VAR = val; } catch (...) { THROW_INFOERR(KEY); } + #define TRY_GETINFO(KEY, VAR) try { if (doc.FindValue(KEY) { string val; doc[KEY] >> val; ai->_ ## VAR = val; } catch (...) { THROW_INFOERR(KEY); } #elif YAMLCPP_API_VERSION == 5 #define TRY_GETINFO(KEY, VAR) try { if (doc[KEY] && !doc[KEY].IsNull()) ai->_ ## VAR = doc[KEY].as<string>(); } catch (...) { THROW_INFOERR(KEY); } #endif @@ -75,11 +75,10 @@ #if YAMLCPP_API_VERSION == 3 /// @todo Fix #define TRY_GETINFO_SEQ(KEY, VAR) try { \ - if (doc[KEY]) { \ - const YAML::Node& VAR = doc[KEY]; \ - for (size_t i = 0; i < VAR.size(); ++i) \ - if (!VAR[i].IsNull()) ai->_ ## VAR += VAR[i].as<string>(); \ - } } catch (...) { THROW_INFOERR(KEY); } + if (const YAML::Node* VAR = doc.FindValue(KEY)) { \ + for (size_t i = 0; i < VAR.size(); ++i) { \ + string val; VAR[i] >> val; ai->_ ## VAR += val; \ + } } } catch (...) { THROW_INFOERR(KEY); } #elif YAMLCPP_API_VERSION == 5 #define TRY_GETINFO_SEQ(KEY, VAR) try { \ if (doc[KEY] && !doc[KEY].IsNull()) { \ @@ -111,6 +110,10 @@ try { #if YAMLCPP_API_VERSION == 3 + /// @todo Fix + + #elif YAMLCPP_API_VERSION == 5 + if (doc["Beams"]) { const YAML::Node& beams = doc["Beams"]; vector<PdgIdPair> beam_pairs; @@ -127,10 +130,6 @@ ai->_beams = beam_pairs; } - #elif YAMLCPP_API_VERSION == 5 - - /// @todo Fix - #endif } catch (...) { THROW_INFOERR("Beams"); } @@ -139,6 +138,10 @@ try { #if YAMLCPP_API_VERSION == 3 + /// @todo Fix + + #elif YAMLCPP_API_VERSION == 5 + if (doc["Energies"]) { vector< pair<double,double> > beam_energy_pairs; for (size_t i = 0; i < doc["Energies"].size(); ++i) { @@ -157,10 +160,6 @@ ai->_energies = beam_energy_pairs; } - #elif YAMLCPP_API_VERSION == 5 - - /// @todo Fix - #endif } catch (...) { THROW_INFOERR("Energies"); }
More information about the Rivet-svn mailing list |