EmbeddingSinkStream
StyledTextIOReader
StyledTextIOReader::BadInputHandler
StyledTextIOReader::SinkStream
StyledTextIOReader::SrcStream
StyledTextIOSrcStream_FileDescriptor
StyledTextIOSrcStream_Memory
StyledTextIOWriter
StyledTextIOWriter::SinkStream
StyledTextIOWriter::SrcStream
StyledTextIOWriterSinkStream_FileDescriptor
StyledTextIOWriterSinkStream_Memory
A portable attempt at abstracting away the details of styled text file IO and all the different formats for styled text.
This code defines APIs which should allow for reading any different styled text format. And dumping it to any different output (eg. text buffer).
The only real LED-SPECIFIC parts of this are that I only provide concrete output (aka sinks) implementations to Led StandardStyledTextImagers. And that some of the Src/Sink APIs are oriented towards what would be helpful for a Led-based editor (in other words, features not supported by Led aren't communicated to/from the src/sinks).
The big picture for this module is that there are two main basic subdivisions. There are
StyledTextIOReader
subclasses, and StyledTextIOWriter
subclasses. The readers are for READING some file format,
and converting it to a stream of method calls (on a sink to be described later). And writers are for writing those
formatted data files, based on results of method calls on an abstract source class.
Though StyledTextIOReader
and StyledTextIOWriter
share no common base class, they do follow
a very similar design pattern. They both define abstract 'sources' and 'sinks' for their operation.
For a StyledTextIOReader
, it reads its data from a StyledTextIOReader::SrcStream
(typically maybe a file),
and writes it to a StyledTextIOReader::SinkStream
(typically a Led-text-buffer/view).
A StyledTextIOWriter
, writes data extracted from a StyledTextIOWriter::SrcStream
(typically view/textstore, much like a StyledTextIOReader::SinkStream
),
and writes it to a StyledTextIOWriter::SinkStream
(typically an output file).
These abstract sources and sinks are defined to just the minimal pure virtual APIs needed to extract/write bare bytes, or formatted text in a format Led can understand. Several concrete instantiations of each are provided by Led (some here, and some in other modules, as appropriate).
Subclasses of StyledTextIOReader
and StyledTextIOWriter
are where the knowledge of particular file formats resides.
For example, the knowledge of how to read RTF is in StyledTextIOReader_RTF
and the knowledge of how to write HTML is in
StyledTextIOWriter_HTML
.
EmbeddingSinkStream [public]
SimpleEmbeddedObjectStyleMarker::SinkStream
StyledTextIOReader [public]
Abstract base class for styled text reading. Subclasses know about various styled text file formats, and take care of the details of mapping streams of bytes into Led internal data structures with that styled text.
Member Details |
---|
Each reader class has associated with it an error handler - of type See also |
This routine is called whenever this is badly formatted input text to the reader.
This is a simple wrapper on the owned |
Unread the last read character. Note - this can be done as many times as you want (allowing infinite unread) but it is a bug/error if you ever unread characters that handn't been read in the first place |
|
StyledTextIOReader::BadInputHandler [public]
Abstract base class for styled text writing. Subclasses know about various styled text file formats, and take care of the details of mapping Led internal data structures with styled text into streams of bytes in that format.
Member Details |
---|
This routine is called whenever this is badly formatted input text to the reader. By default - this routine does nothing (unless the unrecoverable argument is 'true'). This is a change of behavior from Led 2.3. In Led 2.3 - format errors would always throw
by calling |
StyledTextIOReader::SinkStream [public]
A StyledTextIOReader needs a pointer to a function which is a sink for all the styled text and other information read. SinkStream is an abstract class defining this API.
Member Details |
---|
|
|
Append the given text to the output text buffer. If fontSpec is NULL, use default.
Probably later we will return and update the fontspec with |
Apply the given style information to the given range of text. See |
Called by StyledText IO readers when end of source buffer is encountered. This means that the next Flush () call contains the last of the text. |
|
|
|
|
|
|
|
|
Return the current seekPos |
StyledTextIOReader::SrcStream [public]
A StyledTextIOReader needs a pointer to a function which is a source of raw bytes to be interpretted as text which will be inserted into a text buffer. SrcStream is an abstract class defining this API.
Member Details |
---|
MacOS Only. Returns the Mac handle to the resource fork, if any (used to read 'styl' resources). |
Return the current seekPos |
Read the given number of bytes from the is source, and fill them into the buffer. Returns the number of bytes read. |
Sets the current read-pointer to the given position (often used to scan backwards, but can be any direction). Note if 'to' is past end, this just pins one past end of buffer. |
StyledTextIOSrcStream_FileDescriptor [public]
StyledTextIOReader::SrcStream
If you have a file which contains the untyped contents which will be converted by some
reader (StyledTextIOReader
), you use this as the StyledTextIOReader::SrcStream
. Just initialize one of these
with the open file descriptor, and pass this to the appropriate StyledTextIOReader
.
NB: This class doesn't close the argument file descriptor. It is up the the caller todo that, and only after this SrcStream object has been destroyed. Typically, this follows trivially from a sequential, stack-based allocation strategy, where the data comes from some object declared earlier on the stack.
StyledTextIOSrcStream_Memory [public]
StyledTextIOReader::SrcStream
If you have a block of memory which contains the untyped contents which will be converted by some
reader (StyledTextIOReader
), you use this as the StyledTextIOReader::SrcStream
. Just initialize one of these
with the appropriate data, and pass this to the appropriate StyledTextIOReader
.
NB: This class doesn't free up, or copy the given pointer. It is up the the caller todo that, and only after this SrcStream object has been destroyed. Typically, this follows trivially from a sequential, stack-based allocation strategy, where the data comes from some object declared earlier on the stack.
StyledTextIOWriter [public]
Abstract base class for styled text writing. Subclasses know about various styled text file formats, and take care of the details of mapping Led internal data structures with styled text into streams of bytes in that format.
StyledTextIOWriter::SinkStream [public]
Abstract base class for StyledTextIOWriter
s to dump their text content to.
Member Details |
---|
Return the current seekPos. |
'to' past end just pins one past end of buffer |
|
StyledTextIOWriter::SrcStream [public]
Abstract base class for StyledTextIOWriter
s to get their text content from.
Member Details |
---|
|
Since we maybe externalizing a subset of the buffer, and the marker positions in the embedding object are absolute, we need to know this to relativize them in the externalized stream |
|
|
|
|
|
|
Returns the special character which should be treated (in RTF output) as the SOFT-RETURN line break character (in RTF \line). |
|
|
|
|
Total # of tChars |
current seekPos |
readNTChars can retun less than maxTChars before end of buffer, only to make us end on even mbyte char boundary. |
'to' past end just pins one past end of buffer |
StyledTextIOWriterSinkStream_FileDescriptor [public]
StyledTextIOWriter::SinkStream
StyledTextIOWriterSinkStream_Memory [public]
StyledTextIOWriter::SinkStream