Changes in src/periodentafel.cpp [cc2ee5:82cd9f]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/periodentafel.cpp
-
Property mode
changed from
100755
to100644
rcc2ee5 r82cd9f 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 119 120 /** Prints period table to given stream. 120 121 * \param output stream 121 */ 122 */ 122 123 bool periodentafel::Output(ofstream *output) const 123 124 { … … 130 131 } 131 132 return result; 132 } else 133 } else 133 134 return false; 134 135 }; … … 137 138 * \param *output output stream 138 139 * \param *checkliste elements table for this molecule 139 */ 140 */ 140 141 bool periodentafel::Checkout(ofstream *output, const int *checkliste) const 141 142 { … … 151 152 if ((walker != NULL) && (walker->Z > 0) && (walker->Z < MAX_ELEMENTS) && (checkliste[walker->Z])) { 152 153 walker->No = No; 153 result = result && walker->Checkout(output, No++, checkliste[walker->Z]); 154 result = result && walker->Checkout(output, No++, checkliste[walker->Z]); 154 155 } 155 156 } 156 157 return result; 157 } else 158 } else 158 159 return false; 159 160 }; 161 160 162 161 163 /** Loads element list from file. … … 169 171 bool status = true; 170 172 bool otherstatus = true; 171 char filename[255];172 173 char *filename = new char[MAXSTRINGSIZE]; 174 173 175 // fill elements DB 174 176 strncpy(filename, path, MAXSTRINGSIZE); … … 223 225 if (infile != NULL) { 224 226 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; 232 } 233 infile.close(); 234 infile.clear(); 235 } else 236 otherstatus = false; 237 238 // fill valence DB per element 239 strncpy(filename, path, MAXSTRINGSIZE); 240 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename)); 241 strncat(filename, STANDARDORBITALDB, MAXSTRINGSIZE-strlen(filename)); 242 infile.open(filename); 243 if (infile != NULL) { 244 while (!infile.eof()) { 225 245 infile >> tmp; 226 246 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;247 infile >> FindElement((int)tmp)->NoValenceOrbitals; 248 infile >> ws; 249 //cout << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->NoValenceOrbitals << " number of singly occupied valence orbitals." << endl; 230 250 } 231 251 infile.close(); … … 233 253 } else 234 254 otherstatus = false; 235 236 // fill valence DB per element 237 strncpy(filename, path, MAXSTRINGSIZE); 238 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename)); 239 strncat(filename, STANDARDORBITALDB, MAXSTRINGSIZE-strlen(filename)); 240 infile.open(filename); 241 if (infile != NULL) { 242 while (!infile.eof()) { 243 infile >> tmp; 244 infile >> ws; 245 infile >> FindElement((int)tmp)->NoValenceOrbitals; 246 infile >> ws; 247 //cout << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->NoValenceOrbitals << " number of singly occupied valence orbitals." << endl; 248 } 249 infile.close(); 250 infile.clear(); 251 } else 252 otherstatus = false; 253 255 254 256 // fill H-BondDistance DB per element 255 257 strncpy(filename, path, MAXSTRINGSIZE); … … 259 261 if (infile != NULL) { 260 262 while (!infile.eof()) { 261 263 infile >> tmp; 262 264 ptr = FindElement((int)tmp); 263 265 infile >> ws; 264 266 infile >> ptr->HBondDistance[0]; 265 267 infile >> ptr->HBondDistance[1]; 266 268 infile >> ptr->HBondDistance[2]; 267 269 infile >> ws; 268 270 //cout << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->HBondDistance[0] << " Angstrom typical distance to hydrogen." << endl; 269 271 } … … 272 274 } else 273 275 otherstatus = false; 274 276 275 277 // fill H-BondAngle DB per element 276 278 strncpy(filename, path, MAXSTRINGSIZE); … … 292 294 } else 293 295 otherstatus = false; 294 296 295 297 if (!otherstatus) 296 cerr << " WARNING: Something went wrong while parsing the otherdatabases!" << endl;297 298 cerr << "ERROR: Something went wrong while parsing the databases!" << endl; 299 298 300 return status; 299 301 }; … … 306 308 ofstream f; 307 309 char filename[MAXSTRINGSIZE]; 308 310 309 311 strncpy(filename, path, MAXSTRINGSIZE); 310 312 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename)); -
Property mode
changed from
Note:
See TracChangeset
for help on using the changeset viewer.