LIEF: Library to Instrument Executable Formats Version 1.0.0
Loading...
Searching...
No Matches
runtime/android/Property.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2026 R. Thomas
2 * Copyright 2017 - 2026 Quarkslab
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#ifndef LIEF_RUNTIME_ANDROID_PROPERTY_H
17#define LIEF_RUNTIME_ANDROID_PROPERTY_H
18#include <ostream>
19#include <cstdint>
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
28namespace LIEF {
29namespace runtime {
30namespace android {
31
34 public:
35 Property() = default;
36 Property(std::string name, std::string value, uint32_t serial) :
37 name_(std::move(name)),
38 value_(std::move(value)),
39 serial_(serial) {}
40
41 static Property create_from(const prop_info& pi);
42
43 Property(const Property&) = default;
44 Property& operator=(const Property&) = default;
45
46 Property(Property&&) noexcept = default;
47 Property& operator=(Property&&) noexcept = default;
48
49 ~Property() = default;
50
52 const std::string& name() const LIEF_LIFETIMEBOUND {
53 return name_;
54 }
55
57 const std::string& value() const LIEF_LIFETIMEBOUND {
58 return value_;
59 }
60
65 uint32_t serial() const {
66 return serial_;
67 }
68
70 std::string to_string() const;
71
72 LIEF_API friend std::ostream& operator<<(std::ostream& os,
73 const Property& prop) {
74 os << prop.to_string();
75 return os;
76 }
77
78 private:
79 std::string name_;
80 std::string value_;
81 uint32_t serial_ = 0;
82};
83}
84}
85}
86#endif
friend std::ostream & operator<<(std::ostream &os, const Property &prop)
Definition runtime/android/Property.hpp:72
static Property create_from(const prop_info &pi)
const std::string & value() const
Value associated with the property.
Definition runtime/android/Property.hpp:57
Property(const Property &)=default
const std::string & name() const
Name of the property (e.g. ro.boot.hardware).
Definition runtime/android/Property.hpp:52
Property(std::string name, std::string value, uint32_t serial)
Definition runtime/android/Property.hpp:36
std::string to_string() const
Pretty representation of the property.
Property(Property &&) noexcept=default
Property & operator=(const Property &)=default
uint32_t serial() const
Serial number of the property.
Definition runtime/android/Property.hpp:65
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
LIEF namespace.
Definition Abstract/Binary.hpp:41
struct prop_info prop_info
Definition runtime/android/Property.hpp:26
#define LIEF_API
Definition visibility.h:45