• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

arangodb / velocypack / 3998645281

pending completion
3998645281

Pull #148

github

GitHub
Merge b1e3c924b into 5a28b6413
Pull Request #148: use separate namespace for xxh functions

0 of 5107 relevant lines covered (0.0%)

0.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Utf8Helper.cpp
1
////////////////////////////////////////////////////////////////////////////////
2
/// DISCLAIMER
3
///
4
/// Copyright 2014-2020 ArangoDB GmbH, Cologne, Germany
5
/// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany
6
///
7
/// Licensed under the Apache License, Version 2.0 (the "License");
8
/// you may not use this file except in compliance with the License.
9
/// You may obtain a copy of the License at
10
///
11
///     http://www.apache.org/licenses/LICENSE-2.0
12
///
13
/// Unless required by applicable law or agreed to in writing, software
14
/// distributed under the License is distributed on an "AS IS" BASIS,
15
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
/// See the License for the specific language governing permissions and
17
/// limitations under the License.
18
///
19
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
20
///
21
/// @author Max Neunhoeffer
22
/// @author Jan Steemann
23
////////////////////////////////////////////////////////////////////////////////
24

25
#include "velocypack/velocypack-common.h"
26
#include "velocypack/Utf8Helper.h"
27

28
using namespace arangodb::velocypack;
29

30
namespace {
31

32
static constexpr uint8_t ValidChar = 0;
33
static constexpr uint8_t InvalidChar = 1;
34

35
static const uint8_t states[] = {
36
    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
37
    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
38
    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  // 00..1f
39
    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
40
    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
41
    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  // 20..3f
42
    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
43
    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
44
    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  // 40..5f
45
    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
46
    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
47
    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  // 60..7f
48
    1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,
49
    1,   1,   1,   1,   1,   9,   9,   9,   9,   9,   9,
50
    9,   9,   9,   9,   9,   9,   9,   9,   9,   9,  // 80..9f
51
    7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,
52
    7,   7,   7,   7,   7,   7,   7,   7,   7,   7,   7,
53
    7,   7,   7,   7,   7,   7,   7,   7,   7,   7,  // a0..bf
54
    8,   8,   2,   2,   2,   2,   2,   2,   2,   2,   2,
55
    2,   2,   2,   2,   2,   2,   2,   2,   2,   2,   2,
56
    2,   2,   2,   2,   2,   2,   2,   2,   2,   2,  // c0..df
57
    0xa, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3,
58
    0x3, 0x3, 0x4, 0x3, 0x3,  // e0..ef
59
    0xb, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
60
    0x8, 0x8, 0x8, 0x8, 0x8,  // f0..ff
61
    0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4,
62
    0x6, 0x1, 0x1, 0x1, 0x1,  // s0..s0
63
    1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,
64
    1,   1,   1,   1,   1,   1,   0,   1,   1,   1,   1,
65
    1,   0,   1,   0,   1,   1,   1,   1,   1,   1,  // s1..s2
66
    1,   2,   1,   1,   1,   1,   1,   2,   1,   2,   1,
67
    1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,
68
    1,   2,   1,   1,   1,   1,   1,   1,   1,   1,  // s3..s4
69
    1,   2,   1,   1,   1,   1,   1,   1,   1,   2,   1,
70
    1,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1,
71
    1,   3,   1,   3,   1,   1,   1,   1,   1,   1,  // s5..s6
72
    1,   3,   1,   1,   1,   1,   1,   3,   1,   3,   1,
73
    1,   1,   1,   1,   1,   1,   3,   1,   1,   1,   1,
74
    1,   1,   1,   1,   1,   1,   1,   1,   1,   1,  // s7..s8
75
};
76

77
}  // namespace
78

79
bool Utf8Helper::isValidUtf8(uint8_t const* p, ValueLength len) {
×
80
  uint8_t const* end = p + len;
×
81
  uint8_t state = ValidChar;
×
82

83
  while (p < end) {
×
84
    state = states[256 + state * 16 + states[*p++]];
×
85
    if (state == InvalidChar) {
×
86
      return false;
×
87
    }
88
  }
89

90
  return (state == ValidChar);
×
91
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc