Click here to Skip to main content
15,881,882 members
Articles / Desktop Programming / MFC

Customizable Window Layouts

Rate me:
Please Sign up or sign in to vote.
5.00/5 (16 votes)
28 Jul 2008CPOL6 min read 39.9K   1.8K   51  
A class to facilitate user defined dialog and window control layouts.
////////////////////////////////////////////////
// xmlfile.h
//
// 2008 Roland Trainor
//


#ifndef _XMLFILE_H_
#define _XMLFILE_H_

#include <istream>

////////////////////////////////////////////////
// CXMLParser
//
// This class is intended to provide a simple 
//  mechanism for loading and parsing-out information 
//  from an XML-based stream.
//

class CXMLParser
{
public:
    class Exception
    {
    public:
        Exception(LPCSTR lpszMessage) : m_strMessage(lpszMessage) {}
        CString& GetErrorMessage(void) { return m_strMessage; }

    private:
        CString m_strMessage;
    };

public:
    // Construction/destruction...
    CXMLParser();
    ~CXMLParser();

    // Persistance...
    virtual void ParseFile(LPCSTR lpszFilename);
    virtual void ParseString(LPCSTR lpszText);
    virtual void ParseStream(std::istream* pStream);

protected:
    // Persistance...
    void* ParseComment(std::istream* pStream, void* pUserData);
    void* ParseProperties(std::istream* pStream, void* pUserData);
    void* ParseProcessingInstruction(std::istream* pStream, LPCSTR lpszTarget, void* pUserData);
    void ParseOverWhiteSpace(std::istream* pStream);

    // Processing...
    virtual void* OnProcessingInstructionBegin(LPCSTR lpszTarget, void* pUserData);
    virtual void* OnProcessingInstructionEnd(LPCSTR lpszTarget, void* pUserData);
    virtual void* OnElementBegin(LPCSTR lpszElementTag, void* pUserData);
    virtual void* OnElementData(LPCSTR lpszElementData, void* pUserData);
    virtual void* OnElementEnd(LPCSTR lpszElementTag, void* pUserData);
    virtual void* OnProperty(LPCSTR lpszPropertyName, LPCSTR lpszPropertyValue, void* pUserData);
    virtual void* OnComment(LPCSTR lpszComment, void* pUserData);

    // Data...
    unsigned long m_lNumCharactersProcessed;
    unsigned long m_lNumCharactersInFile;
};

#endif //_XMLFILE_H_

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions