Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/periodentafel.cpp

    • Property mode changed from 100644 to 100755
    r82cd9f rcc2ee5  
    11/** \file periodentafel.cpp
    2  * 
     2 *
    33 * Function implementations for the class periodentafel.
    4  * 
     4 *
    55 */
    66
     
    1414 * Initialises start and end of list and resets periodentafel::checkliste to false.
    1515 */
    16 periodentafel::periodentafel() 
    17 { 
    18   start = new element; 
    19   end = new element; 
    20   start->previous = NULL; 
    21   start->next = end; 
    22   end->previous = start; 
     16periodentafel::periodentafel()
     17{
     18  start = new element;
     19  end = new element;
     20  start->previous = NULL;
     21  start->next = end;
     22  end->previous = start;
    2323  end->next = NULL;
    2424};
     
    2727 * Removes every element and afterwards deletes start and end of list.
    2828 */
    29 periodentafel::~periodentafel() 
    30 { 
    31   CleanupPeriodtable(); 
    32   delete(end); 
    33   delete(start); 
    34 }; 
     29periodentafel::~periodentafel()
     30{
     31  CleanupPeriodtable();
     32  delete(end);
     33  delete(start);
     34};
    3535
    3636/** Adds element to period table list
     
    3838 * \return true - succeeded, false - does not occur
    3939 */
    40 bool periodentafel::AddElement(element *pointer) 
    41 { 
     40bool periodentafel::AddElement(element *pointer)
     41{
    4242  pointer->sort = &pointer->Z;
    4343  if (pointer->Z < 1 && pointer->Z >= MAX_ELEMENTS)
    4444    cout << Verbose(0) << "Invalid Z number!\n";
    45   return add(pointer, end); 
     45  return add(pointer, end);
    4646};
    4747
     
    5050 * \return true - succeeded, false - element not found
    5151 */
    52 bool periodentafel::RemoveElement(element *pointer) 
    53 { 
    54   return remove(pointer, start, end); 
     52bool periodentafel::RemoveElement(element *pointer)
     53{
     54  return remove(pointer, start, end);
    5555};
    5656
     
    5858 * \return true - succeeded, false - does not occur
    5959 */
    60 bool periodentafel::CleanupPeriodtable() 
    61 { 
    62   return cleanup(start,end); 
     60bool periodentafel::CleanupPeriodtable()
     61{
     62  return cleanup(start,end);
    6363};
    6464
     
    7676    cout << Verbose(0) << "Mass: " << endl;
    7777    cin >> walker->mass;
    78     walker->Z = Z; 
    79     cout << Verbose(0) << "Atomic number: " << walker->Z << endl; 
     78    walker->Z = Z;
     79    cout << Verbose(0) << "Atomic number: " << walker->Z << endl;
    8080    cout << Verbose(0) << "Name [max 64 chars]: " << endl;
    8181    cin >> walker->name;
     
    105105/** Asks for element number and returns pointer to element
    106106 */
    107 element * periodentafel::AskElement() 
     107element * periodentafel::AskElement()
    108108{
    109109  element *walker = NULL;
     
    117117};
    118118
    119 
    120119/** Prints period table to given stream.
    121120 * \param output stream
    122  */ 
     121 */
    123122bool periodentafel::Output(ofstream *output) const
    124123{
     
    131130    }
    132131    return result;
    133   } else 
     132  } else
    134133    return false;
    135134};
     
    138137 * \param *output output stream
    139138 * \param *checkliste elements table for this molecule
    140  */ 
     139 */
    141140bool periodentafel::Checkout(ofstream *output, const int *checkliste) const
    142141{
     
    152151      if ((walker != NULL) && (walker->Z > 0) && (walker->Z < MAX_ELEMENTS) && (checkliste[walker->Z])) {
    153152        walker->No = No;
    154         result = result && walker->Checkout(output, No++, checkliste[walker->Z]);     
     153        result = result && walker->Checkout(output, No++, checkliste[walker->Z]);
    155154      }
    156155    }
    157156    return result;
    158   } else 
     157  } else
    159158    return false;
    160159};
    161 
    162160
    163161/** Loads element list from file.
     
    171169  bool status = true;
    172170  bool otherstatus = true;
    173   char *filename = new char[MAXSTRINGSIZE];
    174  
     171  char filename[255];
     172
    175173  // fill elements DB
    176174  strncpy(filename, path, MAXSTRINGSIZE);
     
    225223  if (infile != NULL) {
    226224    while (!infile.eof()) {
    227         infile >> tmp;
    228         infile >> ws;
    229         infile >> FindElement((int)tmp)->Valence;
    230         infile >> ws;
    231         //cout << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->Valence << " valence electrons." << endl;
     225      infile >> tmp;
     226      infile >> ws;
     227      infile >> FindElement((int)tmp)->Valence;
     228      infile >> ws;
     229      //cout << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->Valence << " valence electrons." << endl;
    232230    }
    233231    infile.close();
     
    253251  } else
    254252    otherstatus = false;
    255  
     253
    256254  // fill H-BondDistance DB per element
    257255  strncpy(filename, path, MAXSTRINGSIZE);
     
    261259  if (infile != NULL) {
    262260    while (!infile.eof()) {
    263         infile >> tmp;
     261      infile >> tmp;
    264262      ptr = FindElement((int)tmp);
    265         infile >> ws;
     263      infile >> ws;
    266264      infile >> ptr->HBondDistance[0];
    267265      infile >> ptr->HBondDistance[1];
    268266      infile >> ptr->HBondDistance[2];
    269         infile >> ws;
     267      infile >> ws;
    270268      //cout << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->HBondDistance[0] << " Angstrom typical distance to hydrogen." << endl;
    271269    }
     
    274272  } else
    275273    otherstatus = false;
    276  
     274
    277275  // fill H-BondAngle DB per element
    278276  strncpy(filename, path, MAXSTRINGSIZE);
     
    294292  } else
    295293    otherstatus = false;
    296  
     294
    297295  if (!otherstatus)
    298     cerr << "ERROR: Something went wrong while parsing the databases!" << endl;
    299  
     296    cerr << "WARNING: Something went wrong while parsing the other databases!" << endl;
     297
    300298  return status;
    301299};
     
    308306  ofstream f;
    309307  char filename[MAXSTRINGSIZE];
    310  
     308
    311309  strncpy(filename, path, MAXSTRINGSIZE);
    312310  strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
Note: See TracChangeset for help on using the changeset viewer.