Statistics
| Revision:

svn-gvsig-desktop / tags / v1_0_RELEASE / libraries / libjni-gdal / include / cpl_string.h @ 9167

History | View | Annotate | Download (7.13 KB)

1
/**********************************************************************
2
 * $Id: cpl_string.h 9167 2006-12-04 16:01:24Z  $
3
 *
4
 * Name:     cpl_string.h
5
 * Project:  CPL - Common Portability Library
6
 * Purpose:  String and StringList functions.
7
 * Author:   Daniel Morissette, danmo@videotron.ca
8
 *
9
 **********************************************************************
10
 * Copyright (c) 1998, Daniel Morissette
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 OR
23
 * 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.2.10.2  2006-11-15 00:08:29  jjdelcerro
33
 * *** empty log message ***
34
 *
35
 * Revision 1.3  2006/10/03 07:05:18  nacho
36
 * *** empty log message ***
37
 *
38
 * Revision 1.1  2006/07/18 16:21:00  nacho
39
 * *** empty log message ***
40
 *
41
 * Revision 1.1  2006/06/29 16:23:27  nacho
42
 * *** empty log message ***
43
 *
44
 * Revision 1.2  2006/01/09 12:50:13  nacho
45
 * *** empty log message ***
46
 *
47
 * Revision 1.1  2005/07/27 08:22:55  igbrotru
48
 * *** empty log message ***
49
 *
50
 * Revision 1.1  2004/12/28 14:06:59  igbrotru
51
 * *** empty log message ***
52
 *
53
 * Revision 1.1  2004/10/28 12:08:47  igbrotru
54
 * *** empty log message ***
55
 *
56
 * Revision 1.1  2004/09/27 08:27:48  igbrotru
57
 * *** empty log message ***
58
 *
59
 * Revision 1.1  2004/09/08 12:39:04  igbrotru
60
 * *** empty log message ***
61
 *
62
 * Revision 1.15  2003/07/17 10:15:40  dron
63
 * CSLTestBoolean() added.
64
 *
65
 * Revision 1.14  2003/03/11 21:33:03  warmerda
66
 * added URL encode/decode support, untested
67
 *
68
 * Revision 1.13  2003/01/30 19:15:55  warmerda
69
 * added some docs
70
 *
71
 * Revision 1.12  2002/07/12 22:37:05  warmerda
72
 * added CSLFetchBoolean
73
 *
74
 * Revision 1.11  2002/05/28 18:53:43  warmerda
75
 * added XML escaping support
76
 *
77
 * Revision 1.10  2002/04/26 14:55:26  warmerda
78
 * Added CPLEscapeString() and CPLUnescapeString() (unescape untested)
79
 *
80
 * Revision 1.9  2002/03/05 14:26:57  warmerda
81
 * expanded tabs
82
 *
83
 * Revision 1.8  2002/01/16 03:59:28  warmerda
84
 * added CPLTokenizeString2
85
 *
86
 * Revision 1.7  2000/10/06 15:19:03  warmerda
87
 * added CPLSetNameValueSeparator
88
 *
89
 * Revision 1.6  2000/04/26 18:25:10  warmerda
90
 * implement CPL_DLL
91
 *
92
 * Revision 1.5  2000/03/30 05:38:48  warmerda
93
 * added CPLParseNameValue
94
 *
95
 * Revision 1.4  1999/06/26 14:05:19  warmerda
96
 * Added CSLFindString().
97
 *
98
 * Revision 1.3  1999/02/17 01:41:58  warmerda
99
 * Added CSLGetField
100
 *
101
 * Revision 1.2  1998/12/04 21:40:42  danmo
102
 * Added more Name=Value manipulation fuctions
103
 *
104
 * Revision 1.1  1998/12/03 18:26:02  warmerda
105
 * New
106
 *
107
 **********************************************************************/
