AliPhysics  db95e02 (db95e02)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliJSONData.cxx
Go to the documentation of this file.
1 /*
2  * AliJSONData.cxx
3  *
4  * Created on: 06.11.2014
5  * Author: markusfasel
6  */
7 #include <sstream>
8 #include <TString.h>
9 
10 #include <AliJSONData.h>
11 
19 
20 std::string AliJSONInt::ToString() const {
21  std::stringstream stringbuilder;
22  stringbuilder << fValue;
23  return stringbuilder.str();
24 }
25 
26 std::string AliJSONFloat::ToString() const {
27  std::stringstream stringbuilder;
28  stringbuilder << fValue;
29  return stringbuilder.str();
30 }
31 
32 std::string AliJSONDouble::ToString() const {
33  std::stringstream stringbuilder;
34  stringbuilder << fValue;
35  return stringbuilder.str();
36 }
37 
38 AliJSONData::AliJSONData(const char* key, const char* value):
39  TNamed(key, ""),
40  fValue(NULL)
41 {
42  TString valstring(value);
43  if(!valstring.CompareTo("true"))
44  fValue = new AliJSONBool(kTRUE);
45  else if(!valstring.CompareTo("false"))
46  fValue = new AliJSONBool(kFALSE);
47  else if(valstring.IsDigit()){
48  if(valstring.IsFloat())
49  fValue = new AliJSONDouble(valstring.Atof());
50  else
51  fValue = new AliJSONInt(valstring.Atoi());
52  } else
53  fValue = new AliJSONString(value);
54 }
55 
56 std::string AliJSONData::ToString() const {
57  std::stringstream jsonbuilder;
58  jsonbuilder << "\"" << GetName() << "\":\"" << fValue->ToString() << "\"";
59  return jsonbuilder.str().c_str();
60 }
61 
62 std::ostream &operator<<(std::ostream &os, const AliJSONValue &val){
63  os << val.ToString();
64  return os;
65 }
66 
67 std::ostream &operator<<(std::ostream &os, const AliJSONData &obj){
68  os << obj.ToString();
69  return os;
70 }
71 
AliJSONData(const char *name, AliJSONValue *value)
Definition: AliJSONData.h:130
Float_t fValue
Definition: AliJSONData.h:63
virtual std::string ToString() const
virtual std::string ToString() const
Double_t fValue
Definition: AliJSONData.h:81
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
std::string ToString() const
virtual std::string ToString() const =0
ClassImp(AliJSONValue) ClassImp(AliJSONInt) ClassImp(AliJSONFloat) ClassImp(AliJSONDouble) ClassImp(AliJSONBool) ClassImp(AliJSONString) ClassImp(AliJSONData) std stringbuilder<< fValue;return stringbuilder.str();}std::string AliJSONFloat::ToString() const {std::stringstream stringbuilder;stringbuilder<< fValue;return stringbuilder.str();}std::string AliJSONDouble::ToString() const {std::stringstream stringbuilder;stringbuilder<< fValue;return stringbuilder.str();}AliJSONData::AliJSONData(const char *key, const char *value):TNamed(key,""), fValue(NULL){TString valstring(value);if(!valstring.CompareTo("true")) fValue=new AliJSONBool(kTRUE);else if(!valstring.CompareTo("false")) fValue=new AliJSONBool(kFALSE);else if(valstring.IsDigit()){if(valstring.IsFloat()) fValue=new AliJSONDouble(valstring.Atof());else fValue=new AliJSONInt(valstring.Atoi());}else fValue=new AliJSONString(value);}std::string AliJSONData::ToString() const {std::stringstream jsonbuilder;jsonbuilder<< "\""<< GetName()<< "\":\""<< fValue-> ToString()<< "\""
Definition: AliJSONData.cxx:58
std::ostream & operator<<(std::ostream &os, const AliJSONValue &val)
Definition: AliJSONData.cxx:62