GDAL

nasakeywordhandler.h
1/******************************************************************************
2 *
3 * Project: PDS Driver; Planetary Data System Format
4 * Purpose: Implementation of NASAKeywordHandler - a class to read
5 * keyword data from PDS, ISIS2 and ISIS3 data products.
6 * Author: Frank Warmerdam <warmerdam@pobox.com
7 *
8 ******************************************************************************
9 * Copyright (c) 2006, Frank Warmerdam <warmerdam@pobox.com>
10 * Copyright (c) 2008-2010, Even Rouault <even dot rouault at spatialys.com>
11 * Copyright (c) 2017 Hobu Inc
12 * Copyright (c) 2017, Dmitry Baryshnikov <polimax@mail.ru>
13 * Copyright (c) 2017, NextGIS <info@nextgis.com>
14 *
15 * SPDX-License-Identifier: MIT
16 ****************************************************************************/
17
18#ifndef NASAKEYWORDHANDLER_H
19#define NASAKEYWORDHANDLER_H
20
22
23#include "cpl_json.h"
24#include "cpl_string.h"
25
26/************************************************************************/
27/* ==================================================================== */
28/* NASAKeywordHandler */
29/* ==================================================================== */
30/************************************************************************/
31
32// Only exported for HDF4 plugin needs. Do not use outside of GDAL please.
33
34 class CPL_DLL NASAKeywordHandler
35{
36 CPLStringList aosKeywordList{};
37
38 const char *pszHeaderNext = nullptr;
39
40 CPLJSONObject oJSon{};
41
42 bool m_bStripSurroundingQuotes = false;
43
44 void SkipWhite();
45 bool ReadWord(CPLString &osWord, bool bStripSurroundingQuotes = false,
46 bool bParseList = false, bool *pbIsString = nullptr);
47 bool ReadPair(CPLString &osName, CPLString &osValue, CPLJSONObject &oCur);
48 bool ReadGroup(const std::string &osPathPrefix, CPLJSONObject &oCur,
49 int nRecLevel);
50
51 NASAKeywordHandler(const NASAKeywordHandler &) = delete;
52 NASAKeywordHandler &operator=(const NASAKeywordHandler &) = delete;
53
54 public:
55 NASAKeywordHandler();
56 ~NASAKeywordHandler();
57
58 void SetStripSurroundingQuotes(bool bStripSurroundingQuotes)
59 {
60 m_bStripSurroundingQuotes = bStripSurroundingQuotes;
61 }
62
63 bool Ingest(VSILFILE *fp, int nOffset);
64 bool Parse(const char *pszStr);
65
66 const char *GetKeyword(const char *pszPath, const char *pszDefault);
67 char **GetKeywordList();
68 CPLJSONObject GetJsonObject() const;
69};
70
72
73#endif // NASAKEYWORDHANDLER_H
CPLJSONObject
The CPLJSONArray class holds JSON object from CPLJSONDocument.
Definition cpl_json.h:41
CPLStringList
String list class designed around our use of C "char**" string lists.
Definition cpl_string.h:436
CPLString
Convenient string class based on std::string.
Definition cpl_string.h:307
cpl_json.h
Interface for read and write JSON documents.
cpl_string.h
Various convenience functions for working with strings and string lists.
VSIVirtualHandle
Virtual file handle.
Definition cpl_vsi_virtual.h:47