LCOV - code coverage report
Current view: top level - frmts/pds - json_utils.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 10 10 100.0 %
Date: 2025-08-01 10:10:57 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        1668 :     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        1474 :         CPLJSONObject oNewChild;
      25         737 :         oParent.Add(osKey, oNewChild);
      26         737 :         return oNewChild;
      27             :     }
      28             : 
      29          97 :     return oChild;
      30             : }
      31             : 
      32             : #endif /* JSON_UTILS_H_INCLUDED */

Generated by: LCOV version 1.14