#ifndef JEZUK_SimpleDOM_DOMIMPLEMENTATIONIMPL_H #define JEZUK_SimpleDOM_DOMIMPLEMENTATIONIMPL_H #include #include #include #include #include namespace Arabica { namespace SimpleDOM { template class DOMImplementationImpl; template > class DOMImplementation { public: static DOM::DOMImplementation getDOMImplementation() { static DOM::DOMImplementation domImpl(new DOMImplementationImpl()); return domImpl; } // getDOMImplementation private: DOMImplementation(); }; // class DOMImplementation template class DOMImplementationImpl : public DOM::DOMImplementation_impl { 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) { 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"))) return true; } // while return false; } // hasFeature virtual DOM::DocumentType_impl* createDocumentType(const stringT& qualifiedName, const stringT& publicId, const stringT& systemId) { DocumentTypeImpl* di = new DocumentTypeImpl(qualifiedName, publicId, systemId); di->setReadOnly(true); return di; } // createDocumentType virtual DOM::Document_impl* createDocument(const stringT& namespaceURI, const stringT& qualifiedName, DOM::DocumentType_impl* docType) { DocumentImpl* doc = new DocumentImpl(namespaceURI, qualifiedName, docType, this); if(!string_adaptorT::empty(qualifiedName)) 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; }; // class DOMImplementationImpl } // namespace Simple } // namespace Arabica #endif // end of file