LCOV - code coverage report
Current view: top level - frmts/zarr - vsikerchunk_inline.hpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 20 20 100.0 %
Date: 2025-06-19 12:30:01 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  GDAL
       4             :  * Purpose:  Zarr driver
       5             :  * Author:   Even Rouault <even dot rouault at spatialys.com>
       6             :  *
       7             :  ******************************************************************************
       8             :  * Copyright (c) 2025, Even Rouault <even dot rouault at spatialys.com>
       9             :  *
      10             :  * SPDX-License-Identifier: MIT
      11             :  ****************************************************************************/
      12             : 
      13             : #ifndef VSIKERCHUNK_INLINE_HPP
      14             : #define VSIKERCHUNK_INLINE_HPP
      15             : 
      16             : #include <string_view>
      17             : 
      18             : inline bool
      19         103 : ZARRIsLikelyStreamableKerchunkJSONRefContent(const std::string_view &str)
      20             : {
      21             :     // v0
      22          48 :     for (const char *pszExpectedPrefix : {"{\".zgroup\":{", "{\".zgroup\":\"{",
      23         151 :                                           "{\".zattrs\":{", "{\".zattrs\":\"{"})
      24             :     {
      25       97407 :         for (char ch : str)
      26             :         {
      27       97387 :             if (!(ch == ' ' || ch == '\n' || ch == '\r'))
      28             :             {
      29        1192 :                 if (ch != *pszExpectedPrefix)
      30          28 :                     break;
      31        1164 :                 ++pszExpectedPrefix;
      32        1164 :                 if (*pszExpectedPrefix == 0)
      33             :                 {
      34          91 :                     return true;
      35             :                 }
      36             :             }
      37             :         }
      38             :     }
      39             : 
      40             :     {
      41             :         // v1
      42          12 :         const char *pszExpectedPrefix = "{\"version\":1,\"refs\":{";
      43       24169 :         for (char ch : str)
      44             :         {
      45       24164 :             if (!(ch == ' ' || ch == '\n' || ch == '\r'))
      46             :             {
      47         115 :                 if (ch != *pszExpectedPrefix)
      48           3 :                     break;
      49         112 :                 ++pszExpectedPrefix;
      50         112 :                 if (*pszExpectedPrefix == 0)
      51             :                 {
      52           4 :                     return str.find("\".zgroup\"") != std::string::npos ||
      53           4 :                            str.find("\".zarray\"") != std::string::npos;
      54             :                 }
      55             :             }
      56             :         }
      57             :     }
      58           8 :     return false;
      59             : }
      60             : 
      61             : #endif

Generated by: LCOV version 1.14