]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/xtixml.cpp
Fix typo in last commit
[wxWidgets.git] / src / common / xtixml.cpp
index c0c6e3b5beeeccc69f160078c1f53814b60089e6..33fb30d3415bc993315d3b32eb45538d593795ff 100644 (file)
 #include "wx/wxprec.h"
 
 #ifdef __BORLANDC__
 #include "wx/wxprec.h"
 
 #ifdef __BORLANDC__
-    #pragma hdrstop
+#pragma hdrstop
 #endif
 
 #if wxUSE_EXTENDED_RTTI
 
 #endif
 
 #if wxUSE_EXTENDED_RTTI
 
-#include "wx/xtixml.h"
+#include "wx/xtistrm.h"
 
 #ifndef WX_PRECOMP
     #include "wx/object.h"
 
 #ifndef WX_PRECOMP
     #include "wx/object.h"
@@ -30,6 +30,7 @@
 #include "wx/tokenzr.h"
 #include "wx/txtstrm.h"
 #include "wx/xtistrm.h"
 #include "wx/tokenzr.h"
 #include "wx/txtstrm.h"
 #include "wx/xtistrm.h"
+#include "wx/xtixml.h"
 
 // STL headers
 
 
 // STL headers
 
@@ -110,17 +111,19 @@ void wxObjectXmlWriter::DoEndWriteTopLevelEntry( const wxString &WXUNUSED(name)
 
 void wxObjectXmlWriter::DoBeginWriteObject(const wxObject *WXUNUSED(object), 
                                      const wxClassInfo *classInfo, 
 
 void wxObjectXmlWriter::DoBeginWriteObject(const wxObject *WXUNUSED(object), 
                                      const wxClassInfo *classInfo, 
-                                     int objectID, wxVariantBaseArray &metadata   )
+                                     int objectID, const wxStringToAnyHashMap &metadata   )
 {
     wxXmlNode *pnode;
     pnode = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("object"));
     pnode->AddProperty(wxT("class"), wxString(classInfo->GetClassName()));
     pnode->AddProperty(wxT("id"), wxString::Format( wxT("%d"), objectID ) );
 
 {
     wxXmlNode *pnode;
     pnode = new wxXmlNode(wxXML_ELEMENT_NODE, wxT("object"));
     pnode->AddProperty(wxT("class"), wxString(classInfo->GetClassName()));
     pnode->AddProperty(wxT("id"), wxString::Format( wxT("%d"), objectID ) );
 
-    for ( size_t i = 0; i < metadata.GetCount(); ++i )
+    wxStringToAnyHashMap::const_iterator it, en;
+    for( it = metadata.begin(), en = metadata.end(); it != en; ++it )
     {
     {
-        pnode->AddProperty( metadata[i].GetName(), metadata[i].GetAsString() );
+        pnode->AddProperty( it->first, wxAnyGetAsString(it->second) );
     }
     }
+
     m_data->m_current->AddChild(pnode);
     m_data->Push( pnode );
 }
     m_data->m_current->AddChild(pnode);
     m_data->Push( pnode );
 }
@@ -132,9 +135,9 @@ void wxObjectXmlWriter::DoEndWriteObject(const wxObject *WXUNUSED(object),
     m_data->Pop();
 }
 
     m_data->Pop();
 }
 
-void wxObjectXmlWriter::DoWriteSimpleType( wxVariantBase &value )
+void wxObjectXmlWriter::DoWriteSimpleType( const wxAny &value )
 {
 {
-    wxXmlAddContentToNode( m_data->m_current,value.GetAsString() );
+    wxXmlAddContentToNode( m_data->m_current,wxAnyGetAsString(value) );
 }
 
 void wxObjectXmlWriter::DoBeginWriteElement()
 }
 
 void wxObjectXmlWriter::DoBeginWriteElement()
@@ -204,13 +207,13 @@ as properties are always sought by typeinfo over all levels
 and create params are always toplevel class only
 */
 
 and create params are always toplevel class only
 */
 
-int wxObjectXmlReader::ReadComponent(wxXmlNode *node, wxObjectWriterCallback *callbacks)
+int wxObjectXmlReader::ReadComponent(wxXmlNode *node, wxObjectReaderCallback *callbacks)
 {
     wxASSERT_MSG( callbacks, wxT("Does not support reading without a Depersistor") );
     wxString className;
     wxClassInfo *classInfo;
 
 {
     wxASSERT_MSG( callbacks, wxT("Does not support reading without a Depersistor") );
     wxString className;
     wxClassInfo *classInfo;
 
-    wxVariantBase *createParams;
+    wxAny *createParams;
     int *createParamOids;
     const wxClassInfo** createClassInfos;
     wxXmlNode *children;
     int *createParamOids;
     const wxClassInfo** createClassInfos;
     wxXmlNode *children;
@@ -221,7 +224,7 @@ int wxObjectXmlReader::ReadComponent(wxXmlNode *node, wxObjectWriterCallback *ca
     if (!children)
     {
         // check for a null object or href
     if (!children)
     {
         // check for a null object or href
-        if (node->GetPropVal(wxT("href"), &ObjectIdString ) )
+        if (node->GetAttribute(wxT("href"), &ObjectIdString ) )
         {
             objectID = atoi( ObjectIdString.ToAscii() );
             if ( HasObjectClassInfo( objectID ) )
         {
             objectID = atoi( ObjectIdString.ToAscii() );
             if ( HasObjectClassInfo( objectID ) )
@@ -234,12 +237,12 @@ int wxObjectXmlReader::ReadComponent(wxXmlNode *node, wxObjectWriterCallback *ca
                 return wxInvalidObjectID;
             }
         }
                 return wxInvalidObjectID;
             }
         }
-        if ( !node->GetPropVal(wxT("id"), &ObjectIdString ) )
+        if ( !node->GetAttribute(wxT("id"), &ObjectIdString ) )
         {
             return wxNullObjectID;
         }
     }
         {
             return wxNullObjectID;
         }
     }
-    if (!node->GetPropVal(wxT("class"), &className))
+    if (!node->GetAttribute(wxT("class"), &className))
     {
         // No class name.  Eek. FIXME: error handling
         return wxInvalidObjectID;
     {
         // No class name.  Eek. FIXME: error handling
         return wxInvalidObjectID;
@@ -257,7 +260,7 @@ int wxObjectXmlReader::ReadComponent(wxXmlNode *node, wxObjectWriterCallback *ca
         wxLogError(_("objects cannot have XML Text Nodes") );
         return wxInvalidObjectID;
     }
         wxLogError(_("objects cannot have XML Text Nodes") );
         return wxInvalidObjectID;
     }
-    if (!node->GetPropVal(wxT("id"), &ObjectIdString))
+    if (!node->GetAttribute(wxT("id"), &ObjectIdString))
     {
         wxLogError(_("Objects must have an id attribute") );
         // No object id.  Eek. FIXME: error handling
     {
         wxLogError(_("Objects must have an id attribute") );
         // No object id.  Eek. FIXME: error handling
@@ -276,14 +279,14 @@ int wxObjectXmlReader::ReadComponent(wxXmlNode *node, wxObjectWriterCallback *ca
     // first make the object know to our internal registry
     SetObjectClassInfo( objectID, classInfo );
 
     // first make the object know to our internal registry
     SetObjectClassInfo( objectID, classInfo );
 
-    wxVariantBaseArray metadata;
-    wxXmlProperty *xp = node->GetProperties();
+    wxStringToAnyHashMap metadata;
+    wxXmlProperty *xp = node->GetAttributes();
     while ( xp )
     {
         if ( xp->GetName() != wxString(wxT("class")) && 
              xp->GetName() != wxString(wxT("id")) )
         {
     while ( xp )
     {
         if ( xp->GetName() != wxString(wxT("class")) && 
              xp->GetName() != wxString(wxT("id")) )
         {
-            metadata.Add( new wxVariantBase( xp->GetValue(), xp->GetName() ) );
+            metadata[xp->GetName()] = wxAny( xp->GetValue() );
         }
         xp = xp->GetNext();
     }
         }
         xp = xp->GetNext();
     }
@@ -292,7 +295,7 @@ int wxObjectXmlReader::ReadComponent(wxXmlNode *node, wxObjectWriterCallback *ca
 
     //
     // stream back the Create parameters first
 
     //
     // stream back the Create parameters first
-    createParams = new wxVariantBase[ classInfo->GetCreateParamCount() ];
+    createParams = new wxAny[ classInfo->GetCreateParamCount() ];
     createParamOids = new int[classInfo->GetCreateParamCount() ];
     createClassInfos = new const wxClassInfo*[classInfo->GetCreateParamCount() ];
 
     createParamOids = new int[classInfo->GetCreateParamCount() ];
     createClassInfos = new const wxClassInfo*[classInfo->GetCreateParamCount() ];
 
@@ -309,7 +312,7 @@ int wxObjectXmlReader::ReadComponent(wxXmlNode *node, wxObjectWriterCallback *ca
     while( children )
     {
         wxString name;
     while( children )
     {
         wxString name;
-        children->GetPropVal( wxT("name"), &name );
+        children->GetAttribute( wxT("name"), &name );
         propertyNames.push_back( (const wxChar*)name.c_str() );
         propertyNodes[(const wxChar*)name.c_str()] = children->GetChildren();
         children = children->GetNext();
         propertyNames.push_back( (const wxChar*)name.c_str() );
         propertyNodes[(const wxChar*)name.c_str()] = children->GetChildren();
         children = children->GetNext();
@@ -347,7 +350,7 @@ int wxObjectXmlReader::ReadComponent(wxXmlNode *node, wxObjectWriterCallback *ca
                     {
                         long realval;
                         eti->ConvertToLong( createParams[i], realval );
                     {
                         long realval;
                         eti->ConvertToLong( createParams[i], realval );
-                        createParams[i] = wxVariantBase( realval );
+                        createParams[i] = wxAny( realval );
                     }
                     else
                     {
                     }
                     else
                     {
@@ -396,7 +399,7 @@ int wxObjectXmlReader::ReadComponent(wxXmlNode *node, wxObjectWriterCallback *ca
     // properties were written in the xml
     for ( size_t j = 0; j < propertyNames.size(); ++j )
     {
     // properties were written in the xml
     for ( size_t j = 0; j < propertyNames.size(); ++j )
     {
-        if ( propertyNames[j].length() )
+        if ( !propertyNames[j].empty() )
         {
             PropertyNodes::iterator propiter = propertyNodes.find( propertyNames[j] );
             if ( propiter != propertyNodes.end() )
         {
             PropertyNodes::iterator propiter = propertyNodes.find( propertyNames[j] );
             if ( propiter != propertyNodes.end() )
@@ -435,7 +438,7 @@ int wxObjectXmlReader::ReadComponent(wxXmlNode *node, wxObjectWriterCallback *ca
                             }
                             else
                             {
                             }
                             else
                             {
-                                wxVariantBase elementValue = ReadValue( elementContent, elementType );
+                                wxAny elementValue = ReadValue( elementContent, elementType );
                                 if ( pi->GetAccessor()->HasAdder() )
                                     callbacks->AddToPropertyCollection( objectID, classInfo,pi, elementValue );
                             }
                                 if ( pi->GetAccessor()->HasAdder() )
                                     callbacks->AddToPropertyCollection( objectID, classInfo,pi, elementValue );
                             }
@@ -462,7 +465,7 @@ int wxObjectXmlReader::ReadComponent(wxXmlNode *node, wxObjectWriterCallback *ca
                         else
                         {
                             wxASSERT( pi->GetTypeInfo()->HasStringConverters() );
                         else
                         {
                             wxASSERT( pi->GetTypeInfo()->HasStringConverters() );
-                            wxVariantBase nodeval = ReadValue( prop, pi->GetTypeInfo() );
+                            wxAny nodeval = ReadValue( prop, pi->GetTypeInfo() );
                             callbacks->SetProperty( objectID, classInfo,pi, nodeval );
                         }
                     }
                             callbacks->SetProperty( objectID, classInfo,pi, nodeval );
                         }
                     }
@@ -480,7 +483,7 @@ int wxObjectXmlReader::ReadComponent(wxXmlNode *node, wxObjectWriterCallback *ca
                             wxClassInfo* sinkClassInfo = GetObjectClassInfo( sinkOid );
 
                             callbacks->SetConnect( objectID, classInfo, pi, sinkClassInfo,
                             wxClassInfo* sinkClassInfo = GetObjectClassInfo( sinkOid );
 
                             callbacks->SetConnect( objectID, classInfo, pi, sinkClassInfo,
-                                sinkClassInfo->FindHandlerInfo(handlerName),  sinkOid );
+                                sinkClassInfo->FindHandlerInfo(handlerName.c_str()),  sinkOid );
                         }
                         else
                         {
                         }
                         else
                         {
@@ -491,7 +494,7 @@ int wxObjectXmlReader::ReadComponent(wxXmlNode *node, wxObjectWriterCallback *ca
                 }
                 else
                 {
                 }
                 else
                 {
-                    wxVariantBase nodeval = ReadValue( prop, pi->GetTypeInfo() );
+                    wxAny nodeval = ReadValue( prop, pi->GetTypeInfo() );
                     if( pi->GetFlags() & wxPROP_ENUM_STORE_LONG )
                     {
                         const wxEnumTypeInfo *eti = 
                     if( pi->GetFlags() & wxPROP_ENUM_STORE_LONG )
                     {
                         const wxEnumTypeInfo *eti = 
@@ -500,7 +503,7 @@ int wxObjectXmlReader::ReadComponent(wxXmlNode *node, wxObjectWriterCallback *ca
                         {
                             long realval;
                             eti->ConvertToLong( nodeval, realval );
                         {
                             long realval;
                             eti->ConvertToLong( nodeval, realval );
-                            nodeval = wxVariantBase( realval );
+                            nodeval = wxAny( realval );
                         }
                         else
                         {
                         }
                         else
                         {
@@ -520,24 +523,24 @@ int wxObjectXmlReader::ReadComponent(wxXmlNode *node, wxObjectWriterCallback *ca
     return objectID;
 }
 
     return objectID;
 }
 
-wxVariantBase wxObjectXmlReader::ReadValue(wxXmlNode *node,
+wxAny wxObjectXmlReader::ReadValue(wxXmlNode *node,
                                   const wxTypeInfo *type )
 {
     wxString content;
     if ( node )
         content = node->GetContent();
                                   const wxTypeInfo *type )
 {
     wxString content;
     if ( node )
         content = node->GetContent();
-    wxVariantBase result;
+    wxAny result;
     type->ConvertFromString( content, result );
     return result;
 }
 
     type->ConvertFromString( content, result );
     return result;
 }
 
-int wxObjectXmlReader::ReadObject( const wxString &name, wxObjectWriterCallback *callbacks)
+int wxObjectXmlReader::ReadObject( const wxString &name, wxObjectReaderCallback *callbacks)
 {
     wxXmlNode *iter = m_parent->GetChildren();
     while ( iter )
     {
         wxString entryName;
 {
     wxXmlNode *iter = m_parent->GetChildren();
     while ( iter )
     {
         wxString entryName;
-        if ( iter->GetPropVal(wxT("name"), &entryName) )
+        if ( iter->GetAttribute(wxT("name"), &entryName) )
         {
             if ( entryName == name )
                 return ReadComponent( iter->GetChildren(), callbacks );
         {
             if ( entryName == name )
                 return ReadComponent( iter->GetChildren(), callbacks );