arabica/include/DOM/Simple/DOMImplementation.hpp

94 lines
3.4 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/DOMException.hpp>
#include <DOM/DOMImplementation.hpp>
2007-09-05 00:55:47 +02:00
#include <DOM/Simple/DocumentImpl.hpp>
#include <DOM/Simple/DocumentTypeImpl.hpp>
#include <Arabica/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, string_adaptorT> getDOMImplementation()
2002-06-21 13:16:28 +02:00
{
static DOMImplementationImpl<stringT, string_adaptorT> domImpl;
return DOM::DOMImplementation<stringT, string_adaptorT>(&domImpl);
2002-06-21 13:16:28 +02:00
} // getDOMImplementation
private:
DOMImplementation();
}; // class DOMImplementation
template<class stringT, class string_adaptorT>
class DOMImplementationImpl : public DOM::DOMImplementation_impl<stringT, string_adaptorT>
2002-06-21 13:16:28 +02:00
{
public:
// we don't actually need the ref count in this case
virtual void addRef() { }
virtual void releaseRef() { }
2002-06-21 13:16:28 +02:00
////////////////////////////////////////////////
// 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, string_adaptorT>* createDocumentType(const stringT& qualifiedName,
const stringT& publicId,
const stringT& systemId)
2002-06-21 13:16:28 +02:00
{
DocumentTypeImpl<stringT, string_adaptorT>* di = new DocumentTypeImpl<stringT, string_adaptorT>(qualifiedName, publicId, systemId);
di->setReadOnly(true);
return di;
} // createDocumentType
virtual DOM::Document_impl<stringT, string_adaptorT>* createDocument(const stringT& namespaceURI,
const stringT& qualifiedName,
DOM::DocumentType_impl<stringT, string_adaptorT>* docType)
2002-06-21 13:16:28 +02:00
{
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
private:
DOMImplementationImpl() { }
virtual ~DOMImplementationImpl() { }
2002-06-21 13:16:28 +02:00
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