Stroika Library 3.0d25
 
Loading...
Searching...
No Matches
IConsumer.h
Go to the documentation of this file.
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2026. All rights reserved
3 */
4#ifndef _Stroika_Foundation_DataExchange_StructuredStreamEvents_IConsumer_h_
5#define _Stroika_Foundation_DataExchange_StructuredStreamEvents_IConsumer_h_ 1
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
10#include "Stroika/Foundation/Containers/Mapping.h"
11
13
14/**
15 * \file
16 *
17 * \note Code-Status: <a href="Code-Status.md#Alpha">Alpha</a>
18 *
19 */
20
21namespace Stroika::Foundation::DataExchange::StructuredStreamEvents {
22
23 using Characters::String;
24 using Containers::Mapping;
25
26 /**
27 * Override any of these methods you want to recieve notification of the given event. There is no need to call the
28 * inherited version.
29 *
30 * \note INTENDED as base for EITHER XML or JSON SAX(stream) based parsing.
31 *
32 * @todo SEE http://code.google.com/p/json-simple/
33 * @todo SEE http://jackson.codehaus.org/Tutorial
34 * @todo SEE Stax API
35 *
36 * \note It MAYBE pointless and hopeless to unify SAX/JSON here... they are very different - but try and review these others
37 *
38 * \note What we call here an "Element" really corresponds more closely to a "Node" in XML. We essentuially include attributes
39 * (and may soon include processing instructions or other ignored thigns) as special type elements).
40 *
41 * @todo then when you configure the SAX parser, tell it (consmer interface returning a set of types of things it wants)
42 * to optimize so just the right types of elements sent.
43 *
44 * \note A callback MAY throw (ObjectReader does, on data it cannot map): the exception comes out of whatever drove
45 * the parse - XML::Provider::SAXParse, say - and the parse stops there. Providers go to some trouble for
46 * that, since a parser written in C lies in between (@see XML::Providers::LibXML2's SAXReader_).
47 *
48 * @see ObjectReaderRegistry for examples of one way to use this
49 */
50 class IConsumer {
51 public:
52 virtual ~IConsumer () = default;
53
54 public:
55 /**
56 * \note The default implementation ignores this.
57 */
58 virtual void StartDocument ();
59
60 public:
61 /**
62 * \note The default implementation ignores this.
63 */
64 virtual void EndDocument ();
65
66 public:
67 /**
68 * \note The default implementation ignores this.
69 *
70 * \note Before Stroika v3.0d5 - **incompatible change** - StartElement() didn't take a map of attributes.
71 * Instead, it generated a 'sub-element' for each. To achieve this same effect, a callback may simply
72 * iterate over each attribute and call 'StartElement/TextInsideElement/EndElement' in its implementation.
73 */
74 virtual void StartElement (const Name& name, const Mapping<Name, String>& attributes);
75
76 public:
77 /**
78 * \note The default implementation ignores this.
79 */
80 virtual void EndElement (const Name& name);
81
82 public:
83 /**
84 * \note The default implementation ignores this.
85 *
86 * \note Callers will report zero to many chunks of text
87 * data. They do not necessarily gather it up into one big block.
88 */
89 virtual void TextInsideElement (const String& text);
90
91 /*
92 * @todo a comment, and a processing instruction, are reported to nobody - so anything reading through this loses
93 * them, and cannot be made to keep them without a callback each here, emitted by every provider.
94 * @see Variant::XML::Reader
95 */
96 };
97
98}
99
100/*
101 ********************************************************************************
102 ***************************** Implementation Details ***************************
103 ********************************************************************************
104 */
105#include "IConsumer.inl"
106
107#endif /*_Stroika_Foundation_DataExchange_StructuredStreamEvents_IConsumer_h_*/
String is like std::u32string, except it is much easier to use, often much more space efficient,...
Definition String.h:201
A Mapping uniquely associates two elements: a key and a value (use Assocation to allow multiple value...
virtual void StartElement(const Name &name, const Mapping< Name, String > &attributes)
Definition IConsumer.cpp:24