Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
IProvider.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_IProvider_h_
5#define _Stroika_Foundation_DataExchange_XML_Providers_IProvider_h_ 1
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
10#include "Stroika/Foundation/DataExchange/XML/DOM.h"
13#include "Stroika/Foundation/Execution/LazyInitialized.h"
15
16/**
17 * \file
18 *
19 * Generally ignore this file/module unless you need to control which XML provider you are using
20 * and/or to access internal representations from one of these providers.
21 *
22 * \note Code-Status: <a href="Code-Status.md#Alpha">Alpha</a>
23 */
24
25namespace Stroika::Foundation::DataExchange::XML::Providers {
26
27 /**
28 * Abstract interface generally unused EXCEPT to compare that the ISchemaProvider POINTER EQUALS the IDOMProvider pointer.
29 */
30 struct IProvider {
31 virtual ~IProvider () = default;
32 };
33
34 struct ISchemaProvider : public virtual IProvider {
35 virtual ~ISchemaProvider () = default;
36 virtual shared_ptr<Schema::IRep> SchemaFactory (const Streams::InputStream::Ptr<byte>& schemaData,
37 const Resource::ResolverPtr& resolver) const = 0;
38 };
39 struct IDOMProvider : public virtual IProvider {
40 virtual ~IDOMProvider () = default;
41 // Note input stream 'in' maybe nullptr to avoid reading and create new blank with no root
42 virtual shared_ptr<DOM::Document::IRep> DocumentFactory (const Streams::InputStream::Ptr<byte>& in,
43 const Schema::Ptr& schemaToValidateAgainstWhileReading) const = 0;
44 };
45 struct ISAXProvider : public virtual IProvider {
46 virtual ~ISAXProvider () = default;
47 virtual void SAXParse (const Streams::InputStream::Ptr<byte>& in, StructuredStreamEvents::IConsumer* callback,
48 const Schema::Ptr& schema) const = 0;
49 };
50 struct IXMLProvider : ISchemaProvider, IDOMProvider, ISAXProvider {};
51
52#if qStroika_Foundation_DataExchange_XML_SupportParsing and qStroika_Foundation_DataExchange_XML_SupportSchema and qStroika_Foundation_DataExchange_XML_SupportDOM
53 namespace Private_ {
54 const IXMLProvider* GetDefaultProvider_ ();
55 }
56#endif
57
58 /**
59 * Provided as using LazyInitialized so can be ...??? so used before main - and still destroyed properly... without forcing include of libxml2/xerces stuff
60 */
61#if qStroika_Foundation_DataExchange_XML_SupportParsing and qStroika_Foundation_DataExchange_XML_SupportSchema and qStroika_Foundation_DataExchange_XML_SupportDOM
62 inline const Foundation::Execution::LazyInitialized<const IXMLProvider*> kDefaultProvider{Private_::GetDefaultProvider_};
63#endif
64
65}
66
67#endif /*_Stroika_Foundation_DataExchange_XML_Providers_IProvider_h_*/
InputStream<>::Ptr is Smart pointer (with abstract Rep) class defining the interface to reading from ...