arabica/include/DOM/Simple/DOMImplementation.hpp

96 lines
3.2 KiB
C++
Raw Normal View History

2002-06-21 13:16:28 +02:00
#ifndef JEZUK_SimpleDOM_DOMIMPLEMENTATIONIMPL_H
#define JEZUK_SimpleDOM_DOMIMPLEMENTATIONIMPL_H
2007-09-05 00:55:47 +02:00
#include <DOM/DOMImplementation.hpp>
#include <DOM/DOMException.hpp>
#include <DOM/Simple/DocumentImpl.hpp>
#include <DOM/Simple/DocumentTypeImpl.hpp>
#include <Utils/StringAdaptor.hpp>
2002-06-21 13:16:28 +02:00
2007-09-05 13:47:13 +02:00
namespace Arabica
{
2002-06-21 13:16:28 +02:00
namespace SimpleDOM
{
template<class stringT, class string_adaptorT> class DOMImplementationImpl;
template<class stringT, class string_adaptorT = Arabica::default_string_adaptor<stringT> >
2002-06-21 13:16:28 +02:00
class DOMImplementation
{
public:
static DOM::DOMImplementation<stringT> getDOMImplementation()
{
static DOM::DOMImplementation<stringT> domImpl(new DOMImplementationImpl<stringT, string_adaptorT>());
return domImpl;
} // getDOMImplementation
private:
DOMImplementation();
}; // class DOMImplementation
template<class stringT, class string_adaptorT>
class DOMImplementationImpl : public DOM::DOMImplementation_impl<stringT>
{
public:
virtual void addRef() { ++refCount_; }
virtual void releaseRef() { --refCount_; }
////////////////////////////////////////////////
// DOMImplementation methods
virtual bool hasFeature(const stringT& feature, const stringT& version) const
{
// need a proper case-insensitive compare here eventually
const char* names[] = { "Core", "core", "CORE", "XML", "xml", 0 };
for(int n = 0; names[n] != 0; ++n)
{
2005-09-30 23:36:11 +02:00
if((feature == string_adaptorT::construct_from_utf8(names[n])) &&
(string_adaptorT::empty(version) ||
version == string_adaptorT::construct_from_utf8("1.0") ||
version == string_adaptorT::construct_from_utf8("2.0")))
2002-06-21 13:16:28 +02:00
return true;
} // while
return false;
} // hasFeature
virtual DOM::DocumentType_impl<stringT>* createDocumentType(const stringT& qualifiedName,
const stringT& publicId,
const stringT& systemId)
{
DocumentTypeImpl<stringT, string_adaptorT>* di = new DocumentTypeImpl<stringT, string_adaptorT>(qualifiedName, publicId, systemId);
di->setReadOnly(true);
return di;
} // createDocumentType
virtual DOM::Document_impl<stringT>* createDocument(const stringT& namespaceURI,
const stringT& qualifiedName,
DOM::DocumentType_impl<stringT>* docType)
{
DocumentImpl<stringT, string_adaptorT>* doc = new DocumentImpl<stringT, string_adaptorT>(namespaceURI, qualifiedName, docType, this);
if(!string_adaptorT::empty(qualifiedName))
2002-06-21 13:16:28 +02:00
doc->appendChild(doc->createElementNS(namespaceURI, qualifiedName));
return doc;
} // createDocument
public:
DOMImplementationImpl() : refCount_(0) { }
virtual ~DOMImplementationImpl() { }
private:
unsigned int refCount_;
DOMImplementationImpl(const DOMImplementationImpl&);
DOMImplementationImpl& operator=(const DOMImplementationImpl&);
bool operator==(const DOMImplementationImpl&) const;
friend class DOMImplementation<stringT, string_adaptorT>;
}; // class DOMImplementationImpl
} // namespace Simple
2007-09-05 13:47:13 +02:00
} // namespace Arabica
2002-06-21 13:16:28 +02:00
#endif
// end of file