The Text package comes from the separate ParserText project. It is not YAML-specific, but has been written to support AdaYaml. The goals of the Text package are:

To be able to implement this, Text uses quite some pretty low-level techniques like writing a custom dope vector in front of each String’s content. The resulting code is pretty compiler-specific and most probably will only work with GNAT for the forseeable future (even if other compilers start to support Ada 2012).

Using Text.Reference

To query the value of a Text.Reference, use the Value function which returns an Accessor that implicitly dereferences to an UTF_8_String access. The value is not modifyable. The initial value of a Text.Reference is the empty string; you can always safely call Value since the underlying pointer may never be null.

Creating a Text.Reference

If you want to create own Text.Reference values, you need a Text.Pool.Reference. The underlying object needs a lot of memory, so the reference is not initialized by default; you need to call Create on it once. A pool lives on until the last Text.Reference created by it and all Text.Pool.Reference objects vanish. If you are using a Yaml.Parser.Instance, you can query its pool with the Pool function to avoid using two pools.

If you want to create a Text.Reference by subsequently appending content, use Text.Builder.Reference.

Providing Text.Reference Constants

If you want to have package-level constants of Text.Reference, instead of allocating them in a pool, create a Constant_Instance object with the function Hold and then generate a reference from it with the function Held. Example:

with Text;

package My_Package is
   My_Constant : constant Text.Reference;
   My_Constant_Holder : constant Text.Constant_Instance := Text.Hold ("value");
   My_Constant : constant Text.Reference := Text.Held (My_Constant_Holder);
end My_Package;