Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
StyledTextIO_LedNative.h
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef _Stroika_Frameworks_Led_StyledTextIO_LedNative_h_
5#define _Stroika_Frameworks_Led_StyledTextIO_LedNative_h_ 1
6
7/*
8@MODULE: StyledTextIO
9@DESCRIPTION:
10 <p>A portable attempt at abstracting away the details of styled text file IO and all
11 the different formats for styled text.</p>
12 <p>This code defines APIs which should allow for reading any different styled text format.
13 And dumping it to any different output (eg. text buffer).</p>
14 <p>The only real LED-SPECIFIC parts of this are that I only provide concrete output (aka sinks)
15 implementations to Led StandardStyledTextImagers. And that some of the Src/Sink APIs are oriented towards what would be
16 helpful for a Led-based editor (in other words, features not supported by Led aren't communicated to/from the src/sinks).</p>
17 <p>The <em>big picture</em> for this module is that there are two main basic subdivisions. There are
18 @'StyledTextIOReader' subclasses, and @'StyledTextIOWriter' subclasses. The readers are for READING some file format,
19 and converting it to a stream of method calls (on a sink to be described later). And writers are for writing those
20 formatted data files, based on results of method calls on an abstract source class.</p>
21 <p>Though @'StyledTextIOReader' and @'StyledTextIOWriter' share no common base class, they <em>do</em> follow
22 a very similar design pattern. They both define abstract 'sources' and 'sinks' for their operation.</p>
23 <p>For a @'StyledTextIOReader', it reads its data from a @'StyledTextIOReader::SrcStream' (typically maybe a file),
24 and writes it to a @'StyledTextIOReader::SinkStream' (typically a Led-text-buffer/view).</p>
25 <p>A @'StyledTextIOWriter', writes data extracted from a @'StyledTextIOWriter::SrcStream'
26 (typically view/textstore, much like a @'StyledTextIOReader::SinkStream'),
27 and writes it to a @'StyledTextIOWriter::SinkStream' (typically an output file).</p>
28 <p>These abstract sources and sinks are defined to just the minimal pure virtual APIs needed to extract/write bare bytes,
29 or formatted text in a format Led can understand. Several concrete instantiations of each are provided by Led (some here, and
30 some in other modules, as appropriate).</p>
31 <p>Subclasses of @'StyledTextIOReader' and @'StyledTextIOWriter' are where the knowledge of particular file formats resides.
32 For example, the knowledge of how to read RTF is in @'StyledTextIOReader_RTF' and the knowledge of how to write HTML is in
33 @'StyledTextIOWriter_HTML'.</p>
34 */
35
36#include "Stroika/Frameworks/StroikaPreComp.h"
37
38#include "StyledTextIO.h"
39
40namespace Stroika::Frameworks::Led::StyledTextIO {
41
42 /*
43 @CLASS: StyledTextIOReader_LedNativeFileFormat
44 @BASES: @'StyledTextIOReader'
45 @DESCRIPTION:
46 */
47 class StyledTextIOReader_LedNativeFileFormat : public StyledTextIOReader {
48 public:
49 StyledTextIOReader_LedNativeFileFormat (SrcStream* srcStream, SinkStream* sinkStream);
50
51 public:
52 virtual void Read () override;
53 virtual bool QuickLookAppearsToBeRightFormat () override;
54
55 protected:
56 nonvirtual void Read_Version4 (const char* cookie);
57 nonvirtual void Read_Version5 (const char* cookie); // Led 2.1 file format
58 nonvirtual void Read_Version6 (const char* cookie); // Introduced for Led 2.2a2
59
60#if qStroika_Frameworks_Led_SupportGDI
61 // handles default ones Led knows about. You must override to handle your own private types..
62 protected:
63 virtual SimpleEmbeddedObjectStyleMarker* InternalizeEmbedding (Led_PrivateEmbeddingTag tag, size_t howManyBytes);
64#endif
65 };
66
67 /*
68 @CLASS: StyledTextIOWriter_LedNativeFileFormat
69 @BASES: @'StyledTextIOWriter'
70 @DESCRIPTION:
71 */
72 class StyledTextIOWriter_LedNativeFileFormat : public StyledTextIOWriter {
73 public:
74 StyledTextIOWriter_LedNativeFileFormat (SrcStream* srcStream, SinkStream* sinkStream);
75
76 public:
77 virtual void Write () override;
78
79 protected:
80 nonvirtual void Write_Version6 (); // Introduced for Led 2.2a2
81
82#if qStroika_Frameworks_Led_SupportGDI
83 // handles default ones Led knows about. You must override to handle your own private types..
84 protected:
85 virtual void ExternalizeEmbedding (SimpleEmbeddedObjectStyleMarker* embedding);
86#endif
87 };
88
89 /*
90 ********************************************************************************
91 ***************************** Implementation Details ***************************
92 ********************************************************************************
93 */
94
95}
96
97#endif /*_Stroika_Frameworks_Led_StyledTextIO_LedNative_h_*/