common/utils.h

Go to the documentation of this file.
00001 /* utils.h: Various useful utilities
00002  *
00003  * Copyright 1999,2000,2001 BrightStation PLC
00004  * Copyright 2002 Ananova Ltd
00005  * Copyright 2003,2004,2005,2006,2007 Olly Betts
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License as
00009  * published by the Free Software Foundation; either version 2 of the
00010  * License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
00020  * USA
00021  */
00022 
00023 #ifndef OM_HGUARD_UTILS_H
00024 #define OM_HGUARD_UTILS_H
00025 
00026 #include <xapian/visibility.h>
00027 
00028 #include <string>
00029 using std::string;
00030 
00031 #include <stdlib.h>
00032 #include <sys/types.h>
00033 #include "safesysstat.h"
00034 #include "safeunistd.h"
00035 
00037 inline string om_tostring(const string &s) { return s; }
00038 
00040 XAPIAN_VISIBILITY_DEFAULT
00041 string om_tostring(int a);
00042 
00044 XAPIAN_VISIBILITY_DEFAULT
00045 string om_tostring(unsigned int a);
00046 
00048 XAPIAN_VISIBILITY_DEFAULT
00049 string om_tostring(long int a);
00050 
00052 XAPIAN_VISIBILITY_DEFAULT
00053 string om_tostring(unsigned long int a);
00054 
00055 #ifdef __WIN32__
00057 string om_tostring(__int64 a);
00058 #endif
00059 
00061 XAPIAN_VISIBILITY_DEFAULT
00062 string om_tostring(double a);
00063 
00065 XAPIAN_VISIBILITY_DEFAULT
00066 string om_tostring(bool a);
00067 
00069 XAPIAN_VISIBILITY_DEFAULT
00070 string om_tostring(const void * a);
00071 
00074 XAPIAN_VISIBILITY_DEFAULT
00075 bool file_exists(const string &fname);
00076 
00079 XAPIAN_VISIBILITY_DEFAULT
00080 bool dir_exists(const string &dirname);
00081 
00083 inline int atoi(const string &s) { return atoi(s.c_str()); }
00084 
00086 inline int unlink(const string &filename) { return unlink(filename.c_str()); }
00087 
00089 inline int system(const string &command) { return system(command.c_str()); }
00090 
00091 #ifdef HAVE_LINK
00093 inline int link(const string &o, const string &n) {
00094     return link(o.c_str(), n.c_str());
00095 }
00096 #endif
00097 
00099 inline int mkdir(const string &filename, mode_t mode) {
00100     return mkdir(filename.c_str(), mode);
00101 }
00102 
00104 inline int stat(const string &filename, struct stat *buf) {
00105     return stat(filename.c_str(), buf);
00106 }
00107 
00108 namespace Xapian {
00109     namespace Internal {
00110         bool within_DBL_EPSILON(double a, double b);
00111     }
00112 }
00113 
00114 #endif /* OM_HGUARD_UTILS_H */

Documentation for Xapian (version 1.0.10).
Generated on 24 Dec 2008 by Doxygen 1.5.2.