Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
IConsumer.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_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
12#include "Name.h"
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 * @see ObjectReaderRegistry for examples of one way to use this
45 */
46 class IConsumer {
47 public:
48 virtual ~IConsumer () = default;
49
50 public:
51 /**
52 * \note The default implementation ignores this.
53 */
54 virtual void StartDocument ();
55
56 public:
57 /**
58 * \note The default implementation ignores this.
59 */
60 virtual void EndDocument ();
61
62 public:
63 /**
64 * \note The default implementation ignores this.
65 *
66 * \note Before Stroika v3.0d5 - **incompatible change** - StartElement() didn't take a map of attributes.
67 * Instead, it generated a 'sub-element' for each. To achieve this same effect, a callback may simply
68 * iterate over each attribute and call 'StartElement/TextInsideElement/EndElement' in its implementation.
69 */
70 virtual void StartElement (const Name& name, const Mapping<Name, String>& attributes);
71
72 public:
73 /**
74 * \note The default implementation ignores this.
75 */
76 virtual void EndElement (const Name& name);
77
78 public:
79 /**
80 * \note The default implementation ignores this.
81 *
82 * \note Callers will report zero to many chunks of text
83 * data. They do not necessarily gather it up into one big block.
84 */
85 virtual void TextInsideElement (const String& text);
86 };
87
88}
89
90/*
91 ********************************************************************************
92 ***************************** Implementation Details ***************************
93 ********************************************************************************
94 */
95#include "IConsumer.inl"
96
97#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
virtual void StartElement(const Name &name, const Mapping< Name, String > &attributes)
Definition IConsumer.cpp:24