1 : /******************************************************************************
2 : * $Id: cplkeywordparser.h 20996 2010-10-28 18:38:15Z rouault $
3 : *
4 : * Project: Common Portability Library
5 : * Purpose: Implementation of CPLKeywordParser - a class for parsing
6 : * the keyword format used for files like QuickBird .RPB files.
7 : * This is a slight variation on the NASAKeywordParser used for
8 : * the PDS/ISIS2/ISIS3 formats.
9 : * Author: Frank Warmerdam <warmerdam@pobox.com
10 : *
11 : ******************************************************************************
12 : * Copyright (c) 2008, Frank Warmerdam <warmerdam@pobox.com>
13 : *
14 : * Permission is hereby granted, free of charge, to any person obtaining a
15 : * copy of this software and associated documentation files (the "Software"),
16 : * to deal in the Software without restriction, including without limitation
17 : * the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 : * and/or sell copies of the Software, and to permit persons to whom the
19 : * Software is furnished to do so, subject to the following conditions:
20 : *
21 : * The above copyright notice and this permission notice shall be included
22 : * in all copies or substantial portions of the Software.
23 : *
24 : * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 : * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 : * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 : * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 : * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 : * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 : * DEALINGS IN THE SOFTWARE.
31 : ****************************************************************************/
32 :
33 : #ifndef CPL_KEYWORD_PARSER
34 : #define CPL_KEYWORD_PARSER
35 :
36 : #include "cpl_string.h"
37 :
38 : /************************************************************************/
39 : /* ==================================================================== */
40 : /* CPLKeywordParser */
41 : /* ==================================================================== */
42 : /************************************************************************/
43 :
44 : class CPLKeywordParser
45 : {
46 : char **papszKeywordList;
47 :
48 : CPLString osHeaderText;
49 : const char *pszHeaderNext;
50 :
51 : void SkipWhite();
52 : int ReadWord( CPLString &osWord );
53 : int ReadPair( CPLString &osName, CPLString &osValue );
54 : int ReadGroup( const char *pszPathPrefix );
55 :
56 : public:
57 : CPLKeywordParser();
58 : ~CPLKeywordParser();
59 :
60 : int Ingest( VSILFILE *fp );
61 :
62 : const char *GetKeyword( const char *pszPath, const char *pszDefault=NULL );
63 12 : char **GetAllKeywords() { return papszKeywordList; }
64 : };
65 :
66 : #endif /* def CPL_KEYWORD_PARSER */
|