![]() |
ENSDF++ 1.1
An easy, fast and simple way to run querys towards the ENSDF database, written in C++.
|
Identifies a specific nucleid. More...
#include <Nukleid.h>
Public Member Functions | |
Nukleid () | |
Constructor, constructs a blank nucleid (empty). | |
Nukleid (string nucleid) | |
Constructor, constructs a nucleid from a nucleid string. | |
string | getElement () const |
Returns the element string. | |
int | getZ () const |
Returns number of protons. | |
int | getA () const |
Returns number of nucleons. | |
string | toString () const |
Returns a string formatted like "3HE". | |
bool | operator== (const Nukleid &other) const |
Comparision operator. | |
bool | operator> (const Nukleid &other) const |
Comparision operator. | |
bool | operator< (const Nukleid &other) const |
Comparision operator. | |
Static Public Member Functions | |
static void | parseNukleidName (string nucleid, short unsigned int &mass, string &element) |
Parses a nucleid name to mass and element. | |
Protected Member Functions | |
short unsigned int | parseAtomicNumber (string elementToParse) |
Parses the atomic number from elementToParse. | |
Protected Attributes | |
unsigned short int | Z |
The number of protons in the nucleid. | |
unsigned short int | A |
The number of nucleons in the nucleid. | |
string | element |
The element name. | |
string | name |
The name of the element. (e.g. "8HE"). | |
Private Member Functions | |
string | trimString (string toTrim) |
Trims a string. |
Identifies a specific nucleid.
Contains mass number, number of protons and chemical element in a string. Example: 8BE, 2H, etc.
Nukleid::Nukleid | ( | string | nucleid | ) |
Constructor, constructs a nucleid from a nucleid string.
nucleid | The nucleid string to construct the Nukleid object from. 5 or 6 characters long, the first 3 characters are the mass number, the last 2 (or 3) are the name. Example: nucleid=" 3H ", nucleid="235U ". |
Definition at line 12 of file Nukleid.cpp.
{ name=trimString(nucleid); parseNukleidName(nucleid, A, element); Z=parseAtomicNumber(element); }
bool Nukleid::operator< | ( | const Nukleid & | other | ) | const |
bool Nukleid::operator== | ( | const Nukleid & | other | ) | const |
bool Nukleid::operator> | ( | const Nukleid & | other | ) | const |
unsigned short int Nukleid::parseAtomicNumber | ( | string | elementToParse | ) | [protected] |
Parses the atomic number from elementToParse.
elementToParse | The element to parse. |
Definition at line 28 of file Nukleid.cpp.
References ElementLookupTable::lookupElement().
{ ElementLookupTable myTable; return myTable.lookupElement(elementToParse); }
void Nukleid::parseNukleidName | ( | string | nucleid, |
short unsigned int & | mass, | ||
string & | element | ||
) | [static] |
Parses a nucleid name to mass and element.
nucleid | The nucleid name to parse |
mass | A reference to an integer in which the mass number will be inserted. |
element | A reference to a string in which the element will be inserted. |
Definition at line 59 of file Nukleid.cpp.
{ if (nucleid.length() != 5 && nucleid.length()!=6) { throw DataFileException("Nucleid string was of wrong length."); return; } for (int i = 0; i < 3; i++) { if (!((nucleid.at(i) >= '0' && nucleid.at(i) <= '9') || nucleid.at(i) == ' ')) { throw DataFileException("Nucleid number was invalid: '''" + nucleid + "'''"); return; } } for (unsigned int i = 3; i < nucleid.length(); i++) { if(nucleid.at(i)>='a' && nucleid.at(i)<='z') { nucleid[i]+='A'-'a'; } if (!((nucleid.at(i) >= 'A' && nucleid.at(i) <= 'Z') || (nucleid.at(i) == ' ') || (nucleid.at(i) >= '0' && nucleid.at(i) <= '9'))) { throw DataFileException("Nucleid name was invalid: '''" + nucleid + "'''"); return; } } string number = nucleid.substr(0, 3); const char* numberCString = number.c_str(); mass = atoi(numberCString); if (nucleid.at(4) == ' ') element = nucleid.at(3); else if(nucleid.length()==5) element = nucleid.substr(3,2); else if(nucleid[5]!=' ') element = nucleid.substr(3,3); else element = nucleid.substr(3,2); }
string Nukleid::trimString | ( | string | toTrim | ) | [private] |
Trims a string.
toTrim | The string to trim. |
Definition at line 19 of file Nukleid.cpp.
{ string results = ""; for(unsigned int i = 0; i<toTrim.size(); i++) if(!(toTrim[i]==' ' || toTrim[i]=='\n' || toTrim[i]=='\t')) results+=toTrim[i]; return results; }