// XMLDataStore.h: interface for the WMXMLDataStore class.
//
//////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2002 Robert Cunnings. All rights reserved.
//
// You may copy, modify, distribute or publish this code free of charge.
//
// NO WARRANTY: This software is provided AS IS, without warranty of any kind.
//
//////////////////////////////////////////////////////////////////////
//
// WMXMLDocument class - implementation of simple XML storage container
// Tree based on nested "container" elements holding "item" elements
// which may have any content. Searchable using XPath like syntax.
//  
//////////////////////////////////////////////////////////////////////

#pragma once
#include "XMLDocument.h"

#include <stack>

class WMXMLDataStore :
    public WMXMLDocument
{
public:
    WMXMLDataStore(void);
    ~WMXMLDataStore(void);

    bool Seek(const wstring& wstrPath);
    WMXMLElement *GetCurrentElem() { return m_pCurrent; }
    bool CreateContainer(const wstring& wstrPath);
    bool IsContainer() { return m_bIsContainer; }
    bool IsItem() { return m_bIsItem; }
    bool ElemFound() { return m_bElemFound; }
    WMXMLElement *CreateItemElem(const wstring& wstrName);
    WMXMLElement *CreateContainerElem(const wstring& wstrName);
    bool GetElementName(WMXMLElement *pElem, wstring& wstrName);

private:

    void ParsePath(const wstring& wstrPath);

    WMXMLElement            *m_pCurrent;

    stack<wstring>          m_stackPath;
    map<wstring, wstring>   m_mapNS;

    bool                    m_bIsContainer;
    bool                    m_bIsItem;
    bool                    m_bElemFound;
};
