- Main Page
- Classes
- Files
- Related Pages

- File List
- File Members

# cpl_conv.h

Go to the documentation of this file.

    00001 /******************************************************************************
    00002  * $Id: cpl_conv.h 11096 2007-03-29 02:32:06Z warmerdam $
    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 #ifndef CPL_CONV_H_INCLUDED
    00032 #define CPL_CONV_H_INCLUDED
    00033
    00034 #include "cpl_port.h"
    00035 #include "cpl_vsi.h"
    00036 #include "cpl_error.h"
    00037
    00045 /* -------------------------------------------------------------------- */
    00046 /*      Runtime check of various configuration items.                   */
    00047 /* -------------------------------------------------------------------- */
    00048 CPL_C_START
    00049
    00050 void CPL_DLL CPLVerifyConfiguration(void);
    00051
    00052 const char CPL_DLL * CPL_STDCALL
    00053 CPLGetConfigOption( const char *, const char * );
    00054 void CPL_DLL CPL_STDCALL CPLSetConfigOption( const char *, const char * );
    00055 void CPL_DLL CPL_STDCALL CPLFreeConfig(void);
    00056
    00057 /* -------------------------------------------------------------------- */
    00058 /*      Safe malloc() API.  Thin cover over VSI functions with fatal    */
    00059 /*      error reporting if memory allocation fails.                     */
    00060 /* -------------------------------------------------------------------- */
    00061 void CPL_DLL *CPLMalloc( size_t );
    00062 void CPL_DLL *CPLCalloc( size_t, size_t );
    00063 void CPL_DLL *CPLRealloc( void *, size_t );
    00064 char CPL_DLL *CPLStrdup( const char * );
    00065 char CPL_DLL *CPLStrlwr( char *);
    00066
    00067 #define CPLFree VSIFree
    00068
    00069 /* -------------------------------------------------------------------- */
    00070 /*      Read a line from a text file, and strip of CR/LF.               */
    00071 /* -------------------------------------------------------------------- */
    00072 char CPL_DLL *CPLFGets( char *, int, FILE *);
    00073 const char CPL_DLL *CPLReadLine( FILE * );
    00074 const char CPL_DLL *CPLReadLineL( FILE * );
    00075
    00076 /* -------------------------------------------------------------------- */
    00077 /*      Convert ASCII string to floationg point number                  */
    00078 /*      (THESE FUNCTIONS ARE NOT LOCALE AWARE!).                        */
    00079 /* -------------------------------------------------------------------- */
    00080 double CPL_DLL CPLAtof(const char *);
    00081 double CPL_DLL CPLAtofDelim(const char *, char);
    00082 double CPL_DLL CPLStrtod(const char *, char **);
    00083 double CPL_DLL CPLStrtodDelim(const char *, char **, char);
    00084 float CPL_DLL CPLStrtof(const char *, char **);
    00085 float CPL_DLL CPLStrtofDelim(const char *, char **, char);
    00086
    00087 /* -------------------------------------------------------------------- */
    00088 /*      Convert number to string.  This function is locale agnostic     */
    00089 /*      (ie. it will support "," or "." regardless of current locale)   */
    00090 /* -------------------------------------------------------------------- */
    00091 double CPL_DLL CPLAtofM(const char *);
    00092
    00093 /* -------------------------------------------------------------------- */
    00094 /*      Read a numeric value from an ASCII character string.            */
    00095 /* -------------------------------------------------------------------- */
    00096 char CPL_DLL *CPLScanString( const char *, int, int, int );
    00097 double CPL_DLL CPLScanDouble( const char *, int, char * );
    00098 long CPL_DLL CPLScanLong( const char *, int );
    00099 GUIntBig CPL_DLL CPLScanUIntBig( const char *, int );
    00100 void CPL_DLL *CPLScanPointer( const char *, int );
    00101
    00102 /* -------------------------------------------------------------------- */
    00103 /*      Print a value to an ASCII character string.                     */
    00104 /* -------------------------------------------------------------------- */
    00105 int CPL_DLL CPLPrintString( char *, const char *, int );
    00106 int CPL_DLL CPLPrintStringFill( char *, const char *, int );
    00107 int CPL_DLL CPLPrintInt32( char *, GInt32 , int );
    00108 int CPL_DLL CPLPrintUIntBig( char *, GUIntBig , int );
    00109 int CPL_DLL CPLPrintDouble( char *, const char *, double, char * );
    00110 int CPL_DLL CPLPrintTime( char *, int , const char *, const struct tm *,
    00111                           char * );
    00112 int CPL_DLL CPLPrintPointer( char *, void *, int );
    00113
    00114 /* -------------------------------------------------------------------- */
    00115 /*      Fetch a function from DLL / so.                                 */
    00116 /* -------------------------------------------------------------------- */
    00117
    00118 void CPL_DLL *CPLGetSymbol( const char *, const char * );
    00119
    00120 /* -------------------------------------------------------------------- */
    00121 /*      Read a directory  (cpl_dir.c)                                   */
    00122 /* -------------------------------------------------------------------- */
    00123 char CPL_DLL  **CPLReadDir( const char *pszPath );
    00124
    00125 /* -------------------------------------------------------------------- */
    00126 /*      Fetch executable path.                                          */
    00127 /* -------------------------------------------------------------------- */
    00128 int CPL_DLL CPLGetExecPath( char *pszPathBuf, int nMaxLength );
    00129
    00130 /* -------------------------------------------------------------------- */
    00131 /*      Filename handling functions.                                    */
    00132 /* -------------------------------------------------------------------- */
    00133 const char CPL_DLL *CPLGetPath( const char * );
    00134 const char CPL_DLL *CPLGetDirname( const char * );
    00135 const char CPL_DLL *CPLGetFilename( const char * );
    00136 const char CPL_DLL *CPLGetBasename( const char * );
    00137 const char CPL_DLL *CPLGetExtension( const char * );
    00138 char       CPL_DLL *CPLGetCurrentDir(void);
    00139 const char CPL_DLL *CPLFormFilename( const char *pszPath,
    00140                                      const char *pszBasename,
    00141                                      const char *pszExtension );
    00142 const char CPL_DLL *CPLFormCIFilename( const char *pszPath,
    00143                                        const char *pszBasename,
    00144                                        const char *pszExtension );
    00145 const char CPL_DLL *CPLResetExtension( const char *, const char * );
    00146 const char CPL_DLL *CPLProjectRelativeFilename( const char *pszProjectDir,
    00147                                             const char *pszSecondaryFilename );
    00148 int CPL_DLL CPLIsFilenameRelative( const char *pszFilename );
    00149 const char CPL_DLL *CPLExtractRelativePath(const char *, const char *, int *);
    00150 const char CPL_DLL *CPLCleanTrailingSlash( const char * );
    00151
    00152 /* -------------------------------------------------------------------- */
    00153 /*      Find File Function                                              */
    00154 /* -------------------------------------------------------------------- */
    00155 typedef const char *(*CPLFileFinder)(const char *, const char *);
    00156
    00157 const char    CPL_DLL *CPLFindFile(const char *pszClass,
    00158                                    const char *pszBasename);
    00159 const char    CPL_DLL *CPLDefaultFindFile(const char *pszClass,
    00160                                           const char *pszBasename);
    00161 void          CPL_DLL CPLPushFileFinder( CPLFileFinder pfnFinder );
    00162 CPLFileFinder CPL_DLL CPLPopFileFinder(void);
    00163 void          CPL_DLL CPLPushFinderLocation( const char * );
    00164 void          CPL_DLL CPLPopFinderLocation(void);
    00165 void          CPL_DLL CPLFinderClean(void);
    00166
    00167 /* -------------------------------------------------------------------- */
    00168 /*      Safe version of stat() that works properly on stuff like "C:".  */
    00169 /* -------------------------------------------------------------------- */
    00170 int CPL_DLL     CPLStat( const char *, VSIStatBuf * );
    00171
    00172 /* -------------------------------------------------------------------- */
    00173 /*      Reference counted file handle manager.  Makes sharing file      */
    00174 /*      handles more practical.                                         */
    00175 /* -------------------------------------------------------------------- */
    00176 typedef struct {
    00177     FILE *fp;
    00178     int   nRefCount;
    00179     int   bLarge;
    00180     char  *pszFilename;
    00181     char  *pszAccess;
    00182 } CPLSharedFileInfo;
    00183
    00184 FILE CPL_DLL    *CPLOpenShared( const char *, const char *, int );
    00185 void CPL_DLL     CPLCloseShared( FILE * );
    00186 CPLSharedFileInfo CPL_DLL *CPLGetSharedList( int * );
    00187 void CPL_DLL     CPLDumpSharedList( FILE * );
    00188
    00189 /* -------------------------------------------------------------------- */
    00190 /*      DMS to Dec to DMS conversion.                                   */
    00191 /* -------------------------------------------------------------------- */
    00192 double CPL_DLL CPLDMSToDec( const char *is );
    00193 const char CPL_DLL *CPLDecToDMS( double dfAngle, const char * pszAxis,
    00194                                  int nPrecision );
    00195 double CPL_DLL CPLPackedDMSToDec( double );
    00196 double CPL_DLL CPLDecToPackedDMS( double dfDec );
    00197
    00198 void CPL_DLL CPLStringToComplex( const char *pszString,
    00199                                  double *pdfReal, double *pdfImag );
    00200
    00201 /* -------------------------------------------------------------------- */
    00202 /*      Misc other functions.                                           */
    00203 /* -------------------------------------------------------------------- */
    00204 int CPL_DLL CPLUnlinkTree( const char * );
    00205 int CPL_DLL CPLCopyFile( const char *pszNewPath, const char *pszOldPath );
    00206
    00207 CPL_C_END
    00208
    00209 /* -------------------------------------------------------------------- */
    00210 /*      C++ object for temporariliy forcing a LC_NUMERIC locale to "C". */
    00211 /* -------------------------------------------------------------------- */
    00212
    00213 #ifdef __cplusplus
    00214
    00215 class CPLLocaleC
    00216 {
    00217   private:
    00218     char *pszOldLocale;
    00219
    00220   public:
    00221     CPLLocaleC();
    00222     ~CPLLocaleC();
    00223 };
    00224
    00225 #endif /* def __cplusplus */
    00226
    00227
    00228 #endif /* ndef CPL_CONV_H_INCLUDED */

Generated for GDAL by 1.5.1.