| Line | |
|---|
| 1 | // this :
|
|---|
| 2 | #include <G4Lab/BestUnit.h>
|
|---|
| 3 |
|
|---|
| 4 | // Geant4 :
|
|---|
| 5 | #include <G4UnitsTable.hh>
|
|---|
| 6 |
|
|---|
| 7 | // Lib :
|
|---|
| 8 | #include <Lib/Debug.h>
|
|---|
| 9 | #include <Lib/Out.h>
|
|---|
| 10 | #include <Lib/smanip.h>
|
|---|
| 11 | #include <Lib/sout.h>
|
|---|
| 12 |
|
|---|
| 13 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 14 | bool G4Lab::BestUnit::toDoubles(
|
|---|
| 15 | Slash::Core::IWriter& aPrinter
|
|---|
| 16 | ,const std::string& aString
|
|---|
| 17 | ,std::vector<double>& aVec
|
|---|
| 18 | )
|
|---|
| 19 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 20 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
|
|---|
| 21 | {
|
|---|
| 22 | std::vector<std::string> words = Lib::smanip::words(aString," ");
|
|---|
| 23 | unsigned int wordn = words.size();
|
|---|
| 24 | if(!wordn) {
|
|---|
| 25 | aVec.clear();
|
|---|
| 26 | return false;
|
|---|
| 27 | }
|
|---|
| 28 | G4double unit = G4UnitDefinition::GetValueOf(words[wordn-1]);
|
|---|
| 29 | if(unit==0.) {
|
|---|
| 30 | aVec.clear();
|
|---|
| 31 | return false;
|
|---|
| 32 | }
|
|---|
| 33 | aVec.resize(wordn-1);
|
|---|
| 34 | for(unsigned int index=0;index<(wordn-1);index++) {
|
|---|
| 35 | double v = 0;
|
|---|
| 36 | if(!Lib::smanip::todouble(words[index],v)) {
|
|---|
| 37 | Lib::Out out(aPrinter);
|
|---|
| 38 | out << "G4Lab::BestUnit::toDoubles :"
|
|---|
| 39 | << " " << Lib::sout(words[index]) << " not a double."
|
|---|
| 40 | << Lib::endl;
|
|---|
| 41 | aVec.clear();
|
|---|
| 42 | return false;
|
|---|
| 43 | }
|
|---|
| 44 | aVec[index] = v * unit;
|
|---|
| 45 | }
|
|---|
| 46 | return true;
|
|---|
| 47 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.