Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libjni-gdal / include / cpl_conv.h @ 930

History | View | Annotate | Download (9.5 KB)

1 716 igbrotru
/******************************************************************************
2
 * $Id$
3
 *
4
 * Project:  CPL - Common Portability Library
5
 * Purpose:  Convenience functions declarations.
6
 *           This is intended to remain light weight.
7
 * Author:   Frank Warmerdam, warmerdam@pobox.com
8
 *
9
 ******************************************************************************
10
 * Copyright (c) 1998, Frank Warmerdam
11
 *
12
 * Permission is hereby granted, free of charge, to any person obtaining a
13
 * copy of this software and associated documentation files (the "Software"),
14
 * to deal in the Software without restriction, including without limitation
15
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16
 * and/or sell copies of the Software, and to permit persons to whom the
17
 * Software is furnished to do so, subject to the following conditions:
18
 *
19
 * The above copyright notice and this permission notice shall be included
20
 * in all copies or substantial portions of the Software.
21
 *
22
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28
 * DEALINGS IN THE SOFTWARE.
29
 ******************************************************************************
30
 *
31
 * $Log$
32
 * Revision 1.1  2004-12-28 14:06:59  igbrotru
33
 * *** empty log message ***
34
 *
35
 * Revision 1.1  2004/10/28 12:08:47  igbrotru
36
 * *** empty log message ***
37
 *
38
 * Revision 1.1  2004/09/27 08:27:48  igbrotru
39
 * *** empty log message ***
40
 *
41
 * Revision 1.1  2004/09/08 12:39:04  igbrotru
42
 * *** empty log message ***
43
 *
44
 * Revision 1.31  2004/03/28 16:22:02  warmerda
45
 * const correctness changes in scan functions
46
 *
47
 * Revision 1.30  2004/03/24 09:01:17  dron
48
 * Added CPLPrintUIntBig().
49
 *
50
 * Revision 1.29  2004/02/07 14:03:30  dron
51
 * CPLDecToPackedDMS() added.
52
 *
53
 * Revision 1.28  2004/02/01 08:37:55  dron
54
 * Added CPLPackedDMSToDec().
55
 *
56
 * Revision 1.27  2003/12/28 17:24:43  warmerda
57
 * added CPLFreeConfig
58
 *
59
 * Revision 1.26  2003/10/17 07:06:06  dron
60
 * Added locale selection option to CPLScanDouble() and CPLPrintDOuble().
61
 *
62
 * Revision 1.25  2003/09/28 14:14:16  dron
63
 * Added CPLScanString().
64
 *
65
 * Revision 1.24  2003/09/08 11:09:53  dron
66
 * Added CPLPrintDouble() and CPLPrintTime().
67
 *
68
 * Revision 1.23  2003/09/07 14:38:43  dron
69
 * Added CPLPrintString(), CPLPrintStringFill(), CPLPrintInt32(), CPLPrintUIntBig().
70
 *
71
 * Revision 1.22  2003/08/31 14:48:05  dron
72
 * Added CPLScanLong() and CPLScanDouble().
73
 *
74
 * Revision 1.21  2003/08/25 20:01:58  dron
75
 * Added CPLFGets() helper function.
76
 *
77
 * Revision 1.20  2003/05/08 21:51:14  warmerda
78
 * added CPL{G,S}etConfigOption() usage
79
 *
80
 * Revision 1.19  2003/03/02 04:44:38  warmerda
81
 * added CPLStringToComplex
82
 *
83
 * Revision 1.18  2002/12/13 06:00:54  warmerda
84
 * added CPLProjectRelativeFilename() and CPLIsFilenameRelative()
85
 *
86
 * Revision 1.17  2002/12/09 18:52:51  warmerda
87
 * added DMS conversion
88
 *
89
 * Revision 1.16  2002/12/03 04:42:02  warmerda
90
 * improved finder cleanup support
91
 *
92
 * Revision 1.15  2002/08/15 09:23:24  dron
93
 * Added CPLGetDirname() function
94
 *
95
 * Revision 1.14  2002/02/01 20:39:50  warmerda
96
 * ensure CPLReadLine() is exported from DLL
97
 *
98
 * Revision 1.13  2001/12/12 17:06:57  warmerda
99
 * added CPLStat
100
 *
101
 * Revision 1.12  2001/03/16 22:15:08  warmerda
102
 * added CPLResetExtension
103
 *
104
 * Revision 1.1  1998/10/18 06:15:11  warmerda
105
 * Initial implementation.
106
 *
107
 */
108
109
#ifndef CPL_CONV_H_INCLUDED
110
#define CPL_CONV_H_INCLUDED
111
112
#include "cpl_port.h"
113
#include "cpl_vsi.h"
114
#include "cpl_error.h"
115
116
/**
117
 * \file cpl_conv.h
118
 *
119
 * Various convenience functions for CPL.
120
 *
121
 */
