4#include "Stroika/Foundation/StroikaPreComp.h"
10#include "Stroika/Foundation/Execution/Exceptions.h"
12#include "Stroika/Foundation/Memory/Common.h"
15#include "Stroika/Foundation/Streams/MemoryStream.h"
16#include "Stroika/Foundation/Streams/TextToBinary.h"
25using namespace Stroika::Foundation::Debug;
27using namespace Stroika::Foundation::Memory;
28using namespace Stroika::Foundation::DataExchange::XML;
29using namespace Stroika::Foundation::DataExchange::XML::DOM;
30using namespace Stroika::Foundation::DataExchange::XML::DOM::Document;
32using Memory::MakeSharedPtr;
39XPath::XPathExpressionNotSupported::XPathExpressionNotSupported ()
40 : Execution::
Exception<runtime_error> (
"XPath implementation doesn't support that XML expression"_k)
49String XPath::Expression::Options::ToString ()
const
53 sb <<
"namespaces: "sv << fNamespaces;
54 if (fResultTypeIndex) {
55 sb <<
", resultTypeIndex: "sv << fResultTypeIndex;
57 sb <<
", ordered: "sv << fOrdered;
58 sb <<
", snapshot: "sv << fSnapshot;
71 XPath::Expression::Options fOptions_;
72 XPathExpRep_ (
String&& e,
const XPath::Expression::Options& o)
73 : fExpression_{move (e)}
81 virtual XPath::Expression::Options
GetOptions ()
const override
92String XPath::Expression::ToString ()
const
97 sb <<
"expression: "sv << fRep_->GetExpression ();
98 sb <<
", options: "sv << fRep_->GetOptions ();
110 for (
Node::Ptr c : this->GetChildren ()) {
111 static const String kID_ =
"id"s;
113 if (e.GetAttribute (kID_) ==
id) {
126String Node::Ptr::ToString ()
const
128 if (PeekRep () ==
nullptr) {
139 if (c.GetName () == eltName) {
155 fRep_->Validate (schema);
158String Document::Ptr::ToString ()
const
160 if (fRep_ ==
nullptr) {
173Document::Ptr Document::New (
const Providers::IDOMProvider& p)
181 doc.ReplaceRootElement (documentElementName);
187 return Document::Ptr{p.DocumentFactory (in, schemaToValidateAgainstWhileReading)};
192 return New (p, Streams::TextToBinary::Reader::New (in), schemaToValidateAgainstWhileReading);
195Document::Ptr Document::New (
const Providers::IDOMProvider& p,
const Ptr& clone)
203#if qStroika_Foundation_DataExchange_XML_SupportDOM
206 return New (o.GetProvider ());
211 return New (o.GetProvider (), documentElementName);
216 return New (o.GetProvider (), in, schema);
221 return New (o.GetProvider (), in, schema);
226 return New (o.GetProvider (), clone);
#define RequireNotNull(p)
auto MakeSharedPtr(ARGS_TYPE &&... args) -> shared_ptr< T >
same as make_shared, but if type T has block allocation, then use block allocation for the 'shared pa...
Similar to String, but intended to more efficiently construct a String. Mutable type (String is large...
String is like std::u32string, except it is much easier to use, often much more space efficient,...
Document::Ptr is create with Document::New, and is a smart pointer to a DOM document object.
nonvirtual void Validate(const Schema::Ptr &schema) const
nonvirtual void Write(const Streams::OutputStream::Ptr< byte > &to, const SerializationOptions &options={}) const
The document as XML: to a byte stream as UTF-8, with no byte order mark - or as a String.
nonvirtual Ptr GetChild(const NameWithNamespace &eltName) const
Node::Ptr is a smart pointer to a Node::IRep.
nonvirtual String GetExpression() const
nonvirtual Options GetOptions() const
Exception<> is a replacement (subclass) for any std c++ exception class (e.g. the default 'std::excep...
Ptr New(const InputStream::Ptr< byte > &src, optional< SeekableFlag > seekable={}, ReadAhead readAhead=eReadAheadAllowed)
Create an InputStream::Ptr<Character> from the arguments (usually binary source) - which can be used ...
An element's or attribute's name (local-name, not including a prefix), plus the namespace that name i...
How XML is read and written - for now, with which provider - taken last by each XML function (DOM::Do...