Commit aaf25de2 by maarten

reorganizing

git-svn-id: svn+ssh://gitlab/srv/svn-repos/pdb-redo/trunk@426 a1961a4f-ab94-4bcc-80e8-33b5a54de466
parent 0cbb927b
...@@ -10,8 +10,6 @@ ...@@ -10,8 +10,6 @@
#include <boost/filesystem/fstream.hpp> #include <boost/filesystem/fstream.hpp>
#include <boost/thread.hpp> #include <boost/thread.hpp>
#include <zeep/xml/document.hpp>
#include "cif++/Cif++.h" #include "cif++/Cif++.h"
#include "cif++/Point.h" #include "cif++/Point.h"
#include "cif++/Compound.h" #include "cif++/Compound.h"
...@@ -20,7 +18,6 @@ ...@@ -20,7 +18,6 @@
using namespace std; using namespace std;
namespace ba = boost::algorithm; namespace ba = boost::algorithm;
namespace fs = boost::filesystem; namespace fs = boost::filesystem;
namespace zx = zeep::xml;
namespace mmcif namespace mmcif
{ {
...@@ -58,23 +55,11 @@ struct CompoundBondLess ...@@ -58,23 +55,11 @@ struct CompoundBondLess
struct IsomerSet struct IsomerSet
{ {
vector<string> compounds; vector<string> compounds;
template<typename Archive>
void serialize(Archive& ar, unsigned long version)
{
ar & zx::make_element_nvp("compound", compounds);
}
}; };
struct IsomerSets struct IsomerSets
{ {
vector<IsomerSet> isomers; vector<IsomerSet> isomers;
template<typename Archive>
void serialize(Archive& ar, unsigned long version)
{
ar & zx::make_element_nvp("isomer-set", isomers);
}
}; };
class IsomerDB class IsomerDB
...@@ -91,20 +76,31 @@ class IsomerDB ...@@ -91,20 +76,31 @@ class IsomerDB
IsomerDB(); IsomerDB();
IsomerSets mData; IsomerSets mData;
// map<string,size_t> mIndex;
}; };
IsomerDB::IsomerDB() IsomerDB::IsomerDB()
{ {
// mrsrc::rsrc isomers("isomers.xml"); mrsrc::rsrc isomers("isomers.txt");
mrsrc::rsrc isomers("isomers-with-sugar.xml"); // mrsrc::rsrc isomers("isomers-with-sugar.xml");
if (not isomers) if (not isomers)
throw runtime_error("Missing isomers.xml resource"); throw runtime_error("Missing isomers.txt resource");
zx::document doc(string(isomers.data(), isomers.size())); struct membuf : public streambuf
zx::deserializer d(doc.root()); {
membuf(char* data, size_t length) { this->setg(data, data, data + length); }
} buffer(const_cast<char*>(isomers.data()), isomers.size());
d & zx::make_element_nvp("isomers", mData); istream is(&buffer);
string line;
while (getline(is, line))
{
IsomerSet compounds;
ba::split(compounds.compounds, line, ba::is_any_of(":"));
if (not compounds.compounds.empty())
mData.isomers.emplace_back(std::move(compounds));
}
} }
IsomerDB& IsomerDB::instance() IsomerDB& IsomerDB::instance()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment