Category Archives: Delphi library

OXml left beta

Yesterday, I finally released OXml 1.0, the first version in production state and OXml definitely left beta. What changed for you as an OXml user?

The most important change is the license. OXml is now licensed under CPAL 1.0. It is an open-source license with a strong attribution clause. It forces you to display the Original Developer’s Attribution Information each time an executable is launched. As an alternative, you may buy a commercial license which doesn’t require any attribution at all.

I prepared a PLUS package with extra units: two XML serializer/deserializers, one based on TypInfo (for Delphi 6+ and Lazarus) and one based on enhanced RTTI (for Delphi 2010+). I also plan writing a dataset-to-XML component. This package will be available only for customers who bought OXml.

What led me to the decision to change the license was first the fact that there are a lot of free XML libraries but I believe that OXml is special and those who really need OXml should also be willing to pay a reasonable amount for it. As a result I’ll be motivated to keep updating and enhancing OXml. Those who don’t want to pay for OXml can use one of its beta versions licensed under MPL, be pirates and ignore the new license or switch to other XML libraries.

Second it’s Embarcadero’s own update policy. I have to pay anually for Delphi license as well so a small fee for OXml helps me keep OXml updated in future Delphi versions as well.

OXml homepage:

Ansi- and RawByteString for Delphi mobile

Do you want to use 8-bit strings on mobile platforms with all the nice old-fashioned features?

ORawByteString has been designed to make old code easily portable to mobile platforms – you only have to rename functions like “Copy” to “AnsiCopy”, that’s all.
With ORawByteString you can write code like this:

procedure TestAnsiString(const aOutputLines: TStrings);
  Raw: RawByteString;
  Wide: string;
  I: Integer;
  C: PAnsiChar;
  Raw := RawByteString('HEADET');
  Raw[AnsiLength(Raw)] := AnsiChar('R');//Raw = HEADER
  Wide := UTF8ToString(Raw);//convert "HEADER" from UTF-8 (ASCII) to UTF-16

  aOutputLines.Add(Wide);//output "HEADER"

  Raw := RawByteString(Wide);//CONVERT UTF-16 back into ASCII (without any codepage)
  I := Pos('H', Raw);//Fast search in RawByteString
  Raw := AnsiCopy(Raw, I, 3);//Use fast copy on RawByteString -> Raw = "HEA"
  Wide := String(Raw);//CONVERT ASCII to UTF-16 (without any codepage)

  C := PAnsiChar(Raw);//YOU CAN EVEN USE PAnsiChar!!!
  Raw := RawByteString(C);//AND convert PAnsiChar back to RawByteString/AnsiString

  C := PAnsiChar(Raw);
  aOutputLines.Add(String(C[2]));//output "A" (the third letter from C (PAnsiChar is always 0-based)

  AnsiDelete(Raw, 1, 1);//Fast delete in RawByteString -> Raw = "EA"
  AnsiInsert(RawByteString('x'), Raw, 2);//Fast insert -> Raw = "ExA"
  Raw := UpperCase(Raw);//Fast uppercase -> Raw = "EXA"
  aOutputLines.Add(String(Raw));//output "EXA"
  Raw := LowerCase(Raw);//Fast uppercase -> Raw = "exa"
  aOutputLines.Add(String(Raw));//output "exa"

ORawByteString.pas allows you to:

  1. use 8-bit AnsiString and RawByteString on mobile platforms.
  2. use 8-bit PAnsiChar on mobile platforms.
  3. use 8-bit AnsiChar on mobile platforms.
  4. use the same AnsiString code on desktop and mobile.
  5. -> no IDE hacking is needed :)

It features it’s own text functions like AnsiInsert(), AnsiCopy(), AnsiDelete(), AnsiLength(), Pos(), LowerCase() etc. to offer maximum performance.

And when we talk about performance: ORawByteString is in some scenarios a little bit slower than string on mobile platforms, but most of the test cases and an usual usage showed no significant performance drawbacks. String operations perform on ORawByteString as fast as on string.

ORawByteString features full copy-on-write, mutability and all string features you have always taken advantage of.

On the one hand ORawByteString is a technical exhibition on how you can use records with operators to create your own delphi type, but on the other hand it can also be useful since it’s not certain that 8-bit strings will be officially available on mobile platforms at some point.

License: MPL 1.1