108

    
109
#ifndef _CPL_STRING_H_INCLUDED
110
#define _CPL_STRING_H_INCLUDED
111

    
112
#include "cpl_vsi.h"
113
#include "cpl_error.h"
114
#include "cpl_conv.h"
115

    
116
/**
117
 * \file cpl_string.h
118
 *
119
 * Various convenience functions for working with strings and string lists. 
120
 *
121
 * A StringList is just an array of strings with the last pointer being
122
 * NULL.  An empty StringList may be either a NULL pointer, or a pointer to
123
 * a pointer memory location with a NULL value.
124
 *
125
 * A common convention for StringLists is to use them to store name/value
126
 * lists.  In this case the contents are treated like a dictionary of
127
 * name/value pairs.  The actual data is formatted with each string having
128
 * the format "<name>:<value>" (though "=" is also an acceptable separator). 
129
 * A number of the functions in the file operate on name/value style
130
 * string lists (such as CSLSetNameValue(), and CSLFetchNameValue()). 
131
 *
132
 */
133

    
134
CPL_C_START
135

    
136
char CPL_DLL **CSLAddString(char **papszStrList, const char *pszNewString);
137
int CPL_DLL CSLCount(char **papszStrList);
138
const char CPL_DLL *CSLGetField( char **, int );
139
void CPL_DLL CSLDestroy(char **papszStrList);
140
char CPL_DLL **CSLDuplicate(char **papszStrList);
141

    
142
char CPL_DLL **CSLTokenizeString(const char *pszString );
143
char CPL_DLL **CSLTokenizeStringComplex(const char *pszString,
144
                                   const char *pszDelimiter,
145
                                   int bHonourStrings, int bAllowEmptyTokens );
146
char CPL_DLL **CSLTokenizeString2( const char *pszString, 
147
                                   const char *pszDelimeter, 
148
                                   int nCSLTFlags );
149

    
150
#define CSLT_HONOURSTRINGS      0x0001
151
#define CSLT_ALLOWEMPTYTOKENS   0x0002
152
#define CSLT_PRESERVEQUOTES     0x0004
153
#define CSLT_PRESERVEESCAPES    0x0008
154

    
155
int CPL_DLL CSLPrint(char **papszStrList, FILE *fpOut);
156
char CPL_DLL **CSLLoad(const char *pszFname);
157
int CPL_DLL CSLSave(char **papszStrList, const char *pszFname);
158

    
159
char CPL_DLL **CSLInsertStrings(char **papszStrList, int nInsertAtLineNo, 
160
                         char **papszNewLines);
161
char CPL_DLL **CSLInsertString(char **papszStrList, int nInsertAtLineNo, 
162
                        char *pszNewLine);
163
char CPL_DLL **CSLRemoveStrings(char **papszStrList, int nFirstLineToDelete,
164
                         int nNumToRemove, char ***ppapszRetStrings);
165
int CPL_DLL CSLFindString( char **, const char * );
166
int CPL_DLL CSLTestBoolean( const char *pszValue );
167
int CPL_DLL CSLFetchBoolean( char **papszStrList, const char *pszKey, 
168
                             int bDefault );
169

    
170
const char CPL_DLL *CPLSPrintf(char *fmt, ...);
171
char CPL_DLL **CSLAppendPrintf(char **papszStrList, char *fmt, ...);
172

    
173
const char CPL_DLL *
174
      CPLParseNameValue(const char *pszNameValue, char **ppszKey );
175
const char CPL_DLL *
176
      CSLFetchNameValue(char **papszStrList, const char *pszName);
177
char CPL_DLL **
178
      CSLFetchNameValueMultiple(char **papszStrList, const char *pszName);
179
char CPL_DLL **
180
      CSLAddNameValue(char **papszStrList, 
181
                      const char *pszName, const char *pszValue);
182
char CPL_DLL **
183
      CSLSetNameValue(char **papszStrList, 
184
                      const char *pszName, const char *pszValue);
185
void CPL_DLL CSLSetNameValueSeparator( char ** papszStrList, 
186
                                       const char *pszSeparator );
187

    
188
#define CPLES_BackslashQuotable 0
189
#define CPLES_XML               1
190
#define CPLES_URL               2   /* unescape only for now */
191

    
192
char CPL_DLL *CPLEscapeString( const char *pszString, int nLength, 
193
                               int nScheme );
194
char CPL_DLL *CPLUnescapeString( const char *pszString, int *pnLength,
195
                                 int nScheme );
196

    
197
CPL_C_END
198

    
199
#endif /* _CPL_STRING_H_INCLUDED */