![]() |
ENSDF++ 1.1
An easy, fast and simple way to run querys towards the ENSDF database, written in C++.
|
Extended by all specializing Record classes in the ENSDF database. More...
#include <Record.h>
Public Member Functions | |
Record (list< string > cardArg) | |
Constructor. | |
Nukleid | getNukleid () const |
Returns the associated Nukleid object. | |
list< string > | getCardStrings () const |
Get the card strings. | |
Protected Member Functions | |
double | cardToDouble (int startPos, int endPos) |
Takes a portion of the record card, and parses it as a double. | |
double | parseHalfLife (int startPos, int endPos) |
Takes a portion of the record card, and parses it as a half-life (number and unit). | |
string | trimString (string toTrim) |
Trim a string. | |
Private Attributes | |
Nukleid | myNukleid |
The Nukleid object corresponding to this Record. | |
list< string > | myCard |
Holds the 80 character wide ENSDF record card(s) for this record. |
Record::Record | ( | list< string > | cardArg | ) |
double Record::cardToDouble | ( | int | startPos, |
int | endPos | ||
) | [protected] |
Takes a portion of the record card, and parses it as a double.
startPos | The start position in the ENSDF record card. |
endPos | The end position in the ENSDF record card. |
Definition at line 28 of file Record.cpp.
References myCard.
Referenced by QValueRecord::processCard(), NormalizationRecord::processCard(), LevelRecord::processCard(), GammaRecord::processCard(), BetaPlusRecord::processCard(), and BetaMinusRecord::processCard().
{ if(!myCard.empty()) { string data = myCard.front().substr(startPos-1, endPos-startPos+1); const char* dataCString = data.c_str(); double number = atof(dataCString); return number; } else { throw DataFileException("Empty card string.\n"); } }
list< string > Record::getCardStrings | ( | ) | const |
Get the card strings.
Definition at line 23 of file Record.cpp.
References myCard.
Referenced by DataQueryBetaGamma::findNextLevel(), and IdentificationRecord::processCard().
{ return myCard; }
Nukleid Record::getNukleid | ( | ) | const |
Returns the associated Nukleid object.
Definition at line 18 of file Record.cpp.
References myNukleid.
Referenced by DataQueryBetaGamma::DetectInterestingStuffWithThisIsotope(), QValueRecord::operator==(), LevelRecord::operator==(), Record_TEST::testBetaMinusRecord(), Record_TEST::testBetaPlusRecord(), Record_TEST::testGammaRecord(), Record_TEST::testLevelRecord(), Record_TEST::testNormalizationRecord(), and Record_TEST::testParentRecord().
{ return myNukleid; }
double Record::parseHalfLife | ( | int | startPos, |
int | endPos | ||
) | [protected] |
Takes a portion of the record card, and parses it as a half-life (number and unit).
Definition at line 53 of file Record.cpp.
References myCard, and trimString().
Referenced by ParentRecord::processCard(), and LevelRecord::processCard().
{ string tempStr = myCard.front().substr(startPos-1, endPos-startPos+1); string halfLifeStr = trimString(tempStr); if (halfLifeStr.substr(0,5).compare("STABLE") == 0) // the strings are equal return -1; unsigned int i = 0; for (i = 0; i < halfLifeStr.length(); i++) { if (!((halfLifeStr.at(i) <= '9' && halfLifeStr.at(i) >= '0') || halfLifeStr.at(i) == '.')) break; } if(halfLifeStr.size()<i+2) return -3; string numberStr = halfLifeStr.substr(0, i); const char* numberCString = numberStr.c_str(); double number = atof(numberCString); if(halfLifeStr.size()>i+2) { string unit = halfLifeStr.substr(i+1, 2); if (unit.compare("Y ") == 0) number *= 365*24*60*60; else if (unit.compare("D ") == 0) number *= 60*60*24; else if (unit.compare("H ") == 0) number *= 60*60; else if (unit.compare("M ") == 0) number *= 60; else if (unit.compare("S ") == 0) number *= 1; else if (unit.compare("MS") == 0) number *= 1E-3; else if (unit.compare("US") == 0) number *= 1E-6; else if (unit.compare("NS") == 0) number *= 1E-9; else if (unit.compare("PS") == 0) number *= 1E-12; else if (unit.compare("FS") == 0) number *= 1E-15; else if (unit.compare("AS") == 0) number *= 1E-18; else return -2; } else if(halfLifeStr.size()>i+1) { string unit = halfLifeStr.substr(i+1, 1); if (unit.compare("Y") == 0) number *= 365*24*60*60; else if (unit.compare("D") == 0) number *= 60*60*24; else if (unit.compare("H") == 0) number *= 60*60; else if (unit.compare("M") == 0) number *= 60; else if (unit.compare("S") == 0) number *= 1; else return -5; } else { number = - 1339; } return number; }
string Record::trimString | ( | string | toTrim | ) | [protected] |
Trim a string.
toTrim | The string to trim. |
Definition at line 43 of file Record.cpp.
Referenced by parseHalfLife().
{ int ptrStart = -1; int ptrStop = toTrim.size(); while(toTrim[++ptrStart]==' '); while(toTrim[--ptrStop]==' '); return toTrim.substr(ptrStart,ptrStop-ptrStart+1); }