mirror of
https://github.com/kvorschk/Magisk.git
synced 2026-12-06 15:30:46 -05:00
Make Utf8CStr a first class citizen in C++ codebase
Utf8CStr is in many cases a better string view class than std::string_view, because it provides "view" access to a string buffer that is guaranteed to be null terminated. It also has the additional benefit of being UTF-8 verified and can seemlessly cross FFI boundaries. We would want to start use more Utf8CStr in our existing C++ codebase.
This commit is contained in:
@@ -143,6 +143,10 @@ template<> void prop_to_string<rust::String>::exec(const char *, const char *val
|
||||
serial = s;
|
||||
}
|
||||
|
||||
static bool str_starts(std::string_view s, std::string_view ss) {
|
||||
return s.starts_with(ss);
|
||||
}
|
||||
|
||||
static int set_prop(const char *name, const char *value, PropFlags flags) {
|
||||
if (!check_legal_property_name(name))
|
||||
return 1;
|
||||
@@ -429,7 +433,7 @@ static StringType get_prop_impl(const char *name, bool persist) {
|
||||
return get_prop<StringType>(name, flags);
|
||||
}
|
||||
|
||||
rust::String get_prop_rs(rust::Utf8CStr name, bool persist) {
|
||||
rust::String get_prop_rs(Utf8CStr name, bool persist) {
|
||||
return get_prop_impl<rust::String>(name.data(), persist);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user