std::shared_ptr< const TypeMetainfo_I > TypeMetainfoCollection::getTypeMetainfo( std::string const& name ) const
		{
			auto type = mImpl->getTypeMetainfo( name );
			if ( type->isBasicType() )
			{
				auto basictype = std::static_pointer_cast< BasicTypeMetainfoImpl >( type );
				return std::shared_ptr< const TypeMetainfo_I >(  new TypeMetainfo( basictype ) );
			}
			else
			{
				auto customtype = std::static_pointer_cast< CustomTypeMetainfoImpl >( type );
				return std::shared_ptr< const TypeMetainfo_I >(  new CustomTypeMetainfo( customtype ) );
			}
		}
Пример #2
0
// Returns a pointer to one-past-end of this type if it's valid;
// returns NULL if it isn't valid.
static const char *validateSingleType(const char *signature)
{
    char c = *signature;
    if (c == DBUS_TYPE_INVALID)
        return 0;

    // is it one of the one-letter types?
    if (strchr(oneLetterTypes, c) != NULL)
        return signature + 1;

    // is it an array?
    if (c == DBUS_TYPE_ARRAY) {
        // then it's valid if the next type is valid
        // or if it's a dict-entry
        c = *++signature;
        if (c == DBUS_DICT_ENTRY_BEGIN_CHAR) {
            // beginning of a dictionary entry
            // a dictionary entry has a key which is of basic types
            // and a free value
            c = *++signature;
            if (!isBasicType(c))
                return 0;
            signature = validateSingleType(signature + 1);
            return signature && *signature == DBUS_DICT_ENTRY_END_CHAR ? signature + 1 : 0;
        }

        return validateSingleType(signature);
    }

    if (c == DBUS_STRUCT_BEGIN_CHAR) {
        // beginning of a struct
        ++signature;
        while (true) {
            signature = validateSingleType(signature);
            if (!signature)
                return 0;
            if (*signature == DBUS_STRUCT_END_CHAR)
                return signature + 1;
        }
    }

    // invalid/unknown type
    return 0;
}
Пример #3
0
 /*!
     \fn bool QDBusUtil::isValidBasicType(int type)
     Returns \c true if \a c is a valid, basic D-Bus type.
  */
 bool isValidBasicType(int c)
 {
     return isBasicType(c);
 }