Statistics
| Revision:

svn-gvsig-desktop / tags / v1_9_Build_1247 / libraries / libjni-gdal-macosx / include / cpl_string.h @ 44527

History | View | Annotate | Download (6.97 KB)

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

    
103
#ifndef _CPL_STRING_H_INCLUDED
104
#define _CPL_STRING_H_INCLUDED
105

    
106
#include "cpl_vsi.h"
107
#include "cpl_error.h"
108
#include "cpl_conv.h"
109

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

    
128
CPL_C_START
129

    
130
char CPL_DLL **CSLAddString(char **papszStrList, const char *pszNewString);
131
int CPL_DLL CSLCount(char **papszStrList);
132
const char CPL_DLL *CSLGetField( char **, int );
133
void CPL_DLL CSLDestroy(char **papszStrList);
134
char CPL_DLL **CSLDuplicate(char **papszStrList);
135

    
136
char CPL_DLL **CSLTokenizeString(const char *pszString );
137
char CPL_DLL **CSLTokenizeStringComplex(const char *pszString,
138
                                   const char *pszDelimiter,
139
                                   int bHonourStrings, int bAllowEmptyTokens );
140
char CPL_DLL **CSLTokenizeString2( const char *pszString, 
141
                                   const char *pszDelimeter, 
142
                                   int nCSLTFlags );
143

    
144
#define CSLT_HONOURSTRINGS      0x0001
145
#define CSLT_ALLOWEMPTYTOKENS   0x0002
146
#define CSLT_PRESERVEQUOTES     0x0004
147
#define CSLT_PRESERVEESCAPES    0x0008
148

    
149
int CPL_DLL CSLPrint(char **papszStrList, FILE *fpOut);
150
char CPL_DLL **CSLLoad(const char *pszFname);
151
int CPL_DLL CSLSave(char **papszStrList, const char *pszFname);
152

    
153
char CPL_DLL **CSLInsertStrings(char **papszStrList, int nInsertAtLineNo, 
154
                         char **papszNewLines);
155
char CPL_DLL **CSLInsertString(char **papszStrList, int nInsertAtLineNo, 
156
                        char *pszNewLine);
157
char CPL_DLL **CSLRemoveStrings(char **papszStrList, int nFirstLineToDelete,
158
                         int nNumToRemove, char ***ppapszRetStrings);
159
int CPL_DLL CSLFindString( char **, const char * );
160
int CPL_DLL CSLTestBoolean( const char *pszValue );
161
int CPL_DLL CSLFetchBoolean( char **papszStrList, const char *pszKey, 
162
                             int bDefault );
163

    
164
const char CPL_DLL *CPLSPrintf(char *fmt, ...);
165
char CPL_DLL **CSLAppendPrintf(char **papszStrList, char *fmt, ...);
166

    
167
const char CPL_DLL *
168
      CPLParseNameValue(const char *pszNameValue, char **ppszKey );
169
const char CPL_DLL *
170
      CSLFetchNameValue(char **papszStrList, const char *pszName);
171
char CPL_DLL **
172
      CSLFetchNameValueMultiple(char **papszStrList, const char *pszName);
173
char CPL_DLL **
174
      CSLAddNameValue(char **papszStrList, 
175
                      const char *pszName, const char *pszValue);
176
char CPL_DLL **
177
      CSLSetNameValue(char **papszStrList, 
178
                      const char *pszName, const char *pszValue);
179
void CPL_DLL CSLSetNameValueSeparator( char ** papszStrList, 
180
                                       const char *pszSeparator );
181

    
182
#define CPLES_BackslashQuotable 0
183
#define CPLES_XML               1
184
#define CPLES_URL               2   /* unescape only for now */
185

    
186
char CPL_DLL *CPLEscapeString( const char *pszString, int nLength, 
187
                               int nScheme );
188
char CPL_DLL *CPLUnescapeString( const char *pszString, int *pnLength,
189
                                 int nScheme );
190

    
191
CPL_C_END
192

    
193
#endif /* _CPL_STRING_H_INCLUDED */