1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
//
// Copyright (C) 2018 Susan H. Leung
//
// @@ 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 "TautomerCatalogEntry.h"
#include <RDGeneral/types.h>
#include <RDGeneral/utils.h>
#include <GraphMol/RDKitBase.h>
#include <RDGeneral/StreamOps.h>
#include <iostream>
#include <fstream>
namespace RDKit {
namespace MolStandardize {
void TautomerCatalogEntry::toStream(std::ostream &ss) const {
// ReactionPickler::pickleReaction(*dp_transform, ss);
boost::int32_t tmpInt;
tmpInt = getBitId();
streamWrite(ss, tmpInt);
tmpInt = d_descrip.size();
streamWrite(ss, tmpInt);
ss.write(d_descrip.c_str(), tmpInt * sizeof(char));
}
std::string TautomerCatalogEntry::Serialize() const {
std::stringstream ss(std::ios_base::binary | std::ios_base::out |
std::ios_base::in);
toStream(ss);
return ss.str();
}
void TautomerCatalogEntry::initFromStream(std::istream &ss) {
// the tautomer TODO:
dp_transform = new TautomerTransform(nullptr, std::vector<Bond::BondType>(),
std::vector<int>());
// ReactionPickler::reactionFromPickle(ss, *dp_transform);
boost::int32_t tmpInt;
// the bitId:
streamRead(ss, tmpInt);
setBitId(tmpInt);
// the description:
streamRead(ss, tmpInt);
char *tmpText = new char[tmpInt + 1];
ss.read(tmpText, tmpInt * sizeof(char));
tmpText[tmpInt] = 0;
d_descrip = tmpText;
delete[] tmpText;
}
void TautomerCatalogEntry::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 MolStandardize
} // namespace RDKit
|