Exemplo n.º 1
0
void CTFXConfigParser::OnStartElementL(const RTagInfo& aElement, const RAttributeArray& aAttributes, TInt aErrorCode)
    {
    if (iFileType == EConfigFileManifest)
        {
        OnMfStartElementL(aElement, aAttributes, aErrorCode);
        return;
        }
    else if (iFileType == EConfigFileSel)
        {
        OnSelStartElementL(aElement, aAttributes, aErrorCode);
        return;
        }


    if (!aElement.LocalName().DesC().CompareF(KManifestTag))
        {
        iFileType = EConfigFileManifest;
        return;
        }
    else if (!aElement.LocalName().DesC().CompareF(KSelTag))
        {
        iFileType = EConfigFileSel;

        // find if there's baseskin attribute
        // if baseskin is found then parsing is stopped and
        // baseskin is parsed and registered first
        TInt attrCount( aAttributes.Count() );
        for( TInt i( 0 ); i < attrCount; i++ )
            {
            RAttribute attribute = aAttributes[i];
            RTagInfo tag = attribute.Attribute();
            if (!tag.LocalName().DesC().CompareF(KBaseSkinTag))
                {
                // base skin can be found once per parser
                if( iBaseSkinSelFile.Length() == 0 )
                    {
                    iBaseSkinSelFile.Copy( attribute.Value().DesC() );
                    User::Leave( KBaseSkinParserLeave );
                    }
                }
            }
        return;
        }
    }
Exemplo n.º 2
0
QString
AMetaObject::attrName( int idx ) const
{
    if ( idx < 0 || idx >= attrCount() ) return QString::null;
    return v_attr.keys().at( idx );
}
Exemplo n.º 3
0
Arquivo: tag.cpp Projeto: KDE/quanta
void Tag::parse(const QString &p_tagStr, Document *p_write)
{
 attrs.clear();
 m_tagStr = p_tagStr;
 uint strLength = m_tagStr.length();
 cleanStr = m_tagStr;
 m_write = p_write;
 if (!m_tagStr.startsWith("<"))
 {
   type = Text;
   return;
 }
 m_nameLine = m_area.bLine;
 m_nameCol = m_area.bCol + 1;
 uint pos = 1;
 while (pos < strLength &&
        !m_tagStr[pos].isSpace() && m_tagStr[pos] != '>' && m_tagStr[pos] != '\n')
 {
   pos++;
 }
 name = m_tagStr.mid(1, pos - 1);
 int nameSpacePos = name.find(':');
 if (nameSpacePos != -1)
 {
   nameSpace = name.left(nameSpacePos);
   name = name.mid(++nameSpacePos);
   m_nameCol += nameSpacePos;
 }
 QString attrStr;
 TagAttr attr;
 attr.special = false; //by default non of the attributes are special
 while (pos < strLength && m_tagStr[pos].isSpace())
        pos++;
 int sPos = pos;
 int valueStartPos = 0;
 while (pos < strLength)
 {
    //find the attribute name
    while (pos < strLength &&
           !m_tagStr[pos].isSpace() && m_tagStr[pos] != '=')
    {
      pos++;
    }
    attr.name = m_tagStr.mid(sPos, pos - sPos);
    if (attr.name.endsWith(">") && pos == strLength)
    {
      attr.name = attr.name.left(attr.name.length() - 1).lower();
      if (!attr.name.stripWhiteSpace().isEmpty())
      {
        attr.nameLine = m_tagStr.left(sPos).contains('\n') + m_area.bLine;
        if (attr.nameLine == m_area.bLine)
            attr.nameCol = sPos + m_area.bCol;
        else
            attr.nameCol = m_tagStr.left(sPos).section('\n',-1).length();
        attr.value = (dtd != 0) ? dtd->booleanTrue : QString("checked");
        attr.valueCol = attr.nameCol;
        attr.valueLine = attr.nameLine;
        attr.quoted = false;
        attrs.append(attr);
      }
      break;
    }
    if (dtd && !dtd->caseSensitive)
        attr.name = attr.name.lower();
    attr.nameLine = m_tagStr.left(sPos).contains('\n') + m_area.bLine;
    if (attr.nameLine == m_area.bLine)
        attr.nameCol = sPos + m_area.bCol;
    else
        attr.nameCol = m_tagStr.left(sPos).section('\n',-1).length();

    while (pos < m_tagStr.length() && m_tagStr[pos].isSpace())
            pos++;
    //if the attribute is just listed and there is no value specified,
    //treate it as a "true" boolean
    if (m_tagStr[pos] != '=' || pos == strLength)
    {
      attr.value = (dtd != 0) ? dtd->booleanTrue : QString("checked");
      attr.valueCol = attr.nameCol;
      attr.valueLine = attr.nameLine;
      attr.quoted = false;
      pos--;
    } else
    {
      pos++;
      while (pos < strLength && m_tagStr[pos].isSpace())
            pos++;
      if (m_tagStr[pos] == '\'' || m_tagStr[pos] == '"')
      {
        attr.quoted = true;
        valueStartPos = pos + 1;
        QChar quotation = m_tagStr[pos];
        pos += 1;
        while (pos < strLength &&
               (m_tagStr[pos] != quotation ||
               (m_tagStr[pos] == quotation && m_tagStr[pos-1] == '\\')))
        {
          pos++;
        }
        attr.value = m_tagStr.mid(valueStartPos, pos - valueStartPos);
      } else
      {
        attr.quoted = false;
        valueStartPos = pos;
        while (pos < strLength && !m_tagStr[pos].isSpace())
          pos++;
        if (pos == strLength)
          pos--;
        attr.value = m_tagStr.mid(valueStartPos, pos - valueStartPos);
      }
      attr.valueLine = m_tagStr.left(valueStartPos).contains('\n') + m_area.bLine;
      if (attr.valueLine == m_area.bLine)
          attr.valueCol = valueStartPos + m_area.bCol;
      else
          attr.valueCol = m_tagStr.left(valueStartPos).section('\n',-1).length();
    }

    attrs.append(attr);
    //go to the first non-space char. This is where the next attribute name starts
    pos++;
    while (pos < strLength && m_tagStr[pos].isSpace())
          pos++;
    sPos = pos++;
 }
 
 //add the tag to the document usertag list if it's not present in the dtd
  if (m_tagStr.startsWith("<") && m_tagStr.endsWith(">") && dtd)
  {
    //QString tagName = (m_parsingDTD->caseSensitive) ? name : name.upper();
    QString tagName = name.lower();
    //add the new xml tags to the userTagList
    if ( !QuantaCommon::isKnownTag(dtd->name, tagName) &&
          name[0] != '/' )
    {
      QTag *newTag = m_write->userTagList.find(tagName);
      bool insertNew = !newTag;
      if (insertNew)
      {
        newTag = new QTag();
        newTag->setName(name);
        newTag->parentDTD = dtd;
      }
      for (int i = 0; i >attrCount(); i++)
      {
        Attribute *attr = new Attribute;
        attr->name = attribute(i);
        attr->values.append(attributeValue(i));
        newTag->addAttribute(attr);
        delete attr;
      }
      if (insertNew)
      {
        m_write->userTagList.insert(tagName, newTag);
      }
    }
  }
}