-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
44 lines (39 loc) · 983 Bytes
/
main.cpp
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
#include <iostream>
#include <base_cpp/output.h>
#include <base_cpp/scanner.h>
#include <molecule/molecule.h>
#include <molecule/molecule_auto_loader.h>
#include <molecule/molecule_cdxml_saver.h>
using namespace indigo;
#ifndef EX_USAGE
#define EX_USAGE 64
#endif
std::string molecule2cdxml(const std::string& input)
{
BufferScanner scanner(input.c_str());
MoleculeAutoLoader moleculeLoader(scanner);
Molecule molecule;
moleculeLoader.loadMolecule(molecule);
Array<char> array;
ArrayOutput output(array);
MoleculeCdxmlSaver cdxmlSaver(output);
cdxmlSaver.saveMolecule(molecule);
return array.ptr();
}
int main(int argc, char *argv[])
{
if (argc < 2)
{
std::cout << "usage: molecule2cdxml <SMILES string>\n";
return EX_USAGE;
}
try
{
std::cout << molecule2cdxml(argv[1]);
}
catch (const Exception &e)
{
std::cout << "Fatal error: " << e.what() << '\n';
return 1;
}
}