[yunqa.de] Re: DIunicode Qs

  • From: Delphi Inspiration <delphi@xxxxxxxx>
  • To: yunqa@xxxxxxxxxxxxx
  • Date: Wed, 15 Feb 2012 22:53:06 +0100

On 15.02.2012 21:28, Jon Burnham wrote:

> 1)    The examples run, but there are no components in the palette – is
> this correct?

DIUnicode does not have IDE design-time components. Adjust your search
path and add the necessary units to your uses clause and you're all set.

> 2)    I have decided to use it to parse a series of API’s data. These
> return with CSV, Json and XML. I decided it would be easier to
> de-serialise the response manually as they are comparatively small
> amounts of repeating data. They are very repetitive and essentially rely
> on columns and rows. So I need to be able to count characters and look
> for strings. So rather than plough through the very large help file full
> of stuff I may not need., I need to just work with the find and navigate
> commands. Is there a way of just suggesting a set of commands to look at
> for this list.

For CSV, look at the DIUnicode\Demos\DIUnicode_CSV_Parser demo.

For XML, my DIXml, DITidy or DIHtmlParser libraries may be more targeted
solutions:

* http://yunqa.de/delphi/doku.php/products/xml/index
* http://yunqa.de/delphi/doku.php/products/tidy/index
* http://yunqa.de/delphi/doku.php/products/htmlparser/index

> a)    Optimum way of loading a pre-ordained string (the response)

The TDIUnicodeReader.SetSource... methods.

> b)    Count strings

TDIUnicodeReader does not handle strings, it handles Unicode characters.
The concept is to read a series of single chars with
TDIUnicodeReader.ReadChar, inspect them with TDIUnicodeReader.Char and
for each char, decide what to do next.

> c)     Find a string

Same thing.

> d)    Move to character

The TDIUnicodeReader.Skip... methods.

> e)    Mark a position

Reading is forward only for performance. TDIUnicodeReader.PeekChars
allows virtually unlimited look-ahead.

TDIUnicodeReader.CharCol and TDIUnicodeReader.CharLine track the
reader's position in the source.

> f)     Move to begin/end of data string based on legal characters

See above.

> g)    Extract data

The TDIUnicodeReader.Read... methods combined with the
TDIUnicodeReader.Data... methods and properties. I also use
TDIUnicodeReader.AddCharReadChar a lot.

> An example of what I am dealing with follows:

The character-based concept might feel a little odd at first, but takes
little time only to get used to. Then you will automatically benefit
from these features:

* No limits on input length.
* On the fly character decoding and encoding.
* Very fast parsing.
* Built in, reusable data buffer for simple and efficient data extraction.

To get a feel of TDIUnicodeReader in practice, I suggest a look at the
demos, in particular for your needs:

* DIUnicode\Demos\DIUnicode_Extract_Words
* DIUnicode\Demos\DIUnicode_CSV_Parser

The DICsvParser.pas unit contains the TDICsvParser class used in the demo.

Ralf
_______________________________________________
Delphi Inspiration mailing list
yunqa@xxxxxxxxxxxxx
//www.freelists.org/list/yunqa



Other related posts: