LIEF: Library to Instrument Executable Formats Version 0.15.0
Loading...
Searching...
No Matches
Field.hpp
1/* Copyright 2021 - 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_DEX_FIELD_H
16#define LIEF_DEX_FIELD_H
17
18#include <climits>
19#include <cstdint>
20
21#include "LIEF/DEX/enums.hpp"
22
23#include "LIEF/visibility.h"
24#include "LIEF/Object.hpp"
25
26#include "LIEF/DEX/Type.hpp"
27
28namespace LIEF {
29namespace DEX {
30class Parser;
31class Class;
32
34class LIEF_API Field : public Object {
35 friend class Parser;
36 public:
37 using access_flags_list_t = std::vector<ACCESS_FLAGS>;
38
39 public:
40 Field();
41 Field(std::string name, Class* parent = nullptr);
42
43 Field(const Field&);
44 Field& operator=(const Field&);
45
47 const std::string& name() const;
48
51 bool has_class() const;
52
54 const Class* cls() const;
55 Class* cls();
56
58 size_t index() const;
59
61 bool is_static() const;
62
64 const Type* type() const;
65 Type* type();
66
67 void accept(Visitor& visitor) const override;
68
70 bool has(ACCESS_FLAGS f) const;
71
73 access_flags_list_t access_flags() const;
74
75
76 LIEF_API friend std::ostream& operator<<(std::ostream& os, const Field& mtd);
77
78 ~Field() override;
79
80 private:
81 void set_static(bool v);
82
83 private:
84 std::string name_;
85 Class* parent_ = nullptr;
86 Type* type_ = nullptr;
87 uint32_t access_flags_ = 0;
88 uint32_t original_index_ = UINT_MAX;
89 bool is_static_ = false;
90};
91
92} // Namespace DEX
93} // Namespace LIEF
94#endif
Class which represents a DEX Class (i.e. a Java/Kotlin class)
Definition DEX/Class.hpp:35
Class which represent a DEX Field.
Definition Field.hpp:34
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.
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.
const std::string & name() const
Name of the Field.
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 Type.hpp:33
Definition Object.hpp:25
Definition Visitor.hpp:219
LIEF namespace.
Definition Abstract/Binary.hpp:32