Line data Source code
1 : /****************************************************************************** 2 : * 3 : * Project: VICAR Driver; JPL/MIPL VICAR Format 4 : * Purpose: Implementation of VICARKeywordHandler - a class to read 5 : * keyword data from VICAR data products. 6 : * Authors: Sebastian Walter <sebastian dot walter at fu-berlin dot de> 7 : * 8 : * NOTE: This driver code is loosely based on the ISIS and PDS drivers. 9 : * It is not intended to diminish the contribution of the authors. 10 : ****************************************************************************** 11 : * Copyright (c) 2014, Sebastian Walter <sebastian dot walter at fu-berlin dot 12 : *de> 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 VICARKEYWORDHANDLER_H 34 : #define VICARKEYWORDHANDLER_H 35 : 36 : #include "cpl_json.h" 37 : 38 : class VICARKeywordHandler 39 : { 40 : char **papszKeywordList; 41 : 42 : CPLString osHeaderText; 43 : const char *pszHeaderNext; 44 : 45 : CPLJSONObject oJSon; 46 : 47 : void SkipWhite(); 48 : bool ReadName(CPLString &osWord); 49 : bool ReadValue(CPLString &osWord, bool bInList, bool &bIsString); 50 : bool ReadPair(CPLString &osName, CPLString &osValue, CPLJSONObject &oCur); 51 : bool Parse(); 52 : 53 : public: 54 : VICARKeywordHandler(); 55 : ~VICARKeywordHandler(); 56 : 57 : bool Ingest(VSILFILE *fp, const GByte *pabyHeader); 58 : 59 : const char *GetKeyword(const char *pszPath, const char *pszDefault) const; 60 : 61 112 : const CPLJSONObject &GetJsonObject() const 62 : { 63 112 : return oJSon; 64 : } 65 : }; 66 : 67 : #endif // VICARKEYWORDHANDLER_H