Coverage Report

Created: 2026-01-25 07:08

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wpantund/src/util/Data.h
Line
Count
Source
1
/*
2
 *
3
 * Copyright (c) 2016 Nest Labs, Inc.
4
 * All rights reserved.
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 *
18
 *    Description:
19
 *      Class definition for binary data container.
20
 *
21
 */
22
23
#ifndef __wpantund__Data__
24
#define __wpantund__Data__
25
26
#include <vector>
27
#include <stdint.h>
28
#include <stdlib.h>
29
30
namespace nl {
31
class Data : public std::vector<uint8_t> {
32
public:
33
0
  Data(const std::vector<uint8_t>& x) : std::vector<uint8_t>(x) {
34
0
  }
35
  Data(
36
      const uint8_t* ptr, size_t len
37
18.4k
      ) : std::vector<uint8_t>(ptr, ptr + len) {
38
18.4k
  }
39
40
  template<typename _InputIterator>
41
  Data(_InputIterator __first, _InputIterator __last)
42
  : std::vector<uint8_t>(__first, __last) { }
43
44
181k
  Data(size_t len = 0) : std::vector<uint8_t>(len) {
45
181k
  }
46
47
2.84k
  Data& append(const Data& d) {
48
2.84k
    insert(end(),d.begin(),d.end());
49
2.84k
    return *this;
50
2.84k
  }
51
52
714
  Data& append(const uint8_t* ptr, size_t len) {
53
714
    insert(end(),ptr,ptr+len);
54
714
    return *this;
55
714
  }
56
57
0
  void pop_front(size_t len) {
58
0
    erase(begin(), begin()+len);
59
0
  }
60
61
53.2k
  uint8_t* data() {
62
53.2k
    return empty() ? NULL : &*begin();
63
53.2k
  }
64
65
289
  const uint8_t* data() const {
66
289
    return empty() ? NULL : &*begin();
67
289
  }
68
};
69
};
70
71
#endif /* defined(__wpantund__Data__) */