22 #include <openbabel/babelconfig.h> 65 OBConversion(std::istream* is=NULL, std::ostream* os=NULL);
66 OBConversion(std::string inFilename, std::string outFilename=
"");
76 static int RegisterFormat(
const char* ID,
OBFormat* pFormat,
const char* MIME = NULL);
79 static OBFormat* FindFormat(
const char* ID);
82 static OBFormat* FindFormat(
const std::string ID);
84 static OBFormat* FormatFromExt(
const char* filename);
85 static OBFormat* FormatFromExt(
const char* filename,
bool& isgzip);
88 static OBFormat* FormatFromExt(
const std::string filename);
89 static OBFormat* FormatFromExt(
const std::string filename,
bool& isgzip);
91 static OBFormat* FormatFromMIME(
const char* MIME);
95 static bool GetNextFormat(Formatpos& itr,
const char*& str,
OBFormat*& pFormat);
101 static const char* Description();
113 void SetInStream(std::istream* pIn,
bool takeOwnership=
false);
114 void SetOutStream(std::ostream* pOut,
bool takeOwnership=
false);
117 bool SetInAndOutFormats(
const char* inID,
const char* outID,
bool ingzip=
false,
bool outgzip=
false);
118 bool SetInAndOutFormats(
OBFormat* pIn,
OBFormat* pOut,
bool ingzip=
false,
bool outgzip=
false);
120 bool SetInFormat(
const char* inID,
bool isgzip=
false);
121 bool SetInFormat(
OBFormat* pIn,
bool isgzip=
false);
123 bool SetOutFormat(
const char* outID,
bool isgzip=
false);
124 bool SetOutFormat(
OBFormat* pOut,
bool isgzip=
false);
140 const char* GetTitle()
const;
183 enum Option_type { INOPTIONS, OUTOPTIONS, GENOPTIONS, ALL };
187 const char* IsOption(
const char* opt,
Option_type opttyp=OUTOPTIONS);
191 {
return &OptionsArray[opttyp];};
194 void AddOption(
const char* opt,
Option_type opttyp=OUTOPTIONS,
const char* txt=NULL);
196 bool RemoveOption(
const char* opt,
Option_type optype);
199 void SetOptions(
const char* options,
Option_type opttyp);
202 static void RegisterOptionParam(std::string name,
OBFormat* pFormat,
206 static int GetOptionParams(std::string name,
Option_type typ);
215 std::vector<std::string> GetSupportedInputFormat();
217 std::vector<std::string> GetSupportedOutputFormat();
222 int Convert(std::istream* is, std::ostream* os);
230 int FullConvert(std::vector<std::string>& FileList,
231 std::string& OutputFileName, std::vector<std::string>& OutputFileList);
236 int AddChemObject(
OBBase* pOb);
240 void SetFirstInput(
bool b=
true);
241 int GetOutputIndex()
const ;
242 void SetOutputIndex(
int indx);
243 void SetMoreFilesToCome();
244 void SetOneObjectOnly(
bool b=
true);
247 int GetCount()
const {
return Count; }
253 static OBFormat* GetDefaultFormat(){
return OBFormat::FindType(NULL);};
260 bool Write(
OBBase* pOb, std::ostream* pout=NULL);
269 std::string WriteString(
OBBase* pOb,
bool trimWhitespace =
false);
277 bool WriteFile(
OBBase* pOb, std::string filePath);
290 bool Read(
OBBase* pOb, std::istream* pin=NULL);
303 bool ReadString(
OBBase* pOb, std::string input);
313 bool ReadFile(
OBBase* pOb, std::string filePath);
322 bool OpenInAndOutFiles(std::string infilepath, std::string outfilepath);
328 void ReportNumberConverted(
int count,
OBFormat* pFormat=NULL);
333 int NumInputObjects();
338 static std::string BatchFileName(std::string& BaseName, std::string& InFile);
340 static std::string IncrementedFileName(std::string& BaseName,
const int Count);
342 static bool CheckForUnintendedBatch(
const std::string& infile,
const std::string& outfile);
344 void ClearInStreams();
358 assert(ownedStreams.size() == 0);
367 bool isSet()
const {
return pStream != NULL; }
370 bool SetStartAndEnd();
374 static OPAMapType& OptionParamArray(
Option_type typ);
375 bool OpenAndSetFormat(
bool SetFormat, std::ifstream* is, std::stringstream* ss=NULL);
392 std::map<std::string,std::string> OptionsArray[3];
bool ReadyToInput
Definition: obconversion.h:402
Translate line endings automatically (UNIX, Classic Mac, DOS)
StreamState()
Definition: obconversion.h:355
const std::map< std::string, std::string > * GetOptions(Option_type opttyp)
Access the map with option name as key and any associated text as value.
Definition: obconversion.h:190
std::ostream * pOutput
Definition: obconversion.h:384
void SetAuxConv(OBConversion *pConv)
Definition: obconversion.h:144
unsigned int EndNumber
Definition: obconversion.h:396
unsigned int StartNumber
Definition: obconversion.h:395
std::string GetOutFilename() const
Definition: obconversion.h:131
OBMessageHandler obErrorLog
Global OBMessageHandler error handler.
Definition: oberror.h:187
bool inFormatGzip
skip molecules using -f and -l
Definition: obconversion.h:406
std::vector< std::ios * > ownedStreams
Definition: obconversion.h:353
std::streampos wInpos
position in the input stream of the object being written
Definition: obconversion.h:410
OBFormat * GetOutFormat() const
Definition: obconversion.h:127
bool isSet() const
Definition: obconversion.h:367
Class to convert from one format to another.
Definition: obconversion.h:59
Handle error messages, warnings, debugging information and the like.
Definition: oberror.h:106
bool MoreFilesToCome
Definition: obconversion.h:400
bool m_IsFirstInput
Definition: obconversion.h:398
Definition: obconversion.h:350
std::streampos rInpos
position in the input stream of the object being read
Definition: obconversion.h:411
std::vector< std::ostream * > ownedOutStreams
Definition: obconversion.h:385
static OBFormat * pDefaultFormat
Definition: obconversion.h:388
OBConversion * pAuxConv
Way to extend OBConversion.
Definition: obconversion.h:415
std::ios * pStream
Definition: obconversion.h:352
std::vector< std::string > SupportedOutputFormat
list of supported output format
Definition: obconversion.h:418
int Count
Definition: obconversion.h:397
bool SkippedMolecules
Definition: obconversion.h:403
bool IsLastFile()
True if no more files to be read.
Definition: obconversion.h:246
void SetLast(bool b)
Synonym for SetOneObjectOnly()
Definition: obconversion.h:245
OBBase * pOb1
Definition: obconversion.h:409
PluginMapType::const_iterator PluginIterator
Definition: plugin.h:60
OBFormat * pInFormat
Definition: obconversion.h:389
std::map< std::string, int > OPAMapType
Definition: obconversion.h:373
std::string GetInFilename() const
Definition: obconversion.h:130
OBFormat * pOutFormat
Definition: obconversion.h:390
OBFormat * GetInFormat() const
Definition: obconversion.h:126
size_t rInlen
length in the input stream of the object being read
Definition: obconversion.h:413
size_t GetInLen() const
Get the length in the input stream of the object being read.
Definition: obconversion.h:137
std::istream * pInput
Definition: obconversion.h:381
Option_type
Three types of options set on the the command line by -a? , -x? , or -?
Definition: obconversion.h:184
bool outFormatGzip
Definition: obconversion.h:407
OBPlugin::PluginIterator Formatpos
Definition: obconversion.h:52
std::string OutFilename
Definition: obconversion.h:377
bool GetOutGzipped() const
Definition: obconversion.h:129
OBConversion * GetAuxConv() const
Extension method: deleted in ~OBConversion()
Definition: obconversion.h:143
bool OneObjectOnly
Definition: obconversion.h:401
std::streampos GetInPos() const
Get the position in the input stream of the object being read.
Definition: obconversion.h:134
FilteringInputStream< LineEndingExtractor > LEInStream
Definition: obconversion.h:379
Handle error messages, warnings, notices, etc.
size_t wInlen
length in the input stream of the object being written
Definition: obconversion.h:412
int Index
Definition: obconversion.h:394
~StreamState()
Definition: obconversion.h:356
std::ostream * GetOutStream() const
Definition: obconversion.h:108
bool m_IsLast
Definition: obconversion.h:399
Base Class.
Definition: base.h:239
std::vector< std::istream * > ownedInStreams
Definition: obconversion.h:382
bool GetInGzipped() const
Definition: obconversion.h:128
std::istream * GetInStream() const
Definition: obconversion.h:107
Global namespace for all Open Babel code.
Definition: alias.h:22
std::vector< std::string > SupportedInputFormat
list of supported input format
Definition: obconversion.h:417