CMS 3D CMS Logo

UnitConverter.cc
Go to the documentation of this file.
3 #include "CLHEP/Units/GlobalSystemOfUnits.h"
4 #include <sstream>
5 #include <strstream>
6 
7 /*
8 UnitConverter::UnitConverter(const G4BestUnit & bu)
9  : bu_(bu)
10 {
11  //ostrstream s;
12  //s << bu;
13 
14 }
15 */
16 
18  : bu_(new CocoaBestUnit(val, category)), angl_(false) {
19  if (category == "Angle")
20  angl_ = true;
21 }
22 
24 
26  std::ostrstream str;
27 
28  if (angl_) {
29  str.precision(11);
30  double x = (*(bu_->GetValue())) / deg;
31  str << x << std::string("*deg") << '\0';
32  return std::string(str.str());
33 
34  } else {
35  str << *bu_ << '\0';
36  std::string s(str.str());
37  return s.replace(s.find(' '), 1, "*");
38  }
39  //return s;
40 }
41 
42 /*
43 ostream & operator<<(ostream & os, const UnitConverter & uc)
44 {
45  ostrstream temp;
46  //temp << uc.bu_;
47  //temp << '\0';
48  //string s(temp.str());
49  //cout << "NOW: " << s << endl;
50  os << *(uc.bu_);
51 }
52 
53 */
long double ALIdouble
Definition: CocoaGlobals.h:11
CocoaBestUnit * bu_
Definition: UnitConverter.h:22
std::string ucstring()
std::string ALIstring
Definition: CocoaGlobals.h:9
ALIdouble * GetValue()
UnitConverter(ALIdouble val, const ALIstring &category)
#define str(s)