コード例 #1
0
bool CJS_GlobalData::DeleteGlobalVariable(const CFX_ByteString& propname) {
  CFX_ByteString sPropName(propname);
  if (!TrimPropName(&sPropName))
    return false;

  auto iter = FindGlobalVariable(sPropName);
  if (iter == m_arrayGlobalData.end())
    return false;

  m_arrayGlobalData.erase(iter);
  return true;
}
コード例 #2
0
ファイル: JS_GlobalData.cpp プロジェクト: hfiguiere/pdfium
FX_BOOL CJS_GlobalData::DeleteGlobalVariable(const CFX_ByteString& propname) {
  CFX_ByteString sPropName(propname);
  if (!TrimPropName(&sPropName))
    return FALSE;

  auto iter = FindGlobalVariable(sPropName);
  if (iter == m_arrayGlobalData.end())
    return FALSE;

  m_arrayGlobalData.erase(iter);
  return TRUE;
}
コード例 #3
0
bool CJS_GlobalData::SetGlobalVariablePersistent(const CFX_ByteString& propname,
                                                 bool bPersistent) {
  CFX_ByteString sPropName(propname);
  if (!TrimPropName(&sPropName))
    return false;

  CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName);
  if (!pData)
    return false;

  pData->bPersistent = bPersistent;
  return true;
}
コード例 #4
0
void CJS_GlobalData::SetGlobalVariableNull(const CFX_ByteString& propname) {
  CFX_ByteString sPropName(propname);
  if (!TrimPropName(&sPropName))
    return;

  if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) {
    pData->data.nType = JS_GlobalDataType::NULLOBJ;
    return;
  }
  std::unique_ptr<CJS_GlobalData_Element> pNewData(new CJS_GlobalData_Element);
  pNewData->data.sKey = sPropName;
  pNewData->data.nType = JS_GlobalDataType::NULLOBJ;
  m_arrayGlobalData.push_back(std::move(pNewData));
}
コード例 #5
0
ファイル: JS_GlobalData.cpp プロジェクト: hfiguiere/pdfium
FX_BOOL CJS_GlobalData::SetGlobalVariablePersistent(
    const CFX_ByteString& propname,
    FX_BOOL bPersistent) {
  CFX_ByteString sPropName(propname);
  if (!TrimPropName(&sPropName))
    return FALSE;

  CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName);
  if (!pData)
    return FALSE;

  pData->bPersistent = bPersistent;
  return TRUE;
}
コード例 #6
0
void CJS_GlobalData::SetGlobalVariableObject(
    const CFX_ByteString& propname,
    const CJS_GlobalVariableArray& array) {
  CFX_ByteString sPropName(propname);
  if (!TrimPropName(&sPropName))
    return;

  if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) {
    pData->data.nType = JS_GlobalDataType::OBJECT;
    pData->data.objData.Copy(array);
    return;
  }
  std::unique_ptr<CJS_GlobalData_Element> pNewData(new CJS_GlobalData_Element);
  pNewData->data.sKey = sPropName;
  pNewData->data.nType = JS_GlobalDataType::OBJECT;
  pNewData->data.objData.Copy(array);
  m_arrayGlobalData.push_back(std::move(pNewData));
}
コード例 #7
0
ファイル: serializer.cpp プロジェクト: JGunning/OpenAOL-TV
void Serializer::SerializeObjectProperties( const QObject *pObject )
{
    if (pObject != NULL)
    {
        const QMetaObject *pMetaObject = pObject->metaObject();

        int nCount = pMetaObject->propertyCount();

        for (int nIdx=0; nIdx < nCount; ++nIdx ) 
        {
            QMetaProperty metaProperty = pMetaObject->property( nIdx );

            if (metaProperty.isDesignable( pObject ))
            {
                const char *pszPropName = metaProperty.name();
                QString     sPropName( pszPropName );

                if ( sPropName.compare( "objectName" ) == 0)
                    continue;
                
                bool bHash = false;

                if (ReadPropertyMetadata( pObject, 
                                          sPropName, 
                                          "transient").toLower() != "true" )
                {
                    bHash = true;
                    m_hash.addData( sPropName.toUtf8() );
                }

                QVariant value( pObject->property( pszPropName ) );

                if (bHash && !value.canConvert< QObject* >()) 
                {
                    m_hash.addData( value.toString().toUtf8() );
                }

                AddProperty( sPropName, value, pMetaObject, &metaProperty );
            }
        }
    }
}
コード例 #8
0
ファイル: xmlplistSerializer.cpp プロジェクト: Olti/mythtv
void XmlPListSerializer::SerializePListObjectProperties(const QString &sName,
                                                        const QObject *pObject,
                                                        bool          needKey )
{
    if (!pObject)
        return;

    if (needKey)
    {
        QString sItemName = GetItemName(sName);
        m_pXmlWriter->writeTextElement("key", sItemName);
    }
    m_pXmlWriter->writeStartElement("dict");

    const QMetaObject *pMetaObject = pObject->metaObject();

    int nCount = pMetaObject->propertyCount();

    for (int nIdx=0; nIdx < nCount; ++nIdx)
    {
        QMetaProperty metaProperty = pMetaObject->property(nIdx);

        if (metaProperty.isDesignable(pObject))
        {
            const char *pszPropName = metaProperty.name();
            QString     sPropName(pszPropName);

            if (sPropName.compare("objectName") == 0)
                continue;

            QVariant value(pObject->property(pszPropName));

            AddProperty(sPropName, value, pMetaObject, &metaProperty);
        }
    }

    m_pXmlWriter->writeEndElement();
}
コード例 #9
0
ファイル: xsd.cpp プロジェクト: dreamcat4/mythtv
bool Xsd::RenderXSD( HTTPRequest *pRequest, QObject *pClass )
{
    const QMetaObject *pMetaObject = pClass->metaObject();

    QString     sClassName = ConvertTypeToXSD( pMetaObject->className(), true);
    QDomElement oRoot      = CreateSchemaRoot();

    QMap<QString, TypeInfo> typesToInclude;

    // ------------------------------------------------------------------
    // Create xs:complexType structure
    // ------------------------------------------------------------------
    
    QDomElement oTypeNode = createElement( "xs:complexType" );
    QDomElement oSeqNode  = createElement( "xs:sequence"    );

    oTypeNode.setAttribute( "name", sClassName );

    oTypeNode.appendChild( oSeqNode  );
    
    // -=>TODO: Add an xs:annotation node with class descriptions

    // ------------------------------------------------------------------
    // Add all properties for this type
    //
    //  <xs:element minOccurs="0" name="<propName>" type="<propType>"/>
    //    <xs:element minOccurs="0" name="<childName>" nillable="true" 
    //              type="tns:<ChildType>"/>
    // ------------------------------------------------------------------
    
    int nCount = pMetaObject->propertyCount();

    for (int nIdx=0; nIdx < nCount; ++nIdx ) 
    {
        QMetaProperty metaProperty = pMetaObject->property( nIdx );

        if (metaProperty.isDesignable( pClass ))
        {
            const char *pszPropName = metaProperty.name();
            QString     sPropName( pszPropName );

            if ( sPropName.compare( "objectName" ) == 0)
                continue;

            // ----------------------------------------------------------
            // Create xs:element for this property
            // ----------------------------------------------------------

            QDomElement oNode        = createElement( "xs:element" );
            QString     sType        = metaProperty.typeName();
            bool        bCustomType  = false;
            QString        sCustomAttr  = "type";
            QString     sContentName = QString();
            QString     sContentType = QString();

            // if this is a child object, sType will be QObject*
            // which we can't use, so we need to read the
            // properties value, and read it's metaObject data

            if (sType == "QObject*")
            {
                QVariant val = metaProperty.read( pClass );
                const QObject *pObject = val.value< QObject* >(); 

                sType = pObject->metaObject()->className();
                bCustomType = true;
            }
            else if ((sType == "QVariantList" ) || (sType == "QVariantMap"))
            {
                sContentType = ReadPropertyMetadata( pClass, 
                                                     sPropName, 
                                                     "type" );

                if (sContentType.at(0) == 'Q')
                    sContentType = sContentType.mid( 1 );

                sContentType.remove( "DTC::"    );
                sContentType.remove( QChar('*') );

                if (sType == "QVariantMap")
                {
                    sContentName = ReadPropertyMetadata( pClass, 
                                                         sPropName, 
                                                         "name" );

                    if (sContentName.isEmpty())
                        sContentName = sContentType;

                    sType = "MapOfString" + sContentName;
                }
                else
                    sType = "ArrayOf" + sContentType;

                bCustomType = true;

            }
            else if (sType == "QStringList") 
            { 
                sType = "ArrayOfString"; 
                bCustomType = true;
            }
            else if (metaProperty.isEnumType() || metaProperty.isFlagType() )
            {
                sCustomAttr = "enum";
                sType       = sClassName + "." + sType;
                bCustomType = true;
            }

            QString sNewPropName( metaProperty.name() );

            if (IsNillable( sType ))
                oNode.setAttribute( "nillable" , true );   

            if (bCustomType)
            {
                TypeInfo info = { sCustomAttr, sContentType };
                typesToInclude.insert( sType, info );
            }
    
            oNode.setAttribute( "type"     , (bCustomType ? "tns:" : "xs:") +
                                       ConvertTypeToXSD( sType, bCustomType ));

            oNode.setAttribute( "name"     , sNewPropName );
            oNode.setAttribute( "minOccurs", 0            );

            oSeqNode.appendChild( oNode );
        }
    }

    // ------------------------------------------------------------------
    // Create element for class
    //
    //       <xs:element name="<className>" nillable="true" type="tns:<className>"/>
    // ------------------------------------------------------------------

    QDomElement oElementNode = createElement( "xs:element" );

    oElementNode.setAttribute( "type"    , "tns:" + sClassName );
    oElementNode.setAttribute( "nillable", "true" );
    oElementNode.setAttribute( "name"    , sClassName );

    // ----------------------------------------------------------------------
    // Build xml tree...
    // ----------------------------------------------------------------------

    appendChild( oRoot );

    if (typesToInclude.count() > 0)
    {
        // ------------------------------------------------------------------
        // Create all needed includes
        //
        //    <xs:include schemaLocation="<path to dependant schema"/>
        // ------------------------------------------------------------------

        QString sBaseUri = "http://" + pRequest->m_mapHeaders[ "host" ] + 
                                       pRequest->m_sResourceUrl;

        QMap<QString, TypeInfo >::const_iterator it = typesToInclude.constBegin();
        while( it != typesToInclude.constEnd())
        {
            QDomElement oIncNode = createElement( "xs:include" );
            QString     sType    = it.key();

            sType.remove( "DTC::" );

            TypeInfo info = it.value();

            QString sValue = QString( "%1?%2=%3" ).arg( sBaseUri       )
                                                  .arg( info.sAttrName )
                                                  .arg( sType          );

            if (!info.sContentType.isEmpty())
                sValue += "&name=" + info.sContentType;

            oIncNode.setAttribute( "schemaLocation", sValue );

            oRoot.appendChild( oIncNode );
            ++it;
        }
    }

    oRoot.appendChild( oTypeNode    );
    oRoot.appendChild( oElementNode );

    // ----------------------------------------------------------------------
    // Return xsd doc to caller
    // ----------------------------------------------------------------------

    QTextStream os( &(pRequest->m_response) );

    pRequest->m_eResponseType   = ResponseTypeXML;

    save( os, 0 );

    return true;
}
コード例 #10
0
ファイル: wsdl.cpp プロジェクト: Openivo/mythtv
bool Wsdl::CreateType( QObject *pParent, QString &sTypeName )
{
    if ( m_typesCreated.contains( sTypeName ))
        return true;

//    sTypeName.remove( "DTC::" );
    sTypeName.remove( QChar('*') );

    int id = QMetaType::type( sTypeName.toUtf8() );

    switch( id )
    {
        case QMetaType::QStringList:
            return CreateArrayType( pParent, sTypeName, "Value",  "string", true );

        case QMetaType::QVariantMap:
            return CreateMapType( pParent, sTypeName, "Settings", "string", true );

        default:
            // for not, treat QFileInfo as a string.  Need to turn into MTOM later.
            if (id == QMetaType::type( "QFileInfo" ))
            {
                sTypeName = "QString";
                return false;
            }
            break;
    }

    if ((id == -1) || (id < QMetaType::User)) 
        return false;

    // ------------------------------------------------------------------
    // Need to create an instance of the class to access it's metadata.
    // ------------------------------------------------------------------

    QObject *pClass = (QObject *)QMetaType::construct( id );

    if (pClass != NULL)
    {
        const QMetaObject *pMetaObject = pClass->metaObject();

        // ------------------------------------------------------------------
        // Create xsd element structure
        // ------------------------------------------------------------------
    
        QDomElement oTypeNode = createElement( "xs:complexType" );
        QDomElement oSeqNode  = createElement( "xs:sequence"    );

        oTypeNode.setAttribute( "name", ConvertTypeToXSD( sTypeName, true));

//        oElementNode.appendChild( oTypeNode );
        oTypeNode   .appendChild( oSeqNode  );
    
        // ------------------------------------------------------------------
        // Add all properties for this type
        // ------------------------------------------------------------------
    
		int nCount = pMetaObject->propertyCount();

		for (int nIdx=0; nIdx < nCount; ++nIdx ) 
		{
			QMetaProperty metaProperty = pMetaObject->property( nIdx );

            if (metaProperty.isDesignable( pClass ))
            {
                const char *pszPropName = metaProperty.name();
                QString     sPropName( pszPropName );

                if ( sPropName.compare( "objectName" ) == 0)
                    continue;

                QDomElement oNode = createElement( "xs:element" );

                QString sType = metaProperty.typeName();

                // if this is a child object, sType will be QObject*
                // which we can't use, so we need to read the
                // properties value, and read it's metaObject data

                if (sType == "QObject*")
                {
                    QVariant val = metaProperty.read( pClass );
                    const QObject *pObject = val.value< QObject* >(); 

                    sType = pObject->metaObject()->className();

//                    sType.remove( "DTC::" );
                }

                oNode.setAttribute( "minOccurs", 0       );
                oNode.setAttribute( "name"     , metaProperty.name() );
                oNode.setAttribute( "nillable" , true    );   //-=>TODO: This may need to be determined by sParamType
    
                bool bCustomType = CreateType( pClass, sType );

                oNode.setAttribute( "type"     , ((bCustomType) ? "tns:" : "") + ConvertTypeToXSD( sType, bCustomType ));

                oSeqNode.appendChild( oNode );
            }
		}

        QDomElement oElementNode = createElement( "xs:element" );

        oElementNode.setAttribute( "name"    , ConvertTypeToXSD( sTypeName, true));
        oElementNode.setAttribute( "nillable", "true" );
        oElementNode.setAttribute( "type"    , "tns:" + ConvertTypeToXSD( sTypeName, true));

        m_oTypes.appendChild( oTypeNode    );
        m_oTypes.appendChild( oElementNode );

        QMetaType::destroy( id, pClass );
     }

    m_typesCreated.insert( sTypeName, true );

    return true;
}