Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

cpl_conv.h

Go to the documentation of this file.
00001 /******************************************************************************
00002  * $Id: cpl_conv.h,v 1.49 2006/11/18 20:58:23 mloskot Exp $
00003  *
00004  * Project:  CPL - Common Portability Library
00005  * Purpose:  Convenience functions declarations.
00006  *           This is intended to remain light weight.
00007  * Author:   Frank Warmerdam, warmerdam@pobox.com
00008  *
00009  ******************************************************************************
00010  * Copyright (c) 1998, Frank Warmerdam
00011  *
00012  * Permission is hereby granted, free of charge, to any person obtaining a
00013  * copy of this software and associated documentation files (the "Software"),
00014  * to deal in the Software without restriction, including without limitation
00015  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00016  * and/or sell copies of the Software, and to permit persons to whom the
00017  * Software is furnished to do so, subject to the following conditions:
00018  *
00019  * The above copyright notice and this permission notice shall be included
00020  * in all copies or substantial portions of the Software.
00021  *
00022  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00023  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00024  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
00025  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00026  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00027  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00028  * DEALINGS IN THE SOFTWARE.
00029  ******************************************************************************
00030  *
00031  * $Log: cpl_conv.h,v $
00032  * Revision 1.49  2006/11/18 20:58:23  mloskot
00033  * Removed WIN32CE ifdef around CPLLocaleC.
00034  *
00035  * Revision 1.48  2006/11/13 18:45:05  fwarmerdam
00036  * added CPLCleanTrailingSlash() per bug 1311
00037  *
00038  * Revision 1.47  2006/11/07 16:24:08  hobu
00039  * silence errors about no prototype defined for a few functions with void parameters
00040  *
00041  * Revision 1.46  2006/10/11 08:30:01  dron
00042  * Added CPLStrlwr() function.
00043  *
00044  * Revision 1.45  2006/09/07 18:11:10  dron
00045  * Added CPLGetCurrentDir().
00046  *
00047  * Revision 1.44  2006/08/23 15:09:46  fwarmerdam
00048  * Added --mempreload support, and VSICopyFile
00049  *
00050  * Revision 1.43  2006/04/04 15:37:19  fwarmerdam
00051  * Removed long double strtod functions.
00052  *
00053  * Revision 1.42  2006/03/18 16:36:15  dron
00054  * Added ASCII to floating point number conversion functions.
00055  *
00056  * Revision 1.41  2006/03/04 00:46:43  mloskot
00057  * [WCE] CPLLocaleC class excluded from compilation for Windows CE
00058  *
00059  * Revision 1.40  2006/03/03 19:40:53  fwarmerdam
00060  * added CPLLocaleC class
00061  *
00062  * Revision 1.39  2005/09/11 21:08:21  fwarmerdam
00063  * added CPLReadLineL
00064  *
00065  * Revision 1.38  2005/08/25 18:06:48  fwarmerdam
00066  * void in empty arg lists.
00067  *
00068  * Revision 1.37  2005/06/10 15:00:00  fwarmerdam
00069  * added cpl_getexecpath.cpp
00070  *
00071  * Revision 1.36  2005/04/04 15:23:31  fwarmerdam
00072  * some functions now CPL_STDCALL
00073  *
00074  * Revision 1.35  2004/11/17 22:57:21  fwarmerdam
00075  * added CPLScanPointer() and CPLPrintPointer()
00076  *
00077  * Revision 1.34  2004/08/16 20:24:07  warmerda
00078  * added CPLUnlinkTree
00079  *
00080  * Revision 1.33  2004/08/11 18:41:46  warmerda
00081  * added CPLExtractRelativePath
00082  *
00083  * Revision 1.32  2004/07/31 04:51:36  warmerda
00084  * added shared file open support
00085  *
00086  * Revision 1.31  2004/03/28 16:22:02  warmerda
00087  * const correctness changes in scan functions
00088  *
00089  * Revision 1.30  2004/03/24 09:01:17  dron
00090  * Added CPLPrintUIntBig().
00091  *
00092  * Revision 1.29  2004/02/07 14:03:30  dron
00093  * CPLDecToPackedDMS() added.
00094  *
00095  * Revision 1.28  2004/02/01 08:37:55  dron
00096  * Added CPLPackedDMSToDec().
00097  *
00098  * Revision 1.27  2003/12/28 17:24:43  warmerda
00099  * added CPLFreeConfig
00100  *
00101  * Revision 1.26  2003/10/17 07:06:06  dron
00102  * Added locale selection option to CPLScanDouble() and CPLPrintDOuble().
00103  *
00104  * Revision 1.25  2003/09/28 14:14:16  dron
00105  * Added CPLScanString().
00106  *
00107  * Revision 1.24  2003/09/08 11:09:53  dron
00108  * Added CPLPrintDouble() and CPLPrintTime().
00109  *
00110  * Revision 1.23  2003/09/07 14:38:43  dron
00111  * Added CPLPrintString(), CPLPrintStringFill(), CPLPrintInt32(), CPLPrintUIntBig().
00112  *
00113  * Revision 1.22  2003/08/31 14:48:05  dron
00114  * Added CPLScanLong() and CPLScanDouble().
00115  *
00116  * Revision 1.21  2003/08/25 20:01:58  dron
00117  * Added CPLFGets() helper function.
00118  *
00119  * Revision 1.20  2003/05/08 21:51:14  warmerda
00120  * added CPL{G,S}etConfigOption() usage
00121  *
00122  * Revision 1.19  2003/03/02 04:44:38  warmerda
00123  * added CPLStringToComplex
00124  *
00125  * Revision 1.18  2002/12/13 06:00:54  warmerda
00126  * added CPLProjectRelativeFilename() and CPLIsFilenameRelative()
00127  *
00128  * Revision 1.17  2002/12/09 18:52:51  warmerda
00129  * added DMS conversion
00130  *
00131  * Revision 1.16  2002/12/03 04:42:02  warmerda
00132  * improved finder cleanup support
00133  *
00134  * Revision 1.15  2002/08/15 09:23:24  dron
00135  * Added CPLGetDirname() function
00136  *
00137  * Revision 1.14  2002/02/01 20:39:50  warmerda
00138  * ensure CPLReadLine() is exported from DLL
00139  *
00140  * Revision 1.13  2001/12/12 17:06:57  warmerda
00141  * added CPLStat
00142  *
00143  * Revision 1.12  2001/03/16 22:15:08  warmerda
00144  * added CPLResetExtension
00145  *
00146  * Revision 1.1  1998/10/18 06:15:11  warmerda
00147  * Initial implementation.
00148  *
00149  */
00150 
00151 #ifndef CPL_CONV_H_INCLUDED
00152 #define CPL_CONV_H_INCLUDED
00153 
00154 #include "cpl_port.h"
00155 #include "cpl_vsi.h"
00156 #include "cpl_error.h"
00157 
00165 /* -------------------------------------------------------------------- */
00166 /*      Runtime check of various configuration items.                   */
00167 /* -------------------------------------------------------------------- */
00168 CPL_C_START
00169 
00170 void CPL_DLL CPLVerifyConfiguration(void);
00171 
00172 const char CPL_DLL * CPL_STDCALL
00173 CPLGetConfigOption( const char *, const char * );
00174 void CPL_DLL CPL_STDCALL CPLSetConfigOption( const char *, const char * );
00175 void CPL_DLL CPL_STDCALL CPLFreeConfig(void);
00176 
00177 /* -------------------------------------------------------------------- */
00178 /*      Safe malloc() API.  Thin cover over VSI functions with fatal    */
00179 /*      error reporting if memory allocation fails.                     */
00180 /* -------------------------------------------------------------------- */
00181 void CPL_DLL *CPLMalloc( size_t );
00182 void CPL_DLL *CPLCalloc( size_t, size_t );
00183 void CPL_DLL *CPLRealloc( void *, size_t );
00184 char CPL_DLL *CPLStrdup( const char * );
00185 char CPL_DLL *CPLStrlwr( char *);
00186 
00187 #define CPLFree VSIFree
00188 
00189 /* -------------------------------------------------------------------- */
00190 /*      Read a line from a text file, and strip of CR/LF.               */
00191 /* -------------------------------------------------------------------- */
00192 char CPL_DLL *CPLFGets( char *, int, FILE *);
00193 const char CPL_DLL *CPLReadLine( FILE * );
00194 const char CPL_DLL *CPLReadLineL( FILE * );
00195 
00196 /* -------------------------------------------------------------------- */
00197 /*      Convert ASCII string to floationg point number                  */
00198 /*      (THESE FUNCTIONS ARE NOT LOCALE AWARE!).                        */
00199 /* -------------------------------------------------------------------- */
00200 double CPL_DLL CPLAtof(const char *);
00201 double CPL_DLL CPLAtofDelim(const char *, char);
00202 double CPL_DLL CPLStrtod(const char *, char **);
00203 double CPL_DLL CPLStrtodDelim(const char *, char **, char);
00204 float CPL_DLL CPLStrtof(const char *, char **);
00205 float CPL_DLL CPLStrtofDelim(const char *, char **, char);
00206 
00207 /* -------------------------------------------------------------------- */
00208 /*      Read a numeric value from an ASCII character string.            */
00209 /* -------------------------------------------------------------------- */
00210 char CPL_DLL *CPLScanString( const char *, int, int, int );
00211 double CPL_DLL CPLScanDouble( const char *, int, char * );
00212 long CPL_DLL CPLScanLong( const char *, int );
00213 GUIntBig CPL_DLL CPLScanUIntBig( const char *, int );
00214 void CPL_DLL *CPLScanPointer( const char *, int );
00215 
00216 /* -------------------------------------------------------------------- */
00217 /*      Print a value to an ASCII character string.                     */
00218 /* -------------------------------------------------------------------- */
00219 int CPL_DLL CPLPrintString( char *, const char *, int );
00220 int CPL_DLL CPLPrintStringFill( char *, const char *, int );
00221 int CPL_DLL CPLPrintInt32( char *, GInt32 , int );
00222 int CPL_DLL CPLPrintUIntBig( char *, GUIntBig , int );
00223 int CPL_DLL CPLPrintDouble( char *, const char *, double, char * );
00224 int CPL_DLL CPLPrintTime( char *, int , const char *, const struct tm *,
00225                           char * );
00226 int CPL_DLL CPLPrintPointer( char *, void *, int );
00227 
00228 /* -------------------------------------------------------------------- */
00229 /*      Fetch a function from DLL / so.                                 */
00230 /* -------------------------------------------------------------------- */
00231 
00232 void CPL_DLL *CPLGetSymbol( const char *, const char * );
00233 
00234 /* -------------------------------------------------------------------- */
00235 /*      Read a directory  (cpl_dir.c)                                   */
00236 /* -------------------------------------------------------------------- */
00237 char CPL_DLL  **CPLReadDir( const char *pszPath );
00238 
00239 /* -------------------------------------------------------------------- */
00240 /*      Fetch executable path.                                          */
00241 /* -------------------------------------------------------------------- */
00242 int CPL_DLL CPLGetExecPath( char *pszPathBuf, int nMaxLength );
00243 
00244 /* -------------------------------------------------------------------- */
00245 /*      Filename handling functions.                                    */
00246 /* -------------------------------------------------------------------- */
00247 const char CPL_DLL *CPLGetPath( const char * );
00248 const char CPL_DLL *CPLGetDirname( const char * );
00249 const char CPL_DLL *CPLGetFilename( const char * );
00250 const char CPL_DLL *CPLGetBasename( const char * );
00251 const char CPL_DLL *CPLGetExtension( const char * );
00252 char       CPL_DLL *CPLGetCurrentDir(void);
00253 const char CPL_DLL *CPLFormFilename( const char *pszPath,
00254                                      const char *pszBasename,
00255                                      const char *pszExtension );
00256 const char CPL_DLL *CPLFormCIFilename( const char *pszPath,
00257                                        const char *pszBasename,
00258                                        const char *pszExtension );
00259 const char CPL_DLL *CPLResetExtension( const char *, const char * );
00260 const char CPL_DLL *CPLProjectRelativeFilename( const char *pszProjectDir, 
00261                                             const char *pszSecondaryFilename );
00262 int CPL_DLL CPLIsFilenameRelative( const char *pszFilename );
00263 const char CPL_DLL *CPLExtractRelativePath(const char *, const char *, int *);
00264 const char CPL_DLL *CPLCleanTrailingSlash( const char * );
00265 
00266 /* -------------------------------------------------------------------- */
00267 /*      Find File Function                                              */
00268 /* -------------------------------------------------------------------- */
00269 typedef const char *(*CPLFileFinder)(const char *, const char *);
00270 
00271 const char    CPL_DLL *CPLFindFile(const char *pszClass, 
00272                                    const char *pszBasename);
00273 const char    CPL_DLL *CPLDefaultFindFile(const char *pszClass, 
00274                                           const char *pszBasename);
00275 void          CPL_DLL CPLPushFileFinder( CPLFileFinder pfnFinder );
00276 CPLFileFinder CPL_DLL CPLPopFileFinder(void);
00277 void          CPL_DLL CPLPushFinderLocation( const char * );
00278 void          CPL_DLL CPLPopFinderLocation(void);
00279 void          CPL_DLL CPLFinderClean(void);
00280 
00281 /* -------------------------------------------------------------------- */
00282 /*      Safe version of stat() that works properly on stuff like "C:".  */
00283 /* -------------------------------------------------------------------- */
00284 int CPL_DLL     CPLStat( const char *, VSIStatBuf * );
00285 
00286 /* -------------------------------------------------------------------- */
00287 /*      Reference counted file handle manager.  Makes sharing file      */
00288 /*      handles more practical.                                         */
00289 /* -------------------------------------------------------------------- */
00290 typedef struct {
00291     FILE *fp;
00292     int   nRefCount;
00293     int   bLarge;
00294     char  *pszFilename;
00295     char  *pszAccess;
00296 } CPLSharedFileInfo;
00297 
00298 FILE CPL_DLL    *CPLOpenShared( const char *, const char *, int );
00299 void CPL_DLL     CPLCloseShared( FILE * );
00300 CPLSharedFileInfo CPL_DLL *CPLGetSharedList( int * );
00301 void CPL_DLL     CPLDumpSharedList( FILE * );
00302 
00303 /* -------------------------------------------------------------------- */
00304 /*      DMS to Dec to DMS conversion.                                   */
00305 /* -------------------------------------------------------------------- */
00306 double CPL_DLL CPLDMSToDec( const char *is );
00307 const char CPL_DLL *CPLDecToDMS( double dfAngle, const char * pszAxis,
00308                                  int nPrecision );
00309 double CPL_DLL CPLPackedDMSToDec( double );
00310 double CPL_DLL CPLDecToPackedDMS( double dfDec );
00311 
00312 void CPL_DLL CPLStringToComplex( const char *pszString, 
00313                                  double *pdfReal, double *pdfImag );
00314 
00315 /* -------------------------------------------------------------------- */
00316 /*      Misc other functions.                                           */
00317 /* -------------------------------------------------------------------- */
00318 int CPL_DLL CPLUnlinkTree( const char * );
00319 int CPL_DLL CPLCopyFile( const char *pszNewPath, const char *pszOldPath );
00320 
00321 CPL_C_END
00322 
00323 /* -------------------------------------------------------------------- */
00324 /*      C++ object for temporariliy forcing a LC_NUMERIC locale to "C". */
00325 /* -------------------------------------------------------------------- */
00326 
00327 #ifdef __cplusplus
00328 
00329 class CPLLocaleC
00330 {
00331   private:
00332     char *pszOldLocale;
00333 
00334   public:
00335     CPLLocaleC();
00336     ~CPLLocaleC();
00337 };
00338 
00339 #endif /* def __cplusplus */
00340 
00341 
00342 #endif /* ndef CPL_CONV_H_INCLUDED */

Generated for GDAL by doxygen 1.4.4.