LIEF: Library to Instrument Executable Formats Version 2.0.0
Loading...
Searching...
No Matches
runtime/android/Property.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 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_RUNTIME_ANDROID_PROPERTY_H
16#define LIEF_RUNTIME_ANDROID_PROPERTY_H
17#include <string_view>
18#include <cstdint>
19#include <ostream>
20#include <string>
21
23#include "LIEF/visibility.h"
24
25// Forward definition from include/sys/system_properties.h
26typedef struct prop_info prop_info; // NOLINT
27
28
29namespace LIEF::runtime::android {
30
33 public:
34 Property() = default;
35 Property(std::string name, std::string value, uint32_t serial) :
36 name_(std::move(name)),
37 value_(std::move(value)),
38 serial_(serial) {}
39
40 static Property create_from(const prop_info& pi);
41
42 Property(const Property&) = default;
43 Property& operator=(const Property&) = default;
44
45 Property(Property&&) noexcept = default;
46 Property& operator=(Property&&) noexcept = default;
47
48 ~Property() = default;
49
51 std::string_view name() const LIEF_LIFETIMEBOUND {
52 return name_;
53 }
54
56 std::string_view value() const LIEF_LIFETIMEBOUND {
57 return value_;
58 }
59
64 uint32_t serial() const {
65 return serial_;
66 }
67
69 std::string to_string() const;
70
71 LIEF_API friend std::ostream& operator<<(std::ostream& os,
72 const Property& prop) {
73 os << prop.to_string();
74 return os;
75 }
76
77 private:
78 std::string name_;
79 std::string value_;
80 uint32_t serial_ = 0;
81};
82}
83
84
85#endif
std::string_view value() const
Value associated with the property.
Definition runtime/android/Property.hpp:56
friend std::ostream & operator<<(std::ostream &os, const Property &prop)
Definition runtime/android/Property.hpp:71
static Property create_from(const prop_info &pi)
Property(const Property &)=default
Property(std::string name, std::string value, uint32_t serial)
Definition runtime/android/Property.hpp:35
std::string to_string() const
Pretty representation of the property.
Property(Property &&) noexcept=default
std::string_view name() const
Name of the property (e.g. ro.boot.hardware).
Definition runtime/android/Property.hpp:51
Property & operator=(const Property &)=default
uint32_t serial() const
Serial number of the property.
Definition runtime/android/Property.hpp:64
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
Definition android/Host.hpp:23
struct prop_info prop_info
Definition runtime/android/Property.hpp:26
#define LIEF_API
Definition visibility.h:44