Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Xerces.h
Go to the documentation of this file.
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef _Stroika_Foundation_DataExchange_XML_Providers_Xerces_h_
5#define _Stroika_Foundation_DataExchange_XML_Providers_Xerces_h_ 1
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
9static_assert (qStroika_HasComponent_xerces, "Don't include this file if qStroika_HasComponent_xerces not set");
10
11// avoid namespace conflict with some Xerces code
12#undef Assert
13#include <xercesc/dom/DOM.hpp>
14#include <xercesc/dom/DOMXPathEvaluator.hpp>
15#include <xercesc/framework/LocalFileFormatTarget.hpp>
16#include <xercesc/framework/MemBufFormatTarget.hpp>
17#include <xercesc/framework/MemBufInputSource.hpp>
18#include <xercesc/framework/XMLGrammarPoolImpl.hpp>
19#include <xercesc/parsers/SAX2XMLReaderImpl.hpp>
20#include <xercesc/parsers/XercesDOMParser.hpp>
21#include <xercesc/sax/InputSource.hpp>
22#include <xercesc/sax2/DefaultHandler.hpp>
23#include <xercesc/sax2/SAX2XMLReader.hpp>
24#include <xercesc/sax2/XMLReaderFactory.hpp>
25#include <xercesc/util/BinInputStream.hpp>
26#include <xercesc/util/OutOfMemoryException.hpp>
27#include <xercesc/util/PlatformUtils.hpp>
28#include <xercesc/util/XMLEntityResolver.hpp>
29#include <xercesc/util/XMLString.hpp>
30#include <xercesc/util/XMLUni.hpp>
31#include <xercesc/validators/common/Grammar.hpp>
32#define Assert(c) AssertExpression (c);
33
38
39/**
40 * \file
41 *
42 * \note Code-Status: <a href="Code-Status.md#Beta">Beta</a>
43 *
44 * \note - Generally most code should NOT include this file - its implementation specific data for each provider
45 * Mostly use to control which implementation you are using for SAX, Schema etc, and/or to access implementation-specific objects
46 * from schema, DOM nodes, etc.
47 */
48
49namespace Stroika::Foundation::DataExchange::XML::Providers::Xerces {
50
51 /**
52 */
53 struct IXercesSchemaRep : Schema::IRep {
54 virtual xercesc::XMLGrammarPool* GetCachedGrammarPool () = 0;
55 };
56
57 /**
58 */
59 struct IXercesNodeRep : virtual DOM::Node::IRep {
60 virtual xercesc::DOMNode* GetInternalTRep () = 0;
61 };
62
63 /**
64 */
65 Characters::String xercesString2String (const XMLCh* s, const XMLCh* e);
66 Characters::String xercesString2String (const XMLCh* t);
67
68 /**
69 * Can only be created ONCE (because Xerces library can only be initialized once). Use the default impl.
70 */
71 struct Provider : Providers::IXMLProvider {
72 Provider ();
73 Provider (const Provider&) = delete;
74 ~Provider ();
75
76 virtual shared_ptr<Schema::IRep> SchemaFactory (const Streams::InputStream::Ptr<byte>& schemaData,
77 const Resource::ResolverPtr& resolver) const override;
78 virtual shared_ptr<DOM::Document::IRep> DocumentFactory (const Streams::InputStream::Ptr<byte>& in,
79 const Schema::Ptr& schemaToValidateAgainstWhileReading) const override;
80 virtual void SAXParse (const Streams::InputStream::Ptr<byte>& in, StructuredStreamEvents::IConsumer* callback,
81 const Schema::Ptr& schema) const override;
82
83 private:
84#if qStroika_Foundation_DataExchange_XML_DebugMemoryAllocations
85 struct MyXercesMemMgr_;
86 MyXercesMemMgr_* fUseXercesMemoryManager_{nullptr};
87#endif
88 };
89 inline const Provider kDefaultProvider;
90
91}
92
93/*
94 ********************************************************************************
95 ***************************** Implementation Details ***************************
96 ********************************************************************************
97 */
98CompileTimeFlagChecker_HEADER (Stroika::Foundation::DataExchange::XML, qStroika_HasComponent_xerces, qStroika_HasComponent_xerces);
99
100#endif /*_Stroika_Foundation_DataExchange_XML_Providers_Xerces_h_*/
#define CompileTimeFlagChecker_HEADER(NS_PREFIX, NAME, VALUE)
CompileTimeFlagChecker_HEADER () will generate a LINK ERROR if you ever compile a header with one val...
InputStream<>::Ptr is Smart pointer (with abstract Rep) class defining the interface to reading from ...