Coverage Report

Created: 2026-08-14 09:29

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/gdal/frmts/zarr/vsikerchunk_inline.hpp
Line
Count
Source
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
ZARRIsLikelyStreamableKerchunkJSONRefContent(const std::string_view &str)
20
152
{
21
    // v0
22
152
    for (const char *pszExpectedPrefix : {"{\".zgroup\":{", "{\".zgroup\":\"{",
23
152
                                          "{\".zattrs\":{", "{\".zattrs\":\"{"})
24
608
    {
25
608
        for (char ch : str)
26
18.9k
        {
27
18.9k
            if (!(ch == ' ' || ch == '\n' || ch == '\r'))
28
612
            {
29
612
                if (ch != *pszExpectedPrefix)
30
592
                    break;
31
20
                ++pszExpectedPrefix;
32
20
                if (*pszExpectedPrefix == 0)
33
0
                {
34
0
                    return true;
35
0
                }
36
20
            }
37
18.9k
        }
38
608
    }
39
40
152
    {
41
        // v1
42
152
        const char *pszExpectedPrefix = "{\"version\":1,\"refs\":{";
43
152
        for (char ch : str)
44
4.74k
        {
45
4.74k
            if (!(ch == ' ' || ch == '\n' || ch == '\r'))
46
153
            {
47
153
                if (ch != *pszExpectedPrefix)
48
148
                    break;
49
5
                ++pszExpectedPrefix;
50
5
                if (*pszExpectedPrefix == 0)
51
0
                {
52
0
                    return str.find("\".zgroup\"") != std::string::npos ||
53
0
                           str.find("\".zarray\"") != std::string::npos;
54
0
                }
55
5
            }
56
4.74k
        }
57
152
    }
58
152
    return false;
59
152
}
60
61
#endif