// $Id$ // // Copyright (C) 2006-2008 Greg Landrum // // @@ All Rights Reserved @@ // This file is part of the RDKit. // The contents are covered by the terms of the BSD license // which is included in the file license.txt, found at the root // of the RDKit source tree. // #include "MolCatalogEntry.h" #include #include #include #include #include #include #include namespace RDKit { MolCatalogEntry::MolCatalogEntry(const ROMol *omol) { PRECONDITION(omol, "bad mol"); setBitId(-1); dp_props = new Dict(); d_descrip = ""; dp_mol = omol; d_order = 0; } MolCatalogEntry::MolCatalogEntry(const MolCatalogEntry &other) { setBitId(other.getBitId()); d_descrip = other.d_descrip; dp_props = nullptr; dp_mol = nullptr; if (other.dp_props) { dp_props = new Dict(*other.dp_props); } if (other.dp_mol) { dp_mol = new ROMol(*other.dp_mol); } d_order = other.d_order; } MolCatalogEntry::~MolCatalogEntry() { // std::cerr << "mce: " << dp_mol <<" " <(dp_mol)); dp_props = new Dict(); std::int32_t tmpInt; // the bitId: streamRead(ss, tmpInt); setBitId(tmpInt); // the order: streamRead(ss, tmpInt); setOrder(tmpInt); // the description: streamRead(ss, tmpInt); auto *tmpText = new char[tmpInt + 1]; ss.read(tmpText, tmpInt * sizeof(char)); tmpText[tmpInt] = 0; d_descrip = tmpText; delete[] tmpText; } void MolCatalogEntry::initFromString(const std::string &text) { std::stringstream ss(std::ios_base::binary | std::ios_base::out | std::ios_base::in); // initialize the stream: ss.write(text.c_str(), text.length()); // now start reading out values: initFromStream(ss); } } // namespace RDKit