Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Variant/XML/Reader.cpp
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#include "Stroika/Foundation/StroikaPreComp.h"
5
7#include "Stroika/Foundation/DataExchange/BadFormatException.h"
9
10#include "Reader.h"
11
12using std::byte;
13
14using namespace Stroika::Foundation;
16using namespace Stroika::Foundation::DataExchange::XML;
17
19
20// Comment this in to turn on aggressive noisy DbgTrace in this module
21//#define USE_NOISY_TRACE_IN_THIS_MODULE_ 1
22
23class Variant::XML::Reader::Rep_ : public Variant::Reader::_IRep, public Memory::UseBlockAllocationIfAppropriate<Rep_> {
24public:
25 Rep_ (const SerializationConfiguration& config)
26 : fSerializationConfiguration_{config}
27 {
28 }
29
30public:
31 virtual _SharedPtrIRep Clone () const override
32 {
33 return make_shared<Rep_> (fSerializationConfiguration_);
34 }
35 virtual optional<filesystem::path> GetDefaultFileSuffix () const override
36 {
37 return ".xml"sv;
38 }
39 virtual VariantValue Read (const Streams::InputStream::Ptr<byte>& in) override
40 {
41 // not sure about this - we may want to led xerces read raw binary bytes!!
42 return Read (Streams::BinaryToText::Reader::New (in));
43 }
44 virtual VariantValue Read ([[maybe_unused]] const Streams::InputStream::Ptr<Character>& in) override
45 {
46#if USE_NOISY_TRACE_IN_THIS_MODULE_
47 Debug::TraceContextBumper ctx{"DataExchange::XML::Reader::Rep_::Read"};
48#endif
49// TODO - USE SAXREADER HERE!!!
50#if qStroika_HasComponent_xerces
52 return VariantValue{};
53#else
55 return VariantValue{};
56#endif
57 }
58 nonvirtual SerializationConfiguration GetConfiguration () const
59 {
60 return fSerializationConfiguration_;
61 }
62 nonvirtual void SetConfiguration (const SerializationConfiguration& config)
63 {
64 fSerializationConfiguration_ = config;
65 }
66
67private:
68 SerializationConfiguration fSerializationConfiguration_;
69};
70
71/*
72 ********************************************************************************
73 ************************** DataExchange::XML::Reader ***************************
74 ********************************************************************************
75 */
76Variant::XML::Reader::Reader (const SerializationConfiguration& config)
77 : inherited{make_shared<Rep_> (config)}
78{
79}
80
81Variant::XML::Reader::Rep_& Variant::XML::Reader::GetRep_ ()
82{
83 EnsureMember (&inherited::_GetRep (), Rep_);
84 return reinterpret_cast<Rep_&> (inherited::_GetRep ());
85}
86
87const Variant::XML::Reader::Rep_& Variant::XML::Reader::GetRep_ () const
88{
89 EnsureMember (&inherited::_GetRep (), Rep_);
90 return reinterpret_cast<const Rep_&> (inherited::_GetRep ());
91}
92
93SerializationConfiguration Variant::XML::Reader::GetConfiguration () const
94{
95 return GetRep_ ().GetConfiguration ();
96}
97
98void Variant::XML::Reader::SetConfiguration (const SerializationConfiguration& config)
99{
100 GetRep_ ().SetConfiguration (config);
101}
#define AssertNotImplemented()
Definition Assertions.h:401
#define EnsureMember(p, c)
Definition Assertions.h:319
conditional_t< qStroika_Foundation_Memory_PreferBlockAllocation and andTrueCheck, BlockAllocationUseHelper< T >, Common::Empty > UseBlockAllocationIfAppropriate
Use this to enable block allocation for a particular class. Beware of subclassing.
Simple variant-value (case variant union) object, with (variant) basic types analogous to a value in ...
InputStream<>::Ptr is Smart pointer (with abstract Rep) class defining the interface to reading from ...
Ptr New(const InputStream::Ptr< byte > &src, optional< AutomaticCodeCvtFlags > codeCvtFlags={}, optional< SeekableFlag > seekable={}, ReadAhead readAhead=eReadAheadAllowed)
Create an InputStream::Ptr<Character> from the arguments (usually binary source) - which can be used ...