LIEF: Library to Instrument Executable Formats Version 0.17.0
Loading...
Searching...
No Matches
range.hpp
Go to the documentation of this file.
1/* Copyright 2024 R. Thomas
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15#ifndef LIEF_RANGE_H
16#define LIEF_RANGE_H
17#include <cstdint>
18#include <ostream>
19
20#include "LIEF/visibility.h"
21
22namespace LIEF {
23struct range_t {
24 uint64_t low = 0;
25 uint64_t high = 0;
26
27 bool contains(uint64_t value, bool strict = true) const {
28 if (strict) {
29 return low <= value && value < high;
30 }
31 return low <= value && value <= high;
32 }
33
34 uint64_t size() const {
35 return high - low;
36 }
37
38 friend bool operator==(const range_t& lhs, const range_t& rhs) {
39 return lhs.high == rhs.high && lhs.low == rhs.low;
40 }
41
42 friend bool operator!=(const range_t& lhs, const range_t& rhs) {
43 return !(lhs == rhs);
44 }
45
46 friend LIEF_API
47 std::ostream& operator<<(std::ostream& os, const range_t& range);
48};
49
50}
51#endif
LIEF namespace.
Definition Abstract/Binary.hpp:36
Definition range.hpp:23
friend std::ostream & operator<<(std::ostream &os, const range_t &range)
uint64_t size() const
Definition range.hpp:34
uint64_t low
Definition range.hpp:24
uint64_t high
Definition range.hpp:25
friend bool operator==(const range_t &lhs, const range_t &rhs)
Definition range.hpp:38
bool contains(uint64_t value, bool strict=true) const
Definition range.hpp:27
friend bool operator!=(const range_t &lhs, const range_t &rhs)
Definition range.hpp:42
#define LIEF_API
Definition visibility.h:41