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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
// FILETRANS.H: Handle import/export through use of the Babel external lib.
//
// Copyright (C) 2000 Geoffrey Hutchison
// This program is free software; you can redistribute it and/or modify it
// under the terms of the license (GNU GPL) which comes with this package.
/*################################################################################################*/
#include "config.h"
#ifndef FILETRANS_H
#define FILETRANS_H
/*################################################################################################*/
#include "mm1mdl.h"
#include <string>
#include <vector>
#include <iostream>
#include <fstream>
using namespace std;
/*################################################################################################*/
typedef struct {
mm1_atom * atmr;
OBAtom * oba;
} atom_name_tag;
typedef struct {
string format;
unsigned int offset;
} format_record;
class file_trans
{
private:
vector<format_record> imports;
vector<format_record> exports;
int name_tag_count;
atom_name_tag * tagtab;
mm1_mdl * mdl; OBMol * obm;
iter_mm1al itb; iter_mm1al ite;
public:
file_trans();
virtual ~file_trans();
// these expect to be passed the filename to pick the file format
int Import(const char *, istream &, ostream &);
int Export(const char *, istream &, ostream &);
// these check whether the format picked by the filename are valid
bool CanImport(const char *);
bool CanExport(const char *);
// Get a listing of the number of valid import/export types
unsigned int NumImports() { return imports.size(); }
unsigned int NumExports() { return exports.size(); }
// Get the description associated with this type
string GetExportDescription(unsigned int);
string GetImportDescription(unsigned int);
// These take the unsigned int as a format specifier
int Import(const char *, unsigned int, istream &, ostream &);
int Export(const char *, unsigned int, istream &, ostream &);
// some Babel compatibility methods:
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/// This takes a pair of atom list iterators, and copies all atoms/bonds in this range to OBMol.
OBMol * Copy(mm1_mdl *, iter_mm1al, iter_mm1al);
/// This will copy a molecule (defined by the index) to OBMol.
OBMol * CopyMolecule(mm1_mdl *, int);
/// This will copy everything in this model to OBMol.
OBMol * CopyAll(mm1_mdl *);
/// This will syncronize the model and the OBMol.
// (if you only wish to add new bonds and atoms, set the parameter)
void Synchronize(bool onlyAdd = false);
};
/*################################################################################################*/
#endif // FILETRANS_H
// eof
|