122
123
/* -------------------------------------------------------------------- */
124
/*      Runtime check of various configuration items.                   */
125
/* -------------------------------------------------------------------- */
126
CPL_C_START
127
128
void CPL_DLL CPLVerifyConfiguration();
129
130
const char CPL_DLL *CPLGetConfigOption( const char *, const char * );
131
void CPL_DLL        CPLSetConfigOption( const char *, const char * );
132
void CPL_DLL        CPLFreeConfig();
133
134
/* -------------------------------------------------------------------- */
135
/*      Safe malloc() API.  Thin cover over VSI functions with fatal    */
136
/*      error reporting if memory allocation fails.                     */
137
/* -------------------------------------------------------------------- */
138
void CPL_DLL *CPLMalloc( size_t );
139
void CPL_DLL *CPLCalloc( size_t, size_t );
140
void CPL_DLL *CPLRealloc( void *, size_t );
141
char CPL_DLL *CPLStrdup( const char * );
142
143
#define CPLFree VSIFree
144
145
/* -------------------------------------------------------------------- */
146
/*      Read a line from a text file, and strip of CR/LF.               */
147
/* -------------------------------------------------------------------- */
148
char CPL_DLL *CPLFGets( char *, int, FILE *);
149
const char CPL_DLL *CPLReadLine( FILE * );
150
151
/* -------------------------------------------------------------------- */
152
/*      Read a numeric value from an ASCII character string.            */
153
/* -------------------------------------------------------------------- */
154
char CPL_DLL *CPLScanString( const char *, int, int, int );
155
double CPL_DLL CPLScanDouble( const char *, int, char * );
156
long CPL_DLL CPLScanLong( const char *, int );
157
GUIntBig CPL_DLL CPLScanUIntBig( const char *, int );
158
159
/* -------------------------------------------------------------------- */
160
/*      Print a value to an ASCII character string.                     */
161
/* -------------------------------------------------------------------- */
162
int CPL_DLL CPLPrintString( char *, const char *, int );
163
int CPL_DLL CPLPrintStringFill( char *, const char *, int );
164
int CPL_DLL CPLPrintInt32( char *, GInt32 , int );
165
int CPL_DLL CPLPrintUIntBig( char *, GUIntBig , int );
166
int CPL_DLL CPLPrintDouble( char *, const char *, double, char * );
167
int CPL_DLL CPLPrintTime( char *, int , const char *, const struct tm *,
168
                          char * );
169
170
/* -------------------------------------------------------------------- */
171
/*      Fetch a function from DLL / so.                                 */
172
/* -------------------------------------------------------------------- */
173
174
void CPL_DLL *CPLGetSymbol( const char *, const char * );
175
176
/* -------------------------------------------------------------------- */
177
/*      Read a directory  (cpl_dir.c)                                   */
178
/* -------------------------------------------------------------------- */
179
char CPL_DLL  **CPLReadDir( const char *pszPath );
180
181
/* -------------------------------------------------------------------- */
182
/*      Filename handling functions.                                    */
183
/* -------------------------------------------------------------------- */
184
const char CPL_DLL *CPLGetPath( const char * );
185
const char CPL_DLL *CPLGetDirname( const char * );
186
const char CPL_DLL *CPLGetFilename( const char * );
187
const char CPL_DLL *CPLGetBasename( const char * );
188
const char CPL_DLL *CPLGetExtension( const char * );
189
const char CPL_DLL *CPLFormFilename( const char *pszPath,
190
                                     const char *pszBasename,
191
                                     const char *pszExtension );
192
const char CPL_DLL *CPLFormCIFilename( const char *pszPath,
193
                                       const char *pszBasename,
194
                                       const char *pszExtension );
195
const char CPL_DLL *CPLResetExtension( const char *, const char * );
196
const char CPL_DLL *CPLProjectRelativeFilename( const char *pszProjectDir,
197
                                            const char *pszSecondaryFilename );
198
int CPL_DLL CPLIsFilenameRelative( const char *pszFilename );
199
200
/* -------------------------------------------------------------------- */
201
/*      Find File Function                                              */
202
/* -------------------------------------------------------------------- */
203
typedef const char *(*CPLFileFinder)(const char *, const char *);
204
205
const char    CPL_DLL *CPLFindFile(const char *pszClass,
206
                                   const char *pszBasename);
207
const char    CPL_DLL *CPLDefaultFindFile(const char *pszClass,
208
                                          const char *pszBasename);
209
void          CPL_DLL CPLPushFileFinder( CPLFileFinder pfnFinder );
210
CPLFileFinder CPL_DLL CPLPopFileFinder();
211
void          CPL_DLL CPLPushFinderLocation( const char * );
212
void          CPL_DLL CPLPopFinderLocation();
213
void          CPL_DLL CPLFinderClean();
214
215
/* -------------------------------------------------------------------- */
216
/*      Safe version of stat() that works properly on stuff like "C:".  */
217
/* -------------------------------------------------------------------- */
218
int CPL_DLL     CPLStat( const char *, VSIStatBuf * );
219
220
/* -------------------------------------------------------------------- */
221
/*      DMS to Dec to DMS conversion.                                   */
222
/* -------------------------------------------------------------------- */
223
double CPL_DLL CPLDMSToDec( const char *is );
224
const char CPL_DLL *CPLDecToDMS( double dfAngle, const char * pszAxis,
225
                                 int nPrecision );
226
double CPL_DLL CPLPackedDMSToDec( double );
227
double CPL_DLL CPLDecToPackedDMS( double dfDec );
228
229
void CPL_DLL CPLStringToComplex( const char *pszString,
230
                                 double *pdfReal, double *pdfImag );
231
232
CPL_C_END
233
234
#endif /* ndef CPL_CONV_H_INCLUDED */