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 {
20  if (category=="Angle")
21  angl_=true;
22 }
23 
25 {
26  delete bu_;
27 }
28 
30 {
31 
32  std::ostrstream str;
33 
34  if (angl_) {
35  str.precision(11);
36  double x = ( *(bu_->GetValue()) ) / deg;
37  str << x << std::string("*deg") << '\0';
38  return std::string(str.str());
39 
40  }
41  else {
42  str << *bu_ << '\0';
43  std::string s(str.str());
44  return s.replace(s.find(" "),1,"*");
45  }
46  //return s;
47 
48 }
49 
50 /*
51 ostream & operator<<(ostream & os, const UnitConverter & uc)
52 {
53  ostrstream temp;
54  //temp << uc.bu_;
55  //temp << '\0';
56  //string s(temp.str());
57  //cout << "NOW: " << s << endl;
58  os << *(uc.bu_);
59 }
60 
61 */
long double ALIdouble
Definition: CocoaGlobals.h:11
CocoaBestUnit * bu_
Definition: UnitConverter.h:23
std::string ucstring()
std::string ALIstring
Definition: CocoaGlobals.h:9
ALIdouble * GetValue()
UnitConverter(ALIdouble val, const ALIstring &category)
#define str(s)