• 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/HexDump.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 <ostream>
26

27
#include "velocypack/velocypack-common.h"
28
#include "velocypack/HexDump.h"
29

30
using namespace arangodb::velocypack;
31

32
std::string HexDump::toHex(uint8_t value, std::string_view header) {
×
33
  std::string result(header);
×
34
  appendHex(result, value);
×
35
  return result;
×
36
}
37

38
void HexDump::appendHex(std::string& result, uint8_t value) {
×
39
  uint8_t x = value / 16;
×
40
  result.push_back((x < 10 ? ('0' + x) : ('a' + x - 10)));
×
41
  x = value % 16;
×
42
  result.push_back((x < 10 ? ('0' + x) : ('a' + x - 10)));
×
43
}
×
44

45
std::string HexDump::toString() const {
×
46
  std::string result;
×
47
  result.reserve(4 * (length + separator.size()) + (length / valuesPerLine) +
×
48
                 1);
49

50
  uint8_t const* p = data;
×
51
  uint8_t const* e = p + length;
×
52
  int current = 0;
×
53
  while (p < e) {
×
54
    if (current != 0) {
×
55
      result.append(separator);
×
56

57
      if (valuesPerLine > 0 && current == valuesPerLine) {
×
58
        result.push_back('\n');
×
59
        current = 0;
×
60
      }
61
    }
62

63
    result.append(header);
×
64
    appendHex(result, *p++);
×
65
    ++current;
×
66
  }
67

68
  return result;
×
69
}
70

71
namespace arangodb::velocypack {
72

73
std::ostream& operator<<(std::ostream& stream, HexDump const& hexdump) {
×
74
  stream << hexdump.toString();
×
75
  return stream;
×
76
}
77

78
}  // namespace arangodb::velocypack
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