cplkeywordparser.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. #ifndef CPL_KEYWORD_PARSER
  33. #define CPL_KEYWORD_PARSER
  34. #include "cpl_string.h"
  35. /************************************************************************/
  36. /* ==================================================================== */
  37. /* CPLKeywordParser */
  38. /* ==================================================================== */
  39. /************************************************************************/
  40. class CPLKeywordParser
  41. {
  42. char **papszKeywordList;
  43. CPLString osHeaderText;
  44. const char *pszHeaderNext;
  45. void SkipWhite();
  46. int ReadWord( CPLString &osWord );
  47. int ReadPair( CPLString &osName, CPLString &osValue );
  48. int ReadGroup( const char *pszPathPrefix );
  49. public:
  50. CPLKeywordParser();
  51. ~CPLKeywordParser();
  52. int Ingest( VSILFILE *fp );
  53. const char *GetKeyword( const char *pszPath, const char *pszDefault=NULL );
  54. char **GetAllKeywords() { return papszKeywordList; }
  55. };
  56. #endif /* def CPL_KEYWORD_PARSER */