LIEF: Library to Instrument Executable Formats Version 2.0.0
Loading...
Searching...
No Matches
Field.hpp
Go to the documentation of this file.
1/* Copyright 2021 - 2026 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_DEX_FIELD_H
16#define LIEF_DEX_FIELD_H
17
18#include <string_view>
19#include <climits>
20#include <cstdint>
21
22#include "LIEF/DEX/enums.hpp"
23
24#include "LIEF/Object.hpp"
25#include "LIEF/visibility.h"
26
27#include "LIEF/DEX/Type.hpp"
28
29
30namespace LIEF::DEX {
31class Parser;
32class Class;
33
35class LIEF_API Field : public Object {
36 friend class Parser;
37
38 public:
39 using access_flags_list_t = std::vector<ACCESS_FLAGS>;
40
41 public:
43 Field(std::string name, Class* parent = nullptr);
44
45 Field(const Field&);
47
49 std::string_view name() const;
50
53 bool has_class() const;
54
58
60 size_t index() const;
61
63 bool is_static() const;
64
68
69 void accept(Visitor& visitor) const override;
70
72 bool has(ACCESS_FLAGS f) const;
73
76
77
78 LIEF_API friend std::ostream& operator<<(std::ostream& os, const Field& mtd);
79
80 ~Field() override;
81
82 private:
83 void set_static(bool v);
84
85 private:
86 std::string name_;
87 Class* parent_ = nullptr;
88 Type* type_ = nullptr;
89 uint32_t access_flags_ = 0;
90 uint32_t original_index_ = UINT_MAX;
91 bool is_static_ = false;
92};
93
94} // Namespace DEX
95// Namespace LIEF
96#endif
Class which represents a DEX Class (i.e. a Java/Kotlin class).
Definition DEX/Class.hpp:37
bool has(ACCESS_FLAGS f) const
Check if the field has the given ACCESS_FLAGS.
const Class * cls() const
Class associated with this Field.
access_flags_list_t access_flags() const
ACCESS_FLAGS as a list.
Field(std::string name, Class *parent=nullptr)
bool is_static() const
True if this field is a static one.
bool has_class() const
True if a class is associated with this field (which should be the case).
size_t index() const
Index in the DEX Fields pool.
std::string_view name() const
Name of the Field.
Field(const Field &)
Field & operator=(const Field &)
std::vector< ACCESS_FLAGS > access_flags_list_t
Definition Field.hpp:39
void accept(Visitor &visitor) const override
friend class Parser
Definition Field.hpp:36
const Type * type() const
Field's prototype.
Class which parses a DEX file to produce a DEX::File object.
Definition DEX/Parser.hpp:38
Class which represents a DEX type as described in the format specifications: https://source....
Definition DEX/Type.hpp:34
Definition Visitor.hpp:212
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
Definition DEX/Class.hpp:31
ACCESS_FLAGS
Definition DEX/enums.hpp:22
#define LIEF_API
Definition visibility.h:45