gpt4 book ai didi

c++ - 如何从ofono获得属性(property)

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:28:59 30 4
gpt4 key购买 nike

我用 C++ 编写了一个程序来获取 ofono API 的属性:

string Protocol [readwrite]

Holds the protocol for this context. Valid values
are: "ip", "ipv6" and "dual".

string Name [readwrite]

The name is a free form string that describes this
context. The name should not be empty and limited
to a short string for display purposes.

dict Settings [readonly, optional]

Holds all the IP network settings

string Interface [readonly, optional]

Holds the interface of the network interface
used by this context (e.g. "ppp0" "usb0")

string Method [readonly, optional]

Holds the IP network config method
"static"- Set IP network statically
"dhcp" - Set IP network through DHCP

string Address [readonly, optional]

当我解析我使用的属性时

...
for (auto p:prop){
p.first //to get name of property
p.second.reader().get_string() //to get string value of property
p.second.reader().get_bool() //to get boolean value of property
...
}

我的问题是如何获取 dict 类型的名称和值?例如对于 dict Settings [readonly, optional] 如何获取 string Interface [readonly, optional]string Method [readonly, optional]

最佳答案

我找到了解决方案,只是我做了这个:

p 是我问题中定义的 prop 元素

...
DBus::MessageIter iterator = p.second.reader();
std::map< std::string, ::DBus::Variant > mapping;
iterator >> mapping;
for (auto map:mapping) {
map.first// contain the name
map.second.reader().get_string() // contain the string value
}
...

关于c++ - 如何从ofono获得属性(property),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30303162/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com