Changes in src/periodentafel.cpp [82cd9f:cc2ee5]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/periodentafel.cpp
-
Property mode
changed from
100644
to100755
r82cd9f rcc2ee5 1 1 /** \file periodentafel.cpp 2 * 2 * 3 3 * Function implementations for the class periodentafel. 4 * 4 * 5 5 */ 6 6 … … 14 14 * Initialises start and end of list and resets periodentafel::checkliste to false. 15 15 */ 16 periodentafel::periodentafel() 17 { 18 start = new element; 19 end = new element; 20 start->previous = NULL; 21 start->next = end; 22 end->previous = start; 16 periodentafel::periodentafel() 17 { 18 start = new element; 19 end = new element; 20 start->previous = NULL; 21 start->next = end; 22 end->previous = start; 23 23 end->next = NULL; 24 24 }; … … 27 27 * Removes every element and afterwards deletes start and end of list. 28 28 */ 29 periodentafel::~periodentafel() 30 { 31 CleanupPeriodtable(); 32 delete(end); 33 delete(start); 34 }; 29 periodentafel::~periodentafel() 30 { 31 CleanupPeriodtable(); 32 delete(end); 33 delete(start); 34 }; 35 35 36 36 /** Adds element to period table list … … 38 38 * \return true - succeeded, false - does not occur 39 39 */ 40 bool periodentafel::AddElement(element *pointer) 41 { 40 bool periodentafel::AddElement(element *pointer) 41 { 42 42 pointer->sort = &pointer->Z; 43 43 if (pointer->Z < 1 && pointer->Z >= MAX_ELEMENTS) 44 44 cout << Verbose(0) << "Invalid Z number!\n"; 45 return add(pointer, end); 45 return add(pointer, end); 46 46 }; 47 47 … … 50 50 * \return true - succeeded, false - element not found 51 51 */ 52 bool periodentafel::RemoveElement(element *pointer) 53 { 54 return remove(pointer, start, end); 52 bool periodentafel::RemoveElement(element *pointer) 53 { 54 return remove(pointer, start, end); 55 55 }; 56 56 … … 58 58 * \return true - succeeded, false - does not occur 59 59 */ 60 bool periodentafel::CleanupPeriodtable() 61 { 62 return cleanup(start,end); 60 bool periodentafel::CleanupPeriodtable() 61 { 62 return cleanup(start,end); 63 63 }; 64 64 … … 76 76 cout << Verbose(0) << "Mass: " << endl; 77 77 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; 80 80 cout << Verbose(0) << "Name [max 64 chars]: " << endl; 81 81 cin >> walker->name; … … 105 105 /** Asks for element number and returns pointer to element 106 106 */ 107 element * periodentafel::AskElement() 107 element * periodentafel::AskElement() 108 108 { 109 109 element *walker = NULL; … … 117 117 }; 118 118 119 120 119 /** Prints period table to given stream. 121 120 * \param output stream 122 */ 121 */ 123 122 bool periodentafel::Output(ofstream *output) const 124 123 { … … 131 130 } 132 131 return result; 133 } else 132 } else 134 133 return false; 135 134 }; … … 138 137 * \param *output output stream 139 138 * \param *checkliste elements table for this molecule 140 */ 139 */ 141 140 bool periodentafel::Checkout(ofstream *output, const int *checkliste) const 142 141 { … … 152 151 if ((walker != NULL) && (walker->Z > 0) && (walker->Z < MAX_ELEMENTS) && (checkliste[walker->Z])) { 153 152 walker->No = No; 154 result = result && walker->Checkout(output, No++, checkliste[walker->Z]); 153 result = result && walker->Checkout(output, No++, checkliste[walker->Z]); 155 154 } 156 155 } 157 156 return result; 158 } else 157 } else 159 158 return false; 160 159 }; 161 162 160 163 161 /** Loads element list from file. … … 171 169 bool status = true; 172 170 bool otherstatus = true; 173 char *filename = new char[MAXSTRINGSIZE];174 171 char filename[255]; 172 175 173 // fill elements DB 176 174 strncpy(filename, path, MAXSTRINGSIZE); … … 225 223 if (infile != NULL) { 226 224 while (!infile.eof()) { 227 228 229 230 231 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; 232 230 } 233 231 infile.close(); … … 253 251 } else 254 252 otherstatus = false; 255 253 256 254 // fill H-BondDistance DB per element 257 255 strncpy(filename, path, MAXSTRINGSIZE); … … 261 259 if (infile != NULL) { 262 260 while (!infile.eof()) { 263 261 infile >> tmp; 264 262 ptr = FindElement((int)tmp); 265 263 infile >> ws; 266 264 infile >> ptr->HBondDistance[0]; 267 265 infile >> ptr->HBondDistance[1]; 268 266 infile >> ptr->HBondDistance[2]; 269 267 infile >> ws; 270 268 //cout << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->HBondDistance[0] << " Angstrom typical distance to hydrogen." << endl; 271 269 } … … 274 272 } else 275 273 otherstatus = false; 276 274 277 275 // fill H-BondAngle DB per element 278 276 strncpy(filename, path, MAXSTRINGSIZE); … … 294 292 } else 295 293 otherstatus = false; 296 294 297 295 if (!otherstatus) 298 cerr << " ERROR: Something went wrong while parsing thedatabases!" << endl;299 296 cerr << "WARNING: Something went wrong while parsing the other databases!" << endl; 297 300 298 return status; 301 299 }; … … 308 306 ofstream f; 309 307 char filename[MAXSTRINGSIZE]; 310 308 311 309 strncpy(filename, path, MAXSTRINGSIZE); 312 310 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename)); -
Property mode
changed from
Note:
See TracChangeset
for help on using the changeset viewer.