Stroika Library 3.0d25
 
Loading...
Searching...
No Matches
SAXReader.cpp
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2026. All rights reserved
3 */
4#include "Stroika/Foundation/StroikaPreComp.h"
5
6#include <atomic>
7
8#include "Stroika/Foundation/DataExchange/BadFormatException.h"
11#include "Stroika/Foundation/Execution/Common.h"
13#include "Stroika/Foundation/Execution/ProgressMonitor.h"
14#include "Stroika/Foundation/Memory/Common.h"
17
18#include "SAXReader.h"
19
20// Comment this in to turn on aggressive noisy DbgTrace in this module
21//#define USE_NOISY_TRACE_IN_THIS_MODULE_ 1
22
23using std::byte;
24
25using namespace Stroika::Foundation;
26using namespace Stroika::Foundation::Debug;
27using namespace Stroika::Foundation::Execution;
29using namespace Stroika::Foundation::DataExchange::XML;
30using namespace Stroika::Foundation::Streams;
31
32/*
33 ********************************************************************************
34 ************************************* SAXParse *********************************
35 ********************************************************************************
36 */
37#if qStroika_Foundation_DataExchange_XML_SupportParsing
38void XML::SAXParse (const Streams::InputStream::Ptr<byte>& in, StructuredStreamEvents::IConsumer* callback, const Schema::Ptr& schema,
40{
41 return SAXParse (o.GetProvider (), in, callback, schema, progress);
42}
43#endif
44
45void XML::SAXParse (const Providers::ISAXProvider& saxProvider, const Streams::InputStream::Ptr<byte>& in,
47{
48 Schema::Ptr useSchema = schema;
49 if (useSchema != nullptr) {
50 if (static_cast<const Providers::IProvider*> (schema.GetRep ()->GetProvider ()) != &saxProvider) {
51 WeakAssertNotReached (); // not necessarily a bug, but if this is done regularly, fix so they match
52 useSchema = useSchema.As<Schema::Ptr> (
53 *dynamic_cast<const Providers::ISchemaProvider*> (static_cast<const Providers::IProvider*> (&saxProvider)));
54 }
55 }
56 if (progress == nullptr) {
57 saxProvider.SAXParse (in, callback, useSchema);
58 }
59 else {
60 // IF progress provided, wrap 'in' in magic to handle progress
61 saxProvider.SAXParse (Execution::MakeInputStreamWithProgress (in, progress), callback, useSchema);
62 }
63}
#define WeakAssertNotReached()
Definition Assertions.h:470
void SAXParse(const Providers::ISAXProvider &saxProvider, const Streams::InputStream::Ptr< byte > &in, StructuredStreamEvents::IConsumer *callback=nullptr, const Schema::Ptr &schema=nullptr, Execution::ProgressMonitor::Updater progress=nullptr)
Definition SAXReader.cpp:45
InputStream<>::Ptr is Smart pointer (with abstract Rep) class defining the interface to reading from ...
How XML is read and written - for now, with which provider - taken last by each XML function (DOM::Do...