Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/molecule_graph.cpp

    r112b09 r35b698  
    1212#include "bondgraph.hpp"
    1313#include "config.hpp"
     14#include "defs.hpp"
    1415#include "element.hpp"
    1516#include "helpers.hpp"
     
    10241025/** Storing the bond structure of a molecule to file.
    10251026 * Simply stores Atom::nr and then the Atom::nr of all bond partners per line.
    1026  * \param *path path to file
    1027  * \param *filename name of file
     1027 * \param &filename name of file
     1028 * \param path path to file, defaults to empty
    10281029 * \return true - file written successfully, false - writing failed
    10291030 */
    1030 bool molecule::StoreAdjacencyToFile(char *path, char *filename)
     1031bool molecule::StoreAdjacencyToFile(std::string &filename, std::string path)
    10311032{
    10321033  ofstream AdjacencyFile;
    1033   stringstream line;
     1034  string line;
    10341035  bool status = true;
    10351036
    1036   if (path != NULL)
    1037     line << path << "/" << filename;
     1037  if (path != "")
     1038    line = path + "/" + filename;
    10381039  else
    1039     line << filename;
    1040   AdjacencyFile.open(line.str().c_str(), ios::out);
     1040    line = filename;
     1041  AdjacencyFile.open(line.c_str(), ios::out);
    10411042  DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... " << endl);
    1042   if (AdjacencyFile != NULL) {
     1043  if (AdjacencyFile.good()) {
    10431044    AdjacencyFile << "m\tn" << endl;
    10441045    ActOnAllAtoms(&atom::OutputAdjacency, &AdjacencyFile);
     
    10461047    DoLog(1) && (Log() << Verbose(1) << "\t... done." << endl);
    10471048  } else {
    1048     DoLog(1) && (Log() << Verbose(1) << "\t... failed to open file " << line.str() << "." << endl);
     1049    DoLog(1) && (Log() << Verbose(1) << "\t... failed to open file " << line << "." << endl);
    10491050    status = false;
    10501051  }
     
    10561057/** Storing the bond structure of a molecule to file.
    10571058 * Simply stores Atom::nr and then the Atom::nr of all bond partners, one per line.
    1058  * \param *path path to file
    1059  * \param *filename name of file
     1059 * \param &filename name of file
     1060 * \param path path to file, defaults to empty
    10601061 * \return true - file written successfully, false - writing failed
    10611062 */
    1062 bool molecule::StoreBondsToFile(char *path, char *filename)
     1063bool molecule::StoreBondsToFile(std::string &filename, std::string path)
    10631064{
    10641065  ofstream BondFile;
    1065   stringstream line;
     1066  string line;
    10661067  bool status = true;
    10671068
    1068   if (path != NULL)
    1069     line << path << "/" << filename;
     1069  if (path != "")
     1070    line = path + "/" + filename;
    10701071  else
    1071     line << filename;
    1072   BondFile.open(line.str().c_str(), ios::out);
     1072    line = filename;
     1073  BondFile.open(line.c_str(), ios::out);
    10731074  DoLog(1) && (Log() << Verbose(1) << "Saving adjacency list ... " << endl);
    1074   if (BondFile != NULL) {
     1075  if (BondFile.good()) {
    10751076    BondFile << "m\tn" << endl;
    10761077    ActOnAllAtoms(&atom::OutputBonds, &BondFile);
     
    10781079    DoLog(1) && (Log() << Verbose(1) << "\t... done." << endl);
    10791080  } else {
    1080     DoLog(1) && (Log() << Verbose(1) << "\t... failed to open file " << line.str() << "." << endl);
     1081    DoLog(1) && (Log() << Verbose(1) << "\t... failed to open file " << line << "." << endl);
    10811082    status = false;
    10821083  }
     
    10861087;
    10871088
    1088 bool CheckAdjacencyFileAgainstMolecule_Init(char *path, ifstream &File, int *&CurrentBonds)
    1089 {
    1090   stringstream filename;
    1091   filename << path << "/" << FRAGMENTPREFIX << ADJACENCYFILE;
    1092   File.open(filename.str().c_str(), ios::out);
     1089bool CheckAdjacencyFileAgainstMolecule_Init(std::string &path, ifstream &File, int *&CurrentBonds)
     1090{
     1091  string filename;
     1092  filename = path + ADJACENCYFILE;
     1093  File.open(filename.c_str(), ios::out);
    10931094  DoLog(1) && (Log() << Verbose(1) << "Looking at bond structure stored in adjacency file and comparing to present one ... " << endl);
    1094   if (File == NULL)
     1095  if (File.fail())
    10951096    return false;
    10961097
     
    11461147 * \return true - structure is equal, false - not equivalence
    11471148 */
    1148 bool molecule::CheckAdjacencyFileAgainstMolecule(char *path, atom **ListOfAtoms)
     1149bool molecule::CheckAdjacencyFileAgainstMolecule(std::string &path, atom **ListOfAtoms)
    11491150{
    11501151  ifstream File;
Note: See TracChangeset for help on using the changeset viewer.