diff --git a/core/base/inc/TObject.h b/core/base/inc/TObject.h index 090a4967d6a87c2b78926acf4508e36bfba40b13..399889afd912f1405474c4dc191d4d55a3fbccc0 100644 --- a/core/base/inc/TObject.h +++ b/core/base/inc/TObject.h @@ -228,6 +228,10 @@ enum EObjBits { kInvalidObject = TObject::kInvalidObject }; +namespace cling { + std::string printValue(TObject *val); +} + #ifndef ROOT_TBuffer #include "TBuffer.h" #endif diff --git a/core/base/src/TObject.cxx b/core/base/src/TObject.cxx index 124b0d66ccd5d5ab9d558fbaa3846845e53f94fd..8af0e147d81cafe828dd464be54e0a03318c351f 100644 --- a/core/base/src/TObject.cxx +++ b/core/base/src/TObject.cxx @@ -32,6 +32,7 @@ #endif #include <stdlib.h> #include <stdio.h> +#include <sstream> #include "Varargs.h" #include "Riostream.h" @@ -1055,6 +1056,15 @@ void TObject::operator delete[](void *ptr) fgDtorOnly = 0; } +//////////////////////////////////////////////////////////////////////////////// +/// Print value overload + +std::string cling::printValue(TObject *val) { + std::ostringstream strm; + strm << "Name: " << val->GetName() << " Title: " << val->GetTitle(); + return strm.str(); +} + #ifdef R__PLACEMENTDELETE //////////////////////////////////////////////////////////////////////////////// /// Only called by placement new when throwing an exception. diff --git a/hist/hist/inc/TH1.h b/hist/hist/inc/TH1.h index 83fff6ce99b74f0c2cb84e63d407665923a21994..73f4c67085a7b761bb802fd642f8bb5340489027 100644 --- a/hist/hist/inc/TH1.h +++ b/hist/hist/inc/TH1.h @@ -438,6 +438,10 @@ protected: virtual Double_t GetBinErrorSqUnchecked(Int_t bin) const { return fSumw2.fN ? fSumw2.fArray[bin] : RetrieveBinContent(bin); } }; +namespace cling { + std::string printValue(TH1 *val); +} + //________________________________________________________________________ class TH1C : public TH1, public TArrayC { diff --git a/hist/hist/src/TH1.cxx b/hist/hist/src/TH1.cxx index b70f63c37fa93204a2d5cbcde27c7423ebdcc276..76b5fd2e6690992f01884e7f764249413a1eccf3 100644 --- a/hist/hist/src/TH1.cxx +++ b/hist/hist/src/TH1.cxx @@ -13,6 +13,7 @@ #include <string.h> #include <stdio.h> #include <ctype.h> +#include <sstream> #include "Riostream.h" #include "TROOT.h" @@ -8794,6 +8795,15 @@ void TH1::UpdateBinContent(Int_t, Double_t) AbstractMethod("UpdateBinContent"); } +//////////////////////////////////////////////////////////////////////////////// +/// Print value overload + +std::string cling::printValue(TH1 *val) { + std::ostringstream strm; + strm << cling::printValue((TObject*)val) << " NbinsX: " << val->GetNbinsX(); + return strm.str(); +} + //______________________________________________________________________________ // TH1C methods