本文整理汇总了C++中QDBusArgument::endMap方法的典型用法代码示例。如果您正苦于以下问题:C++ QDBusArgument::endMap方法的具体用法?C++ QDBusArgument::endMap怎么用?C++ QDBusArgument::endMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDBusArgument
的用法示例。
在下文中一共展示了QDBusArgument::endMap方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: extractMapData
//
// Function to extract the data from a QDBusArgument that contains a map.
// Some of the arrayElements can contain a QDBusArgument as the object
// instead of a primitive (string, bool, int, etc.). This function
// will extract the data from the QDBusArgument and write it into a map.
//
// Return value a bool, true on success, false otherwise.
// The map is sent by reference (called r_map here) and is modified by this function.
// r_var is a constant reference to the QDBusArgument.
//
bool shared::extractMapData(QMap<QString,QVariant>& r_map, const QVariant& r_var)
{
// make sure we can convert the QVariant into a QDBusArgument
if (! r_var.canConvert<QDBusArgument>() ) return false;
const QDBusArgument qdba = r_var.value<QDBusArgument>();
// make sure the QDBusArgument holds a map
if (qdba.currentType() != QDBusArgument::MapType ) return false;
// iterate over the QDBusArgument pulling map keys and values out
r_map.clear();
qdba.beginMap();
while ( ! qdba.atEnd() ) {
QString key;
QVariant value;
qdba.beginMapEntry();
qdba >> key >> value;
qdba.endMapEntry();
r_map.insert(key, value);
} // while
qdba.endMap();
return true;
}
示例2:
bool
Serializable::serialize (QDBusArgument &argument)
{
QMap<QString, SerializablePointer>::const_iterator i;
argument.beginMap (QVariant::String, qMetaTypeId<QDBusVariant>());
for (i = m_attachments.begin (); i != m_attachments.end (); i++) {
argument.beginMapEntry ();
argument << i.key ();
argument << i.value ();
argument.endMapEntry ();
}
argument.endMap ();
return true;
}
示例3: while
bool
Serializable::deserialize (const QDBusArgument &argument)
{
argument.beginMap ();
while (!argument.atEnd()) {
QString key;
SerializablePointer p;
argument.beginMapEntry ();
argument >> key;
argument >> p;
argument.endMapEntry ();
m_attachments[key] = p;
}
argument.endMap ();
return true;
}
示例4: while
QMap<QString, QString> DbusAdapter::unpackMessage(const QDBusArgument &arg) {
QMap<QString, QString> argMap;
arg.beginMap();
while (! arg.atEnd()) {
QString key;
QVariant value;
arg.beginMapEntry();
arg >> key >> value;
if (value.canConvert(QVariant::String)) {
argMap.insert(key, value.toString());
}
arg.endMapEntry();
}
arg.endMap();
return argMap;
}
示例5: sipNoMethod
static PyObject *meth_QDBusArgument_endMap(PyObject *sipSelf, PyObject *sipArgs)
{
PyObject *sipParseErr = NULL;
{
QDBusArgument *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QDBusArgument, &sipCpp))
{
Py_BEGIN_ALLOW_THREADS
sipCpp->endMap();
Py_END_ALLOW_THREADS
Py_INCREF(Py_None);
return Py_None;
}
}
/* Raise an exception if the arguments couldn't be parsed. */
sipNoMethod(sipParseErr, sipName_QDBusArgument, sipName_endMap, doc_QDBusArgument_endMap);
return NULL;
}
示例6: createInputMap
/////////////////////////////////////// PUBLIC FUNCTIONS ////////////////////////////////
//
// Function to put all of input fields received via DBus:RequestInput into a
// QMap<QString,QString> where key is the input field received and value is
// generally blank but can be used for informational text.
//
// If we asked to log the input request create the log file in /tmp/cmst/input_request.log
void ConnmanAgent::createInputMap(const QMap<QString,QVariant>& r_map)
{
// Initialize our data map
input_map.clear();
// QFile object for logging
QTextStream log;
QFile logfile("/tmp/cmst/input_request.log");
if (b_loginputrequest) {
QDir d;
d.mkpath("/tmp/cmst");
if (logfile.exists()) logfile.remove();
if (!logfile.open(QIODevice::WriteOnly | QIODevice::Text)) b_loginputrequest = false;
else log.setDevice(&logfile);
}
// Run through the r_map getting the keys and the few values we are interested in.
QMap<QString, QVariant>::const_iterator i = r_map.constBegin();
while (i != r_map.constEnd()) {
// Lets see what the values contain, but first make sure we can get to them.
if (b_loginputrequest) log << "\nMap Key: " << i.key() << "\n";
if (! i.value().canConvert<QDBusArgument>() ) return;
const QDBusArgument qdba = i.value().value<QDBusArgument>();
if (qdba.currentType() != QDBusArgument::MapType ) {
if (b_loginputrequest) log << "Error - QDBusArgument as the value is not a MapType\n";
return;
}
// The r_map.value() is a QDBusArgument::MapType so extract this map into a new QMap called m.
qdba.beginMap();
QMap<QString,QString> m;
m.clear();
if (b_loginputrequest) log << "Extracting the DBusArgument Map...\n";
while ( ! qdba.atEnd() ) {
QString k;
QVariant v;
qdba.beginMapEntry();
qdba >> k >> v;
qdba.endMapEntry();
m.insert(k, v.toString());
if (b_loginputrequest) log << "{ " << k << " , " << v.toString() << "}\n";
} // while
qdba.endMap();
// Browse through QMap m and get things we need to look at
// Types we don' really care about. We ignore "optional" and "alternate" requirements
// and only extract the "mandatory" and "informational" requirements with values
if (m.contains("Requirement") ) {
QString val = QString();
if ( m.value("Requirement").contains("mandatory", Qt::CaseInsensitive) || m.value("Requirement").contains("informational", Qt::CaseInsensitive) ) {
if (m.contains("Value") ) val = m.value("Value");
} // if mandatory or informational
// create our input_map entry
input_map[i.key()] = val;
} // if requirement
++i;
} // while
logfile.close();
return;
}
示例7: if
static QVariantList
qml_from_dbus(QVariant v)
{
QVariantList r;
const char *type=v.typeName();
switch (v.type()) {
case QVariant::ULongLong:
r.append("uint64");
r.append(v.toULongLong());
break;
case QVariant::UInt:
r.append("uint32");
r.append(v.toUInt());
break;
case QVariant::Int:
r.append("int32");
r.append(v.toInt());
break;
case QMetaType::UShort:
r.append("uint16");
r.append(v.toUInt());
break;
case QMetaType::UChar:
r.append("uint8");
r.append(v.toUInt());
break;
case QVariant::String:
r.append("string");
r.append(v.toString());
break;
case QVariant::Bool:
r.append("bool");
r.append(v.toBool());
break;
case QVariant::Double:
r.append("double");
r.append(v.toDouble());
break;
case QVariant::UserType:
if (!strcmp(type,"QDBusArgument")) {
const QDBusArgument arg=v.value < QDBusArgument>();
QVariantList rl;
switch(arg.currentType()) {
case QDBusArgument::ArrayType:
r.append("array");
arg.beginArray();
while (!arg.atEnd()) {
rl.append(qml_from_dbus(arg.asVariant()));
}
r.append(QVariant(rl));
break;
case QDBusArgument::StructureType:
r.append("structure");
arg.beginStructure();
while (!arg.atEnd()) {
rl.append(qml_from_dbus(arg.asVariant()));
}
arg.endStructure();
r.append(QVariant(rl));
break;
case QDBusArgument::MapType:
r.append("map");
arg.beginMap();
while (!arg.atEnd()) {
arg.beginMapEntry();
rl.append(qml_from_dbus(arg.asVariant()));
rl.append(qml_from_dbus(arg.asVariant()));
arg.endMapEntry();
}
arg.endMap();
r.append(QVariant(rl));
break;
case QDBusArgument::UnknownType:
break;
default:
printf("Unknown type %d\n",arg.currentType());
break;
}
} else if (!strcmp(type,"QDBusVariant")) {
const QDBusVariant arg=v.value < QDBusVariant>();
QVariantList rl;
r.append("variant");
rl.append(qml_from_dbus(arg.variant()));
r.append(QVariant(rl));
} else {
printf("User type %s\n",v.typeName());
}
break;
default:
fprintf(stderr,"Unsupported Arg %s(%d)\n",type,v.type());
}
return r;
}