Coverage Report

Created: 2025-11-11 06:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/spotify-json/include/spotify/json/decode_context.hpp
Line
Count
Source
1
/*
2
 * Copyright (c) 2014-2019 Spotify AB
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5
 * use this file except in compliance with the License. You may obtain a copy of
6
 * the License at
7
 *
8
 * http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
 * License for the specific language governing permissions and limitations under
14
 * the License.
15
 */
16
17
#pragma once
18
19
#include <cstddef>
20
#include <spotify/json/decode_exception.hpp>
21
#include <spotify/json/detail/cpuid.hpp>
22
#include <spotify/json/detail/macros.hpp>
23
24
namespace spotify {
25
namespace json {
26
27
/**
28
 * A decode_context has the information that is kept while decoding JSON with
29
 * codecs. It has information about the data to read and whether the decoding
30
 * has failed.
31
 */
32
struct decode_context final {
33
  decode_context(const char *begin, const char *end);
34
  decode_context(const char *data, size_t size);
35
36
2.32k
  json_force_inline size_t offset() const {
37
2.32k
    return (position - begin);
38
2.32k
  }
39
40
2.32k
  json_force_inline size_t offset(const ptrdiff_t d) const {
41
2.32k
    return offset() + d;
42
2.32k
  }
43
44
1.73M
  json_force_inline size_t remaining() const {
45
1.73M
    return (end - position);
46
1.73M
  }
47
48
  const bool has_sse42;
49
  const char *position;
50
  const char *const begin;
51
  const char *const end;
52
};
53
54
}  // namespace json
55
}  // namespace spotify