source: src/periodentafel.cpp@ 586055

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since 586055 was 9f99b3, checked in by Frederik Heber <heber@…>, 14 years ago

MEMFIX: periodentafel::LoadElementsDatabase() leaked memory.

  • if element was replaced by one from parsedElements, the content was copied, but the allocated element in the map not deleted.
  • Property mode set to 100755
File size: 15.3 KB
RevLine 
[bcf653]1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010 University of Bonn. All rights reserved.
5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
6 */
7
[6ac7ee]8/** \file periodentafel.cpp
9 *
10 * Function implementations for the class periodentafel.
11 *
12 */
13
[bf3817]14// include config.h
15#ifdef HAVE_CONFIG_H
16#include <config.h>
17#endif
[112b09]18
[bbbad5]19#include "Helpers/MemDebug.hpp"
[6ac7ee]20
[cd4ccc]21#include <iomanip>
[4eb4fe]22#include <iostream>
[cd4ccc]23#include <fstream>
[49e1ae]24#include <cstring>
[cd4ccc]25
[4eb4fe]26#include "Helpers/Assert.hpp"
[f66195]27#include "element.hpp"
[4eb4fe]28#include "elements_db.hpp"
[952f38]29#include "Helpers/helpers.hpp"
[f66195]30#include "lists.hpp"
[952f38]31#include "Helpers/Log.hpp"
[6ac7ee]32#include "periodentafel.hpp"
[952f38]33#include "Helpers/Verbose.hpp"
[6ac7ee]34
[ead4e6]35using namespace std;
36
[6ac7ee]37/************************************* Functions for class periodentafel ***************************/
38
39/** constructor for class periodentafel
40 * Initialises start and end of list and resets periodentafel::checkliste to false.
41 */
[ead4e6]42periodentafel::periodentafel()
[4eb4fe]43{
[f34c23]44 {
45 stringstream input(elementsDB,ios_base::in);
[e5c0a1]46 bool status = LoadElementsDatabase(input);
[f34c23]47 ASSERT(status, "General element initialization failed");
48 }
49 {
50 stringstream input(valenceDB,ios_base::in);
51 bool status = LoadValenceDatabase(&input);
52 ASSERT(status, "Valence entry of element initialization failed");
53 }
54 {
55 stringstream input(orbitalsDB,ios_base::in);
56 bool status = LoadOrbitalsDatabase(&input);
57 ASSERT(status, "Orbitals entry of element initialization failed");
58 }
59 {
60 stringstream input(HbondangleDB,ios_base::in);
61 bool status = LoadHBondAngleDatabase(&input);
62 ASSERT(status, "HBond angle entry of element initialization failed");
63 }
64 {
65 stringstream input(HbonddistanceDB,ios_base::in);
66 bool status = LoadHBondLengthsDatabase(&input);
67 ASSERT(status, "HBond distance entry of element initialization failed");
68 }
[4eb4fe]69};
[6ac7ee]70
71/** destructor for class periodentafel
72 * Removes every element and afterwards deletes start and end of list.
[42af9e]73 * TODO: Handle when elements have changed and store databases then
[6ac7ee]74 */
75periodentafel::~periodentafel()
76{
[042f82]77 CleanupPeriodtable();
[6ac7ee]78};
79
80/** Adds element to period table list
81 * \param *pointer element to be added
[4eb4fe]82 * \return iterator to added element
[6ac7ee]83 */
[e5c0a1]84periodentafel::iterator periodentafel::AddElement(element * pointer)
[6ac7ee]85{
[ead4e6]86 atomicNumber_t Z = pointer->getNumber();
[4eb4fe]87 ASSERT(!elements.count(Z), "Element is already present.");
[ead4e6]88 if (pointer->getNumber() < 1 && pointer->getNumber() >= MAX_ELEMENTS)
[5f612ee]89 DoeLog(0) && (eLog() << Verbose(0) << "Invalid Z number!\n");
[ead4e6]90 pair<iterator,bool> res = elements.insert(pair<atomicNumber_t,element*>(Z,pointer));
91 return res.first;
[6ac7ee]92};
93
94/** Removes element from list.
95 * \param *pointer element to be removed
96 */
[e5c0a1]97size_t periodentafel::RemoveElement(const element * pointer)
[6ac7ee]98{
[61745cc]99 return RemoveElement(pointer->getNumber());
[4eb4fe]100};
101
102/** Removes element from list.
103 * \param Z element to be removed
104 */
[61745cc]105size_t periodentafel::RemoveElement(atomicNumber_t Z)
[4eb4fe]106{
[61745cc]107 return elements.erase(Z);
[6ac7ee]108};
109
110/** Removes every element from the period table.
111 */
[ead4e6]112void periodentafel::CleanupPeriodtable()
[6ac7ee]113{
[745a85]114 for(iterator iter=elements.begin();iter!=elements.end();++iter){
115 delete(*iter).second;
116 }
[ead4e6]117 elements.clear();
[6ac7ee]118};
119
120/** Finds an element by its atomic number.
[fb73b8]121 * If element is not yet in list, returns NULL.
[6ac7ee]122 * \param Z atomic number
[fb73b8]123 * \return pointer to element or NULL if not found
[6ac7ee]124 */
[e5c0a1]125const element * periodentafel::FindElement(atomicNumber_t Z) const
[6ac7ee]126{
[ead4e6]127 const_iterator res = elements.find(Z);
128 return res!=elements.end()?((*res).second):0;
[6ac7ee]129};
130
131/** Finds an element by its atomic number.
132 * If element is not yet in list, datas are asked and stored in database.
133 * \param shorthand chemical symbol of the element, e.g. H for hydrogene
134 * \return pointer to element
135 */
[e5c0a1]136const element * periodentafel::FindElement(const string &shorthand) const
[6ac7ee]137{
[ead4e6]138 element *res = 0;
139 for(const_iterator iter=elements.begin();iter!=elements.end();++iter) {
140 if((*iter).second->getSymbol() == shorthand){
141 res = (*iter).second;
142 break;
143 }
[042f82]144 }
[ead4e6]145 return res;
[6ac7ee]146};
147
148/** Asks for element number and returns pointer to element
[4eb4fe]149 * \return desired element or NULL
[6ac7ee]150 */
[e5c0a1]151const element * periodentafel::AskElement() const
[6ac7ee]152{
[e5c0a1]153 const element * walker = NULL;
[042f82]154 int Z;
155 do {
[a67d19]156 DoLog(0) && (Log() << Verbose(0) << "Atomic number Z: ");
[042f82]157 cin >> Z;
158 walker = this->FindElement(Z); // give type
159 } while (walker == NULL);
160 return walker;
[6ac7ee]161};
162
[fb73b8]163/** Asks for element and if not found, presents mask to enter info.
164 * \return pointer to either present or newly created element
165 */
[e5c0a1]166const element * periodentafel::EnterElement()
[fb73b8]167{
[ead4e6]168 atomicNumber_t Z = 0;
[a67d19]169 DoLog(0) && (Log() << Verbose(0) << "Atomic number: " << Z << endl);
[fb73b8]170 cin >> Z;
[e5c0a1]171 const element *res = FindElement(Z);
[ead4e6]172 if (!res) {
173 // TODO: make this using the constructor
[a67d19]174 DoLog(0) && (Log() << Verbose(0) << "Element not found in database, please enter." << endl);
[4eb4fe]175 element *tmp = new element;
[ead4e6]176 tmp->Z = Z;
[a67d19]177 DoLog(0) && (Log() << Verbose(0) << "Mass: " << endl);
[ead4e6]178 cin >> tmp->mass;
[a67d19]179 DoLog(0) && (Log() << Verbose(0) << "Name [max 64 chars]: " << endl);
[7e3fc94]180 cin >> tmp->getName();
[a67d19]181 DoLog(0) && (Log() << Verbose(0) << "Short form [max 3 chars]: " << endl);
[7e3fc94]182 cin >> tmp->getSymbol();
[ead4e6]183 AddElement(tmp);
[4eb4fe]184 return tmp;
[fb73b8]185 }
[ead4e6]186 return res;
[fb73b8]187};
188
[ead4e6]189
190/******************** Access to iterators ****************************/
[e5c0a1]191periodentafel::const_iterator periodentafel::begin() const{
[ead4e6]192 return elements.begin();
193}
194
[e5c0a1]195periodentafel::const_iterator periodentafel::end() const{
[ead4e6]196 return elements.end();
197}
198
[e5c0a1]199periodentafel::reverse_iterator periodentafel::rbegin() const{
[ead4e6]200 return reverse_iterator(elements.end());
201}
202
[e5c0a1]203periodentafel::reverse_iterator periodentafel::rend() const{
[ead4e6]204 return reverse_iterator(elements.begin());
205}
206
[6ac7ee]207/** Prints period table to given stream.
208 * \param output stream
209 */
[ead4e6]210bool periodentafel::Output(ostream * const output) const
[6ac7ee]211{
[042f82]212 bool result = true;
213 if (output != NULL) {
[ead4e6]214 for(const_iterator iter=elements.begin(); iter !=elements.end();++iter){
215 result = result && (*iter).second->Output(output);
[042f82]216 }
217 return result;
218 } else
219 return false;
[6ac7ee]220};
221
222/** Loads element list from file.
223 * \param *path to to standard file names
224 */
[989bf6]225bool periodentafel::LoadPeriodentafel(const char *path)
[6ac7ee]226{
[4eb4fe]227 ifstream input;
[042f82]228 bool status = true;
229 bool otherstatus = true;
230 char filename[255];
[6ac7ee]231
[042f82]232 // fill elements DB
233 strncpy(filename, path, MAXSTRINGSIZE);
234 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
235 strncat(filename, STANDARDELEMENTSDB, MAXSTRINGSIZE-strlen(filename));
[4eb4fe]236 input.open(filename);
[61745cc]237 if (!input.fail())
238 DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as elements database." << endl);
[e5c0a1]239 status = status && LoadElementsDatabase(input);
[61745cc]240 input.close();
241 input.clear();
[4eb4fe]242
243 // fill valence DB per element
244 strncpy(filename, path, MAXSTRINGSIZE);
245 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
246 strncat(filename, STANDARDVALENCEDB, MAXSTRINGSIZE-strlen(filename));
247 input.open(filename);
[61745cc]248 if (!input.fail())
249 DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as valence database." << endl);
[4eb4fe]250 otherstatus = otherstatus && LoadValenceDatabase(&input);
[61745cc]251 input.close();
252 input.clear();
[4eb4fe]253
254 // fill orbitals DB per element
255 strncpy(filename, path, MAXSTRINGSIZE);
256 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
257 strncat(filename, STANDARDORBITALDB, MAXSTRINGSIZE-strlen(filename));
258 input.open(filename);
[61745cc]259 if (!input.fail())
260 DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as orbitals database." << endl);
[4eb4fe]261 otherstatus = otherstatus && LoadOrbitalsDatabase(&input);
[61745cc]262 input.close();
263 input.clear();
[4eb4fe]264
265 // fill H-BondAngle DB per element
266 strncpy(filename, path, MAXSTRINGSIZE);
267 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
268 strncat(filename, STANDARDHBONDANGLEDB, MAXSTRINGSIZE-strlen(filename));
269 input.open(filename);
[61745cc]270 if (!input.fail())
271 DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as H bond angle database." << endl);
[4eb4fe]272 otherstatus = otherstatus && LoadHBondAngleDatabase(&input);
[61745cc]273 input.close();
274 input.clear();
[4eb4fe]275
276 // fill H-BondDistance DB per element
277 strncpy(filename, path, MAXSTRINGSIZE);
278 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
279 strncat(filename, STANDARDHBONDDISTANCEDB, MAXSTRINGSIZE-strlen(filename));
280 input.open(filename);
[61745cc]281 if (!input.fail())
282 DoLog(0) && (Log() << Verbose(0) << "Using " << filename << " as H bond length database." << endl);
[4eb4fe]283 otherstatus = otherstatus && LoadHBondLengthsDatabase(&input);
[61745cc]284 input.close();
285 input.clear();
[4eb4fe]286
287 if (!otherstatus){
288 DoeLog(2) && (eLog()<< Verbose(2) << "Something went wrong while parsing the other databases!" << endl);
289 }
290
291 return status;
292};
293
294/** load the element info.
295 * \param *input stream to parse from
296 * \return true - parsing successful, false - something went wrong
297 */
[e5c0a1]298bool periodentafel::LoadElementsDatabase(istream &input)
[4eb4fe]299{
[ff73a2]300 bool status = true;
[e5c0a1]301 string header1tmp,header2tmp;
302 // first parse into a map, so we can revert to old status in case something goes wront
303 map<atomicNumber_t,element*> parsedElements;
304 if (!input.fail()) {
305 getline(input,header1tmp);
306 getline(input,header2tmp); // skip first two header lines
[4e6d74]307 //cout << "First header: " << header1tmp << endl;
308 //cout << "Second header: " << header2tmp << endl;
[a67d19]309 DoLog(0) && (Log() << Verbose(0) << "Parsed elements:");
[e5c0a1]310 while (!input.eof()) {
[042f82]311 element *neues = new element;
[83f176]312 input >> neues->name;
[4eb4fe]313 //(*input) >> ws;
[83f176]314 input >> neues->symbol;
[4eb4fe]315 //(*input) >> ws;
[e5c0a1]316 input >> neues->period;
[4eb4fe]317 //(*input) >> ws;
[e5c0a1]318 input >> neues->group;
[4eb4fe]319 //(*input) >> ws;
[e5c0a1]320 input >> neues->block;
[4eb4fe]321 //(*input) >> ws;
[e5c0a1]322 input >> neues->Z;
[4eb4fe]323 //(*input) >> ws;
[e5c0a1]324 input >> neues->mass;
[4eb4fe]325 //(*input) >> ws;
[e5c0a1]326 input >> neues->CovalentRadius;
[4eb4fe]327 //(*input) >> ws;
[e5c0a1]328 input >> neues->VanDerWaalsRadius;
[4eb4fe]329 //(*input) >> ws;
[e5c0a1]330 input >> ws;
[042f82]331 //neues->Output((ofstream *)&cout);
[61745cc]332 if ((neues->getNumber() > 0) && (neues->getNumber() < MAX_ELEMENTS)) {
[e5c0a1]333 parsedElements[neues->Z] = neues;
[2fe971]334 DoLog(0) && (Log() << Verbose(0) << " " << *neues);
[ff73a2]335 } else {
336 DoeLog(2) && (eLog() << Verbose(2) << "Detected empty line or invalid element in elements db, discarding." << endl);
337 DoLog(0) && (Log() << Verbose(0) << " <?>");
[db6bf74]338 delete(neues);
[042f82]339 }
[e5c0a1]340 // when the input is in failed state, we most likely just read garbage
341 if(input.fail()) {
342 DoeLog(2) && (eLog() << Verbose(2) << "Error parsing elements db." << endl);
343 status = false;
344 break;
345 }
[042f82]346 }
[a67d19]347 DoLog(0) && (Log() << Verbose(0) << endl);
[61745cc]348 } else {
349 DoeLog(1) && (eLog() << Verbose(1) << "Could not open the database." << endl);
[ff73a2]350 status = false;
[61745cc]351 }
[ff73a2]352
[e5c0a1]353 if (!parsedElements.size())
[ff73a2]354 status = false;
355
[e5c0a1]356 if(status){
357 for(map<atomicNumber_t,element*>::iterator iter=parsedElements.begin();
358 iter!=parsedElements.end();
359 ++iter){
360 if (elements.count(iter->first)) {
361 // if element already present, replace the old one
362 // pointer to old element might still be in use, so we have to replace into the old element
363 *(elements[iter->first])=*iter->second;
[9f99b3]364 delete(iter->second);
[e5c0a1]365 }
366 else {
367 // no such element in periodentafel... we can just insert
368 elements[iter->first] = iter->second;
369 }
370 }
371 // all went well.. we now copy the header
372 strncpy(header1,header1tmp.c_str(),MAXSTRINGSIZE);
373 header1[MAXSTRINGSIZE-1]=0;
374 strncpy(header2,header2tmp.c_str(),MAXSTRINGSIZE);
375 header2[MAXSTRINGSIZE-1]=0;
376 }
377
[ff73a2]378 return status;
[4eb4fe]379}
[6ac7ee]380
[4eb4fe]381/** load the valence info.
382 * \param *input stream to parse from
383 * \return true - parsing successful, false - something went wrong
384 */
385bool periodentafel::LoadValenceDatabase(istream *input)
386{
387 char dummy[MAXSTRINGSIZE];
[ff73a2]388 if (!(*input).fail()) {
[4eb4fe]389 (*input).getline(dummy, MAXSTRINGSIZE);
390 while (!(*input).eof()) {
[ead4e6]391 atomicNumber_t Z;
[4eb4fe]392 (*input) >> Z;
393 ASSERT(elements.count(Z), "Element not present");
394 (*input) >> ws;
395 (*input) >> elements[Z]->Valence;
396 (*input) >> ws;
[274d45]397 //Log() << Verbose(3) << "Element " << Z << " has " << FindElement(Z)->Valence << " valence electrons." << endl;
[042f82]398 }
[4eb4fe]399 return true;
[042f82]400 } else
[4eb4fe]401 return false;
402}
[6ac7ee]403
[4eb4fe]404/** load the orbitals info.
405 * \param *input stream to parse from
406 * \return true - parsing successful, false - something went wrong
407 */
408bool periodentafel::LoadOrbitalsDatabase(istream *input)
409{
410 char dummy[MAXSTRINGSIZE];
[ff73a2]411 if (!(*input).fail()) {
[4eb4fe]412 (*input).getline(dummy, MAXSTRINGSIZE);
413 while (!(*input).eof()) {
[ead4e6]414 atomicNumber_t Z;
[4eb4fe]415 (*input) >> Z;
416 ASSERT(elements.count(Z), "Element not present");
417 (*input) >> ws;
418 (*input) >> elements[Z]->NoValenceOrbitals;
419 (*input) >> ws;
[274d45]420 //Log() << Verbose(3) << "Element " << Z << " has " << FindElement(Z)->NoValenceOrbitals << " number of singly occupied valence orbitals." << endl;
[042f82]421 }
[4eb4fe]422 return true;
[042f82]423 } else
[4eb4fe]424 return false;
425}
[6ac7ee]426
[4eb4fe]427/** load the hbond angles info.
428 * \param *input stream to parse from
429 * \return true - parsing successful, false - something went wrong
430 */
431bool periodentafel::LoadHBondAngleDatabase(istream *input)
432{
433 char dummy[MAXSTRINGSIZE];
[ff73a2]434 if (!(*input).fail()) {
[4eb4fe]435 (*input).getline(dummy, MAXSTRINGSIZE);
436 while (!(*input).eof()) {
[ead4e6]437 atomicNumber_t Z;
[4eb4fe]438 (*input) >> Z;
439 ASSERT(elements.count(Z), "Element not present");
440 (*input) >> ws;
441 (*input) >> elements[Z]->HBondAngle[0];
442 (*input) >> elements[Z]->HBondAngle[1];
443 (*input) >> elements[Z]->HBondAngle[2];
444 (*input) >> ws;
445 //Log() << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->HBondAngle[0] << ", " << FindElement((int)tmp)->HBondAngle[1] << ", " << FindElement((int)tmp)->HBondAngle[2] << " degrees bond angle for one, two, three connected hydrogens." << endl;
[042f82]446 }
[4eb4fe]447 return true;
[042f82]448 } else
[4eb4fe]449 return false;
450}
[6ac7ee]451
[4eb4fe]452/** load the hbond lengths info.
453 * \param *input stream to parse from
454 * \return true - parsing successful, false - something went wrong
455 */
456bool periodentafel::LoadHBondLengthsDatabase(istream *input)
457{
458 char dummy[MAXSTRINGSIZE];
[ff73a2]459 if (!(*input).fail()) {
[4eb4fe]460 (*input).getline(dummy, MAXSTRINGSIZE);
461 while (!(*input).eof()) {
[ead4e6]462 atomicNumber_t Z;
[4eb4fe]463 (*input) >> Z;
464 ASSERT(elements.count(Z), "Element not present");
465 (*input) >> ws;
466 (*input) >> elements[Z]->HBondDistance[0];
467 (*input) >> elements[Z]->HBondDistance[1];
468 (*input) >> elements[Z]->HBondDistance[2];
469 (*input) >> ws;
470 //Log() << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->HBondDistance[0] << " Angstrom typical distance to hydrogen." << endl;
[042f82]471 }
[4eb4fe]472 return true;
[042f82]473 } else
[4eb4fe]474 return false;
475}
[6ac7ee]476
477/** Stores element list to file.
478 */
[989bf6]479bool periodentafel::StorePeriodentafel(const char *path) const
[6ac7ee]480{
[042f82]481 bool result = true;
482 ofstream f;
483 char filename[MAXSTRINGSIZE];
[6ac7ee]484
[042f82]485 strncpy(filename, path, MAXSTRINGSIZE);
486 strncat(filename, "/", MAXSTRINGSIZE-strlen(filename));
487 strncat(filename, STANDARDELEMENTSDB, MAXSTRINGSIZE-strlen(filename));
488 f.open(filename);
489 if (f != NULL) {
490 f << header1 << endl;
491 f << header2 << endl;
[ead4e6]492 for(const_iterator iter=elements.begin();iter!=elements.end();++iter){
493 result = result && (*iter).second->Output(&f);
[042f82]494 }
495 f.close();
[4eb4fe]496 return true;
[042f82]497 } else
[4eb4fe]498 return result;
[6ac7ee]499};
Note: See TracBrowser for help on using the repository browser.