00001 /********************************************************************** 00002 tokenst.h - Tokenize and trim strings; Open data files 00003 00004 Copyright (C) 1998-2001 by OpenEye Scientific Software, Inc. 00005 Some portions Copyright (C) 2001-2006 by Geoffrey R. Hutchison 00006 00007 This file is part of the Open Babel project. 00008 For more information, see <http://openbabel.org/> 00009 00010 This program is free software; you can redistribute it and/or modify 00011 it under the terms of the GNU General Public License as published by 00012 the Free Software Foundation version 2 of the License. 00013 00014 This program is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU General Public License for more details. 00018 ***********************************************************************/ 00019 00020 #ifndef OB_TOKENST_H 00021 #define OB_TOKENST_H 00022 00023 #include <openbabel/babelconfig.h> 00024 00025 #include <vector> 00026 #include <sstream> 00027 #include <string> 00028 #include <fstream> 00029 00030 namespace OpenBabel 00031 { 00032 // Utility function prototypes 00033 OBERROR bool tokenize(std::vector<std::string>&, const char *buf, const char *delimstr=" \t\n\r"); 00034 OBERROR bool tokenize(std::vector<std::string>&, std::string&, const char *delimstr=" \t\n\r", int limit=-1); 00036 OBERROR std::string& Trim(std::string& txt); 00037 00038 // \return a string representation of a variable 00039 template<typename T> 00040 std::string toString(T val) 00041 { 00042 std::ostringstream s; 00043 s << val; 00044 return s.str(); 00045 } 00046 00048 struct DeleteObject 00049 { 00050 template<typename T> 00051 void operator()(const T* ptr)const { delete ptr; } 00052 }; 00053 00055 OBERROR std::istream& ignore(std::istream& ifs, const std::string& txt); 00056 00058 // full documentation in tokenst.cpp 00059 OBERROR std::string OpenDatafile(std::ifstream& fs, 00060 const std::string& filename, 00061 const std::string& envvar = "BABEL_DATADIR"); 00062 00063 // Used by other code for reading files 00064 #ifdef WIN32 00065 #define FILE_SEP_CHAR "\\" 00066 #else 00067 #define FILE_SEP_CHAR "/" 00068 #endif 00069 00070 00071 }//namespace 00072 #endif 00073
This file is part of the documentation for Open Babel, version 2.3.