Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

XMLLite: Passing the Reader/IStream

xml stream

  • Please log in to reply
1 reply to this topic

#1 Buttacup

Buttacup

    CC Resident

  • Just Joined
  • PipPipPipPip
  • 71 posts

Posted 11 March 2010 - 10:30 AM

Wasn't sure where to post this so o-o

I'm implementing xmllite for serialization. I have my executable and it needs to pass off the reader/writer or the IStream to external modules, I would like to just pass the file instead. Doing this would allow the modules to decide which xml parser they wish to implement. Essentially I would like to hit an element node which wraps the serialization of a class or data member and pass off. The problem I'm seeing with handing off the file is the recipient then has to go through the file to get to the line where it is required to read/write from. This obliviates any wrapping and is rather time consuming when thousands, tens or hundreds of thousands of classes are serializing. I do not see a GotoLine() in xmllite, It does supply a GetLineNumber() but.... suggestions? Currently thinking to have an xml file cab or folder which I will bitstream into a collective file etc...
  • 0

#2 Buttacup

Buttacup

    CC Resident

  • Just Joined
  • PipPipPipPip
  • 71 posts

Posted 12 March 2010 - 01:07 AM

Not that this will help any but hey I haven't come up with anything in a few days ~week ....

HRESULT DMA::LoadROM()
{
    HRESULT hr = S_OK;;

    if(map_modules.empty())
        InitMappedModules();

    CreateReader();
    PCWSTR uri = 0;
    UINT length_uri = 0;

    PCWSTR name = 0;
    UINT length_name = 0;

    PCWSTR value = 0;
    UINT length_value = 0;
    
    XmlNodeType nodeType;
        
    while(S_OK == (hr = Reader->Read(&nodeType)))
    {
        switch(nodeType)
        {

         case XmlNodeType_None:
            break;

         case XmlNodeType_Element:
            {
                Reader->GetNamespaceUri(&uri, &length_uri);
                Reader->GetLocalName(&name, &length_name);

                switch(map_modules[name])
                {

                case MODULE_NULL:
                    break;

                case MODULE_RC:
                    {
                        Reader->MoveToFirstAttribute();
                        Reader->GetValue(&value, &length_value);

                        wstring DllRenderChain = value;

                        NewModuleRenderChain( DllRenderChain.c_str() );
                    }
                    break;

                case MODULE_RAMDAC:
                    {
                        wstring DllRAMDAC = L"";
                        wstring DllBuffer = L"";
                        wstring Priority = L"";

                        Reader->MoveToFirstAttribute();
                        Reader->GetValue(&value, &length_value);

                        DllRAMDAC = value;

                        Reader->MoveToNextAttribute();
                        Reader->GetValue(&value, &length_value);

                        DllBuffer = value;

                        Reader->MoveToNextAttribute();
                        Reader->GetValue(&value, &length_value);

                        Priority = value;

                        NewModuleRAMDAC( DllRAMDAC.c_str(), DllBuffer.c_str(), Priority.c_str() );
                    }
                    break;

                case MODULE_EFFECT:
                    break;

                case MODULE_KEYBORD:
                    {
                        Reader->MoveToFirstAttribute();
                        Reader->GetValue(&value, &length_value);
                                                
                        wstring DllKeyboard = value;

                        NewModuleKeyboard(DllKeyboard.c_str());
                    }
                    break;

                case MODULE_MOUSE:
                    {
                        Reader->MoveToFirstAttribute();
                        Reader->GetValue(&value, &length_value);

                        wstring DllMouse = value;

                        NewModuleMouse(DllMouse.c_str());
                    }
                    break;

                case MODULE_MATH:
                case MODULE_PHYSX:
                    break;

                case MODULE_STUDIO:
                case MODULE_CLIENT:
                    {
                        Reader->MoveToFirstAttribute();
                        Reader->GetValue(&value, &length_value);

                        wstring DllStudio = value;

                        Reader->MoveToNextAttribute();
                        Reader->GetValue(&value, &length_value);

                        wstring XmlStudio = value;

                         NewModuleStudio( DllStudio.c_str(), XmlStudio.c_str() );
                    }
                    break;

                case MODULE_SERVER:
                    break;

                case MODULE_NETWORK:
                    break;

                }
            }
            break;

        case XmlNodeType_Attribute:
            break;

        case XmlNodeType_Text:
            break;

        case XmlNodeType_CDATA:
            break;

        case XmlNodeType_ProcessingInstruction:
            break;

        case XmlNodeType_Comment:
            break;

        case XmlNodeType_DocumentType:
            break;

        case XmlNodeType_Whitespace:
            break;

        case XmlNodeType_EndElement:
            break;

        case XmlNodeType_XmlDeclaration:
            break;

        }
    }

    if(hr = S_FALSE)
        return S_OK;
    else
        return hr;
}
HRESULT DMA::NewModuleStudio( LPCWSTR lpszDllStudio, LPCWSTR lpszXmlStudio )
{
    HRESULT hr = S_OK;;

    HINSTANCE hdll = NULL;
    typedef void (*pLoadStudio)(ICLIENT**);
    pLoadStudio LoadStudio;
    
    wstring Plug = DIR_ROOT + DIR_DLL + wstring(lpszDllStudio);
    hdll = LoadLibraryEx(Plug.c_str(), NULL, 0 );
    LoadStudio = (pLoadStudio)(GetProcAddress( hdll, "GetNewClient" ));
    LoadStudio(&Client);

    ISerialize* LoadClient;
    hr = Client->QueryInterface(IID_ISerialize, (void**)&LoadClient);
    if(FAILED(hr))
        return hr;

    LoadClient->Deserialize(lpszXmlStudio); <===== BIG HAND OFF

    return hr;
}
and then I'm left just recreating the Reader on a new file 'cause like there is no GoToLine() and I would have to reparse the file over again...... are I missing something??? -.-

HRESULT G_A_U_D::CreateReader( LPCWSTR lpszXMLSerialClassFile )
{
    HRESULT hr = S_OK;;
    
    for(UINT i = 0; i < wstring(DIR_ROOT + DIR_ROM + lpszXMLSerialClassFile).size(); i++)
        File[i] = wstring(DIR_ROOT + DIR_ROM + lpszXMLSerialClassFile).at(i);
    File[wstring(DIR_ROOT + DIR_ROM + lpszXMLSerialClassFile).size()] = '\0';

    hr = SHCreateStreamOnFileEx(File, STGM_READ, STGM_FAILIFTHERE, false, NULL, &StreamIn);
    if (SUCCEEDED(hr))
        hr = CreateXmlReader(__uuidof(IXmlReader), (void**) &Reader, NULL);
    if (SUCCEEDED(hr))
        hr = Reader->SetProperty(XmlReaderProperty_DtdProcessing, DtdProcessing_Prohibit);
    if (SUCCEEDED(hr))
        hr = Reader->SetInput(StreamIn);
    
    return hr;
}
oh wells..... sorry again, kind of an only resort post, not expecting a reply just thought I would try.....
  • 0





Also tagged with one or more of these keywords: xml, stream

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download