ENSDF++ 1.1
An easy, fast and simple way to run querys towards the ENSDF database, written in C++.
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions
Nukleid Class Reference

Identifies a specific nucleid. More...

#include <Nukleid.h>

List of all members.

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.

Detailed Description

Identifies a specific nucleid.

Contains mass number, number of protons and chemical element in a string. Example: 8BE, 2H, etc.

Author:
Rikard Lundmark

Definition at line 46 of file Nukleid.h.


Constructor & Destructor Documentation

Nukleid::Nukleid ( string  nucleid)

Constructor, constructs a nucleid from a nucleid string.

Parameters:
nucleidThe 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.


Member Function Documentation

bool Nukleid::operator< ( const Nukleid other) const

Comparision operator.

Parameters:
otherTo compare with.

Definition at line 128 of file Nukleid.cpp.

References name, and Z.

{
  if (Z > rhs.Z)
    {
      return false;
    }
  else if (Z == rhs.Z)
    {
      if(name.compare(rhs.name)==0)
        {
          return false;
        }
      return !(name.compare(rhs.name)>0);
    }
  return true;
}
bool Nukleid::operator== ( const Nukleid other) const

Comparision operator.

Parameters:
otherTo compare with.

Definition at line 108 of file Nukleid.cpp.

References A, element, and Z.

{
  if (Z == rhs.Z && A == rhs.A && element.compare(rhs.element)==0)
    return true;
  return false;
}
bool Nukleid::operator> ( const Nukleid other) const

Comparision operator.

Parameters:
otherTo compare with.

Definition at line 115 of file Nukleid.cpp.

References name, and Z.

{
  if (Z > rhs.Z)
    return true;
  else if (Z == rhs.Z)
    {
      if(name.compare(rhs.name)==0)
        return false;
      return name.compare(rhs.name)>0;
    }
  return false;
}
unsigned short int Nukleid::parseAtomicNumber ( string  elementToParse) [protected]

Parses the atomic number from elementToParse.

Parameters:
elementToParseThe 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.

Parameters:
nucleidThe nucleid name to parse
massA reference to an integer in which the mass number will be inserted.
elementA 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.

Parameters:
toTrimThe 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;
}

The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Enumerations Enumerator Defines

Back to the main page of the Precalibrated Ion Beam Identification Detector project

Created by Rikard Lundmark