- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

# cpl_conv.h

Go to the documentation of this file.

    00001 /******************************************************************************
    00002  * $Id: cpl_conv.h 25627 2013-02-10 10:17:19Z rouault $
    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 * ) CPL_WARN_UNUSED_RESULT;
    00054 void CPL_DLL CPL_STDCALL CPLSetConfigOption( const char *, const char * );
    00055 void CPL_DLL CPL_STDCALL CPLSetThreadLocalConfigOption( const char *pszKey,
    00056                                                         const char *pszValue );
    00057 void CPL_DLL CPL_STDCALL CPLFreeConfig(void);
    00058
    00059 /* -------------------------------------------------------------------- */
    00060 /*      Safe malloc() API.  Thin cover over VSI functions with fatal    */
    00061 /*      error reporting if memory allocation fails.                     */
    00062 /* -------------------------------------------------------------------- */
    00063 void CPL_DLL *CPLMalloc( size_t ) CPL_WARN_UNUSED_RESULT;
    00064 void CPL_DLL *CPLCalloc( size_t, size_t ) CPL_WARN_UNUSED_RESULT;
    00065 void CPL_DLL *CPLRealloc( void *, size_t ) CPL_WARN_UNUSED_RESULT;
    00066 char CPL_DLL *CPLStrdup( const char * ) CPL_WARN_UNUSED_RESULT;
    00067 char CPL_DLL *CPLStrlwr( char *);
    00068
    00069 #define CPLFree VSIFree
    00070
    00071 /* -------------------------------------------------------------------- */
    00072 /*      Read a line from a text file, and strip of CR/LF.               */
    00073 /* -------------------------------------------------------------------- */
    00074 char CPL_DLL *CPLFGets( char *, int, FILE *);
    00075 const char CPL_DLL *CPLReadLine( FILE * );
    00076 const char CPL_DLL *CPLReadLineL( VSILFILE * );
    00077 const char CPL_DLL *CPLReadLine2L( VSILFILE * , int nMaxCols, char** papszOptions);
    00078
    00079 /* -------------------------------------------------------------------- */
    00080 /*      Convert ASCII string to floationg point number                  */
    00081 /*      (THESE FUNCTIONS ARE NOT LOCALE AWARE!).                        */
    00082 /* -------------------------------------------------------------------- */
    00083 double CPL_DLL CPLAtof(const char *);
    00084 double CPL_DLL CPLAtofDelim(const char *, char);
    00085 double CPL_DLL CPLStrtod(const char *, char **);
    00086 double CPL_DLL CPLStrtodDelim(const char *, char **, char);
    00087 float CPL_DLL CPLStrtof(const char *, char **);
    00088 float CPL_DLL CPLStrtofDelim(const char *, char **, char);
    00089
    00090 /* -------------------------------------------------------------------- */
    00091 /*      Convert number to string.  This function is locale agnostic     */
    00092 /*      (ie. it will support "," or "." regardless of current locale)   */
    00093 /* -------------------------------------------------------------------- */
    00094 double CPL_DLL CPLAtofM(const char *);
    00095
    00096 /* -------------------------------------------------------------------- */
    00097 /*      Read a numeric value from an ASCII character string.            */
    00098 /* -------------------------------------------------------------------- */
    00099 char CPL_DLL *CPLScanString( const char *, int, int, int );
    00100 double CPL_DLL CPLScanDouble( const char *, int );
    00101 long CPL_DLL CPLScanLong( const char *, int );
    00102 unsigned long CPL_DLL CPLScanULong( const char *, int );
    00103 GUIntBig CPL_DLL CPLScanUIntBig( const char *, int );
    00104 void CPL_DLL *CPLScanPointer( const char *, int );
    00105
    00106 /* -------------------------------------------------------------------- */
    00107 /*      Print a value to an ASCII character string.                     */
    00108 /* -------------------------------------------------------------------- */
    00109 int CPL_DLL CPLPrintString( char *, const char *, int );
    00110 int CPL_DLL CPLPrintStringFill( char *, const char *, int );
    00111 int CPL_DLL CPLPrintInt32( char *, GInt32 , int );
    00112 int CPL_DLL CPLPrintUIntBig( char *, GUIntBig , int );
    00113 int CPL_DLL CPLPrintDouble( char *, const char *, double, const char * );
    00114 int CPL_DLL CPLPrintTime( char *, int , const char *, const struct tm *,
    00115                           const char * );
    00116 int CPL_DLL CPLPrintPointer( char *, void *, int );
    00117
    00118 /* -------------------------------------------------------------------- */
    00119 /*      Fetch a function from DLL / so.                                 */
    00120 /* -------------------------------------------------------------------- */
    00121
    00122 void CPL_DLL *CPLGetSymbol( const char *, const char * );
    00123
    00124 /* -------------------------------------------------------------------- */
    00125 /*      Fetch executable path.                                          */
    00126 /* -------------------------------------------------------------------- */
    00127 int CPL_DLL CPLGetExecPath( char *pszPathBuf, int nMaxLength );
    00128
    00129 /* -------------------------------------------------------------------- */
    00130 /*      Filename handling functions.                                    */
    00131 /* -------------------------------------------------------------------- */
    00132 const char CPL_DLL *CPLGetPath( const char * );
    00133 const char CPL_DLL *CPLGetDirname( const char * );
    00134 const char CPL_DLL *CPLGetFilename( const char * );
    00135 const char CPL_DLL *CPLGetBasename( const char * );
    00136 const char CPL_DLL *CPLGetExtension( const char * );
    00137 char       CPL_DLL *CPLGetCurrentDir(void);
    00138 const char CPL_DLL *CPLFormFilename( const char *pszPath,
    00139                                      const char *pszBasename,
    00140                                      const char *pszExtension );
    00141 const char CPL_DLL *CPLFormCIFilename( const char *pszPath,
    00142                                        const char *pszBasename,
    00143                                        const char *pszExtension );
    00144 const char CPL_DLL *CPLResetExtension( const char *, const char * );
    00145 const char CPL_DLL *CPLProjectRelativeFilename( const char *pszProjectDir,
    00146                                             const char *pszSecondaryFilename );
    00147 int CPL_DLL CPLIsFilenameRelative( const char *pszFilename );
    00148 const char CPL_DLL *CPLExtractRelativePath(const char *, const char *, int *);
    00149 const char CPL_DLL *CPLCleanTrailingSlash( const char * );
    00150 char CPL_DLL      **CPLCorrespondingPaths( const char *pszOldFilename,
    00151                                            const char *pszNewFilename,
    00152                                            char **papszFileList );
    00153 int CPL_DLL CPLCheckForFile( char *pszFilename, char **papszSiblingList );
    00154
    00155 const char CPL_DLL *CPLGenerateTempFilename( const char *pszStem );
    00156
    00157 /* -------------------------------------------------------------------- */
    00158 /*      Find File Function                                              */
    00159 /* -------------------------------------------------------------------- */
    00160 typedef const char *(*CPLFileFinder)(const char *, const char *);
    00161
    00162 const char    CPL_DLL *CPLFindFile(const char *pszClass,
    00163                                    const char *pszBasename);
    00164 const char    CPL_DLL *CPLDefaultFindFile(const char *pszClass,
    00165                                           const char *pszBasename);
    00166 void          CPL_DLL CPLPushFileFinder( CPLFileFinder pfnFinder );
    00167 CPLFileFinder CPL_DLL CPLPopFileFinder(void);
    00168 void          CPL_DLL CPLPushFinderLocation( const char * );
    00169 void          CPL_DLL CPLPopFinderLocation(void);
    00170 void          CPL_DLL CPLFinderClean(void);
    00171
    00172 /* -------------------------------------------------------------------- */
    00173 /*      Safe version of stat() that works properly on stuff like "C:".  */
    00174 /* -------------------------------------------------------------------- */
    00175 int CPL_DLL     CPLStat( const char *, VSIStatBuf * );
    00176
    00177 /* -------------------------------------------------------------------- */
    00178 /*      Reference counted file handle manager.  Makes sharing file      */
    00179 /*      handles more practical.                                         */
    00180 /* -------------------------------------------------------------------- */
    00181 typedef struct {
    00182     FILE *fp;
    00183     int   nRefCount;
    00184     int   bLarge;
    00185     char  *pszFilename;
    00186     char  *pszAccess;
    00187 } CPLSharedFileInfo;
    00188
    00189 FILE CPL_DLL    *CPLOpenShared( const char *, const char *, int );
    00190 void CPL_DLL     CPLCloseShared( FILE * );
    00191 CPLSharedFileInfo CPL_DLL *CPLGetSharedList( int * );
    00192 void CPL_DLL     CPLDumpSharedList( FILE * );
    00193 void CPL_DLL     CPLCleanupSharedFileMutex();
    00194
    00195 /* -------------------------------------------------------------------- */
    00196 /*      DMS to Dec to DMS conversion.                                   */
    00197 /* -------------------------------------------------------------------- */
    00198 double CPL_DLL CPLDMSToDec( const char *is );
    00199 const char CPL_DLL *CPLDecToDMS( double dfAngle, const char * pszAxis,
    00200                                  int nPrecision );
    00201 double CPL_DLL CPLPackedDMSToDec( double );
    00202 double CPL_DLL CPLDecToPackedDMS( double dfDec );
    00203
    00204 void CPL_DLL CPLStringToComplex( const char *pszString,
    00205                                  double *pdfReal, double *pdfImag );
    00206
    00207 /* -------------------------------------------------------------------- */
    00208 /*      Misc other functions.                                           */
    00209 /* -------------------------------------------------------------------- */
    00210 int CPL_DLL CPLUnlinkTree( const char * );
    00211 int CPL_DLL CPLCopyFile( const char *pszNewPath, const char *pszOldPath );
    00212 int CPL_DLL CPLMoveFile( const char *pszNewPath, const char *pszOldPath );
    00213
    00214 /* -------------------------------------------------------------------- */
    00215 /*      ZIP Creation.                                                   */
    00216 /* -------------------------------------------------------------------- */
    00217 #define CPL_ZIP_API_OFFERED
    00218 void CPL_DLL  *CPLCreateZip( const char *pszZipFilename, char **papszOptions );
    00219 CPLErr CPL_DLL CPLCreateFileInZip( void *hZip, const char *pszFilename,
    00220                                    char **papszOptions );
    00221 CPLErr CPL_DLL CPLWriteFileInZip( void *hZip, const void *pBuffer, int nBufferSize );
    00222 CPLErr CPL_DLL CPLCloseFileInZip( void *hZip );
    00223 CPLErr CPL_DLL CPLCloseZip( void *hZip );
    00224
    00225 /* -------------------------------------------------------------------- */
    00226 /*      ZLib compression                                                */
    00227 /* -------------------------------------------------------------------- */
    00228
    00229 void CPL_DLL *CPLZLibDeflate( const void* ptr, size_t nBytes, int nLevel,
    00230                               void* outptr, size_t nOutAvailableBytes,
    00231                               size_t* pnOutBytes );
    00232 void CPL_DLL *CPLZLibInflate( const void* ptr, size_t nBytes,
    00233                               void* outptr, size_t nOutAvailableBytes,
    00234                               size_t* pnOutBytes );
    00235
    00236 /* -------------------------------------------------------------------- */
    00237 /*      XML validation.                                                 */
    00238 /* -------------------------------------------------------------------- */
    00239 int CPL_DLL CPLValidateXML(const char* pszXMLFilename,
    00240                            const char* pszXSDFilename,
    00241                            char** papszOptions);
    00242
    00243 CPL_C_END
    00244
    00245 /* -------------------------------------------------------------------- */
    00246 /*      C++ object for temporariliy forcing a LC_NUMERIC locale to "C". */
    00247 /* -------------------------------------------------------------------- */
    00248
    00249 #if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
    00250
    00251 class CPL_DLL CPLLocaleC
    00252 {
    00253 public:
    00254     CPLLocaleC();
    00255     ~CPLLocaleC();
    00256
    00257 private:
    00258     char *pszOldLocale;
    00259
    00260     /* Make it non-copyable */
    00261     CPLLocaleC(CPLLocaleC&);
    00262     CPLLocaleC& operator=(CPLLocaleC&);
    00263 };
    00264
    00265 #endif /* def __cplusplus */
    00266
    00267
    00268 #endif /* ndef CPL_CONV_H_INCLUDED */

Generated for GDAL by 1.7.1.