CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
JsonPrinter.cc
Go to the documentation of this file.
2 //
3 #include <sstream>
4 
5 namespace cond {
6 
7  namespace utilities {
8 
9  JsonPrinter::JsonPrinter():m_values(){}
10 
11  JsonPrinter::JsonPrinter( const std::string& xName, const std::string& yName ):
12  m_xName(xName),
13  m_yName(yName),
14  m_values(){
15  }
16 
17  void JsonPrinter::append( const std::string& xValue, const std::string& yValue, const std::string& yError ){
18  m_values.push_back( std::make_tuple( xValue, yValue, yError ) );
19  }
20 
21  void JsonPrinter::append( const std::string& xValue, const std::string& yValue ){
22  m_values.push_back( std::make_tuple( xValue, yValue, "0" ) );
23  }
24 
26  std::stringstream ss;
27  ss<<" { [ ";
28  bool first = true;
29  for( auto iv : m_values ){
30  if(!first) ss << ",";
31  ss <<" { ";
32  ss <<" \""<<m_xName<<"\": "<<std::get<0>(iv)<<",";
33  ss <<" \""<<m_yName<<"\": "<<std::get<1>(iv)<<",";
34  ss <<" \""<<m_yName<<"_Error\": "<<std::get<2>(iv);
35  ss <<" } ";
36  first = false;
37  }
38  ss<<"] }";
39  return ss.str();
40  }
41 
42  }
43 
44 }
45 
void append(const std::string &xValue, const std::string &yValue, const std::string &yError)
Definition: JsonPrinter.cc:17
std::vector< std::tuple< std::string, std::string, std::string > > m_values
Definition: JsonPrinter.h:27