Esempio n. 1
0
void wxSimpleHtmlTag::Write(wxOutputStream& stream)
{
    switch (GetType())
    {
    case wxSimpleHtmlTag_Text:
        {
            stream << m_text;
            break;
        }
    case wxSimpleHtmlTag_Open:
        {
            stream << "<" << m_name;
            if (GetAttributeCount() > 0)
                stream << " ";
            int i;
            for (i = 0; i < GetAttributeCount(); i++)
            {
                wxSimpleHtmlAttribute* attr = GetAttribute(i);
                attr->Write(stream);
                if (i < GetAttributeCount() - 1)
                    stream << " ";
            }
            stream << ">\n";
            break;
        }
    case wxSimpleHtmlTag_Directive:
        {
            stream << "<!" << m_name << " ";
            int i;
            for (i = 0; i < GetAttributeCount(); i++)
            {
                wxSimpleHtmlAttribute* attr = GetAttribute(i);
                attr->Write(stream);
                if (i < GetAttributeCount() - 1)
                    stream << " ";
            }
            stream << ">\n";
            break;
        }
    case wxSimpleHtmlTag_Close:
        {
            stream << "</" << m_name << ">\n";
            break;
        }
    default:
        {
            break;
        }
    }
    wxSimpleHtmlTag* tag = m_children;
    while (tag)
    {
        tag->Write(stream);
        tag = tag->m_next;
    }

}
Esempio n. 2
0
BOOL CXMLElement::Equals(CXMLElement* pXML) const
{
	if ( this == NULL || pXML == NULL ) return FALSE;
	if ( pXML == this ) return TRUE;

	if ( m_sName != pXML->m_sName ) return FALSE;
	if ( m_sValue != pXML->m_sValue ) return FALSE;

	if ( GetAttributeCount() != pXML->GetAttributeCount() ) return FALSE;
	if ( GetElementCount() != pXML->GetElementCount() ) return FALSE;

	for ( POSITION pos = GetAttributeIterator() ; pos ; )
	{
		CXMLAttribute* pAttribute1 = GetNextAttribute( pos );
		CXMLAttribute* pAttribute2 = pXML->GetAttribute( pAttribute1->m_sName );
		if ( pAttribute2 == NULL ) return FALSE;
		if ( ! pAttribute1->Equals( pAttribute2 ) ) return FALSE;
	}

	POSITION pos1 = GetElementIterator();
	POSITION pos2 = pXML->GetElementIterator();

	for ( ; pos1 && pos2 ; )
	{
		CXMLElement* pElement1 = GetNextElement( pos1 );
		CXMLElement* pElement2 = pXML->GetNextElement( pos2 );
		if ( pElement1 == NULL || pElement2 == NULL ) return FALSE;
		if ( ! pElement1->Equals( pElement2 ) ) return FALSE;
	}

	if ( pos1 != NULL || pos2 != NULL ) return FALSE;

	return TRUE;
}
Esempio n. 3
0
void CXMLElement::Serialize(CArchive& ar)
{
	CXMLNode::Serialize( ar );

	if ( ar.IsStoring() )
	{
		ar.WriteCount( GetAttributeCount() );

		for ( POSITION pos = GetAttributeIterator() ; pos ; )
		{
			GetNextAttribute( pos )->Serialize( ar );
		}

		ar.WriteCount( GetElementCount() );

		for ( POSITION pos = GetElementIterator() ; pos ; )
		{
			GetNextElement( pos )->Serialize( ar );
		}
	}
	else // Loading
	{
		for ( int nCount = (int)ar.ReadCount() ; nCount > 0 ; nCount-- )
		{
			CXMLAttribute* pAttribute = new CXMLAttribute( this );
			pAttribute->Serialize( ar );

			// Skip attribute if name is missing
			if ( pAttribute->m_sName.IsEmpty() )
			{
				delete pAttribute;
				continue;
			}

			CString strNameLower( pAttribute->m_sName );
			strNameLower.MakeLower();

			// Delete the old attribute if one exists
			CXMLAttribute* pExisting;
			if ( m_pAttributes.Lookup( strNameLower, pExisting ) )
				delete pExisting;

			m_pAttributes.SetAt( strNameLower, pAttribute );

			if ( ! m_pAttributesInsertion.Find( strNameLower ) )
				m_pAttributesInsertion.AddTail( strNameLower );		// Track output order workaround
		}

		for ( int nCount = (int)ar.ReadCount() ; nCount > 0 ; nCount-- )
		{
			CXMLElement* pElement = new CXMLElement( this );
			pElement->Serialize( ar );
			m_pElements.AddTail( pElement );
		}
	}
}
Esempio n. 4
0
CString&
ZXmlParser::GetAttributeValue( int index )
{
   m_LastError = "ZXmlParser::GetAttributeValue( int ) failed";
   if ( index < 0 || index > GetAttributeCount( ) )
   {
      m_tmp.Empty( );
      return( m_tmp );
   }

   m_LastError = m_ok;
   return( m_AttribValues[ m_attrib_index ] );
}
Esempio n. 5
0
bool
ZXmlParser::IsValidAttribute( LPCTSTR Name )
{
   // Create the CString Name Object
   CString sName = Name;

   // Clear attribute index
   m_attrib_index = -1;

   int bcl;
   for( bcl = 0; bcl < GetAttributeCount( ) ; bcl++ )
   {
      // Check if the name is equal
      if ( m_AttribNames[ bcl ] == sName )
      {
         // set index fot let user to retrieve value with "GetAttributeValue( )" method
         m_attrib_index = bcl;
         return( true );
      }
   }

   return( false );
}
Esempio n. 6
0
DWORD D3DXMeshAttributeEnumer::GetAttribute( UINT uWhichIndex)
{
	_ASSERTE(uWhichIndex < GetAttributeCount());
	return *(reinterpret_cast<DWORD*>(m_pBuffer) + uWhichIndex);
}
Esempio n. 7
0
VOID D3DXMeshAttributeEnumer::SetAttribute( UINT uWhichIndex, DWORD dwAttribute )
{
	_ASSERTE(uWhichIndex < GetAttributeCount());
	*(reinterpret_cast<DWORD*>(m_pBuffer) + uWhichIndex) = dwAttribute;
}