LCOV - code coverage report
Current view: top level - frmts/pds - json_utils.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 9 9 100.0 %
Date: 2024-05-03 15:49:35 Functions: 1 1 100.0 %

          Line data    Source code
       1             : #ifndef JSON_UTILS_H_INCLUDED
       2             : #define JSON_UTILS_H_INCLUDED
       3             : 
       4             : #include "cpl_json.h"
       5             : 
       6             : /**
       7             :  * Get or create CPLJSONObject.
       8             :  * @param  oParent Parent CPLJSONObject.
       9             :  * @param  osKey  Key name.
      10             :  * @return         CPLJSONObject class instance.
      11             :  */
      12         834 : static CPLJSONObject GetOrCreateJSONObject(CPLJSONObject &oParent,
      13             :                                            const std::string &osKey)
      14             : {
      15         834 :     CPLJSONObject oChild = oParent[osKey];
      16         834 :     if (oChild.IsValid() && oChild.GetType() != CPLJSONObject::Type::Object)
      17             :     {
      18           5 :         oParent.Delete(osKey);
      19           5 :         oChild.Deinit();
      20             :     }
      21             : 
      22         834 :     if (!oChild.IsValid())
      23             :     {
      24         737 :         oChild = CPLJSONObject();
      25         737 :         oParent.Add(osKey, oChild);
      26             :     }
      27         834 :     return oChild;
      28             : }
      29             : 
      30             : #endif /* JSON_UTILS_H_INCLUDED */

Generated by: LCOV version 1.14