improve doc
This commit is contained in:
parent
f73d7d8545
commit
48c00f3ae5
File diff suppressed because one or more lines are too long
|
@ -27,8 +27,38 @@
|
||||||
*
|
*
|
||||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* root namespace of various Pluie lib
|
||||||
|
*/
|
||||||
namespace Pluie
|
namespace Pluie
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Pluie.Io is dedicated to various input/ouput operations
|
||||||
|
*/
|
||||||
|
namespace Io
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Samples namespace to illustrate or test functionnalities
|
||||||
|
*/
|
||||||
|
namespace Samples
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pluie.Yaml provides various tools to deal with yaml files and yaml nodes :
|
||||||
|
*
|
||||||
|
* Use {@link Yaml.Config} to load a .yml file and build a {@link Yaml.Root} node<<BR>>
|
||||||
|
* Use {@link Yaml.Config.get} to retriew a particular {@link Yaml.Node}<<BR>>
|
||||||
|
* Use {@link Yaml.Builder} to convert a {@link Yaml.Node} into a {@link Yaml.Object}<<BR>>
|
||||||
|
* Use {@link Yaml.Dumper} to dump a {@link Yaml.Object} or {@link Yaml.Node} into a yaml string<<BR>>
|
||||||
|
* Use {@link Yaml.serialize} to serialize a {@link Yaml.Object} or {@link Yaml.Node} into a string<<BR>>
|
||||||
|
* Use {@link Yaml.deserialize} to deserialize a serialized string into a {@link Yaml.Node}<<BR>>
|
||||||
|
* Use {@link Yaml.Collection} and {@link Yaml.AbstractChild} methods for Node traversing
|
||||||
|
*/
|
||||||
namespace Yaml
|
namespace Yaml
|
||||||
{
|
{
|
||||||
protected const string INSTALL_PATH = "@INSTALL_PATH@";
|
protected const string INSTALL_PATH = "@INSTALL_PATH@";
|
||||||
|
|
|
@ -34,10 +34,25 @@ using GLib;
|
||||||
*/
|
*/
|
||||||
class Pluie.Io.InputChunkStream : Object
|
class Pluie.Io.InputChunkStream : Object
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
protected ulong chunk_index;
|
protected ulong chunk_index;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
protected uint8 chunk_size;
|
protected uint8 chunk_size;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
protected uint8 buffer_size;
|
protected uint8 buffer_size;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
protected uint8[] buffer;
|
protected uint8[] buffer;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
protected FileStream fs;
|
protected FileStream fs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* a test class to implements yamlize
|
* a YamlCHild test class
|
||||||
*/
|
*/
|
||||||
public class Pluie.Samples.YamlChild : Yaml.Object
|
public class Pluie.Samples.YamlChild : Yaml.Object
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,7 +32,7 @@ using Gee;
|
||||||
using Pluie;
|
using Pluie;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* a test class to implements yamlize
|
* a YamlObject test class
|
||||||
*/
|
*/
|
||||||
public class Pluie.Samples.YamlObject : Yaml.Object
|
public class Pluie.Samples.YamlObject : Yaml.Object
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* YamlStruct test structure
|
||||||
*/
|
*/
|
||||||
public struct Pluie.Samples.YamlStruct
|
public struct Pluie.Samples.YamlStruct
|
||||||
{
|
{
|
||||||
|
@ -46,7 +46,8 @@ public struct Pluie.Samples.YamlStruct
|
||||||
public uint blue;
|
public uint blue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* get a new YamlStruct populated by specified node
|
||||||
|
* @param node the source Yaml.Node
|
||||||
*/
|
*/
|
||||||
public static YamlStruct from_yaml_node (Yaml.Node node)
|
public static YamlStruct from_yaml_node (Yaml.Node node)
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,7 +28,44 @@
|
||||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Yaml.Config class to manage Yaml configuration files
|
* Yaml.Config class to manage Yaml configuration files and provide a Yaml.Root node.
|
||||||
|
*
|
||||||
|
* Yaml.Config use a Yaml.Finder to easily retriew a particular node. <<BR>>
|
||||||
|
* The Yaml.Config.get method is bind to the Yaml.Finder.find method with <<BR>>
|
||||||
|
* the root node as context. (more details on {@link Yaml.Finder})
|
||||||
|
*
|
||||||
|
* {{{
|
||||||
|
* var config = new Yaml.Config (path);
|
||||||
|
* var node = config.get ("ship-to.address.city{0}");
|
||||||
|
* if (node != null) {
|
||||||
|
* of.echo (node.data)
|
||||||
|
* }
|
||||||
|
* }}}
|
||||||
|
*
|
||||||
|
* You can use a special import clause to embed a set of yaml files into your current document.
|
||||||
|
*
|
||||||
|
* {{{
|
||||||
|
* # | use special key word '^imports' to import other yaml config files in
|
||||||
|
* # | current yaml document
|
||||||
|
* # | '^imports' must be uniq and a direct child of root node
|
||||||
|
* # | imported files are injected as mapping nodes at top document level
|
||||||
|
* # | so you cannot use keys that already exists in the document
|
||||||
|
* ^imports :
|
||||||
|
* # you can redefine default import path with the special key '^path'
|
||||||
|
* # if you do not use it, the default path value will be the current directory
|
||||||
|
* # redefined path values are relative to the current directory (if a relative path
|
||||||
|
* # is provided)
|
||||||
|
* ^path : ./config
|
||||||
|
* # you can also define any other var by prefixing key with ^
|
||||||
|
* ^dir : subdir
|
||||||
|
* # and use it enclosed by ^
|
||||||
|
* # here final test path will be "./config/subdir/test.yml"
|
||||||
|
* test : ^dir^/test.yml
|
||||||
|
* # here final db path will be "./config/db.yml"
|
||||||
|
* db : db.yml
|
||||||
|
* }}}
|
||||||
|
*
|
||||||
|
* {{doc/img/pluie-yaml-imports2.png}}
|
||||||
*/
|
*/
|
||||||
public class Pluie.Yaml.Config
|
public class Pluie.Yaml.Config
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,6 +33,19 @@ using Pluie;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finder class used to easily retriew Yaml.Node
|
* Finder class used to easily retriew Yaml.Node
|
||||||
|
*
|
||||||
|
* Path definition has two mode :
|
||||||
|
* default mode is ''Yaml.FIND_MODE.DOT''
|
||||||
|
*
|
||||||
|
* * child mapping node are separated by dot :
|
||||||
|
* * sequence entry must be enclosed in curly brace
|
||||||
|
* ex : ``grandfather.father.son{2}.age``
|
||||||
|
*
|
||||||
|
* other mode is ''Yaml.FIND_MODE.SQUARE_BRACKETS''.
|
||||||
|
*
|
||||||
|
* * node's key name must be enclosed in square brackets
|
||||||
|
* * sequence entry must be enclosed in curly brace
|
||||||
|
* ex : ``[grandfather][father][son]{2}[age]``
|
||||||
*/
|
*/
|
||||||
public class Pluie.Yaml.Finder : GLib.Object
|
public class Pluie.Yaml.Finder : GLib.Object
|
||||||
{
|
{
|
||||||
|
@ -52,17 +65,7 @@ public class Pluie.Yaml.Finder : GLib.Object
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* find a specific child Yaml.Node corresponding to path definition
|
* Find a specific child Yaml.Node corresponding to path definition.
|
||||||
* path definition has two mode.
|
|
||||||
* default mode is Yaml.FIND_MODE.DOT
|
|
||||||
* - child mapping node are separated by dot :
|
|
||||||
* - sequence entry must be enclosed in curly brace
|
|
||||||
* ex : grandfather.father.son{2}.age
|
|
||||||
*
|
|
||||||
* other mode is Yaml.FIND_MODE.DOTSQUARE_BRACKETS
|
|
||||||
* - node's key name must be enclosed in square brackets
|
|
||||||
* - sequence entry must be enclosed in curly brace
|
|
||||||
* ex : [grandfather][father][son]{2}[age]
|
|
||||||
*
|
*
|
||||||
* @param path the definition to retriew the child node
|
* @param path the definition to retriew the child node
|
||||||
* @param context the Yaml.Node context to operate
|
* @param context the Yaml.Node context to operate
|
||||||
|
|
|
@ -38,7 +38,6 @@ public class Pluie.Yaml.GeeBuilder
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* transform a Gee.Collection with fundamental type to a Yaml.Node
|
* transform a Gee.Collection with fundamental type to a Yaml.Node
|
||||||
* @param Gee.ArrayList* a pointer to the list
|
|
||||||
* @param property_name name of related property
|
* @param property_name name of related property
|
||||||
* @param parent parent Yaml.Node of the list
|
* @param parent parent Yaml.Node of the list
|
||||||
* @param is_char flag indicating data with char representation
|
* @param is_char flag indicating data with char representation
|
||||||
|
|
|
@ -27,419 +27,416 @@
|
||||||
*
|
*
|
||||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
|
||||||
|
|
||||||
namespace Pluie
|
namespace Pluie.Yaml
|
||||||
{
|
{
|
||||||
namespace Yaml
|
const string YAML_VERSION = "1.2";
|
||||||
|
const string YAML_VALA_PREFIX = "v";
|
||||||
|
const string YAML_VALA_DIRECTIVE = "tag:pluie.org,2018:vala/";
|
||||||
|
|
||||||
|
public static bool DEBUG = false;
|
||||||
|
|
||||||
|
public static bool DBG_SHOW_INDENT = true;
|
||||||
|
public static bool DBG_SHOW_PARENT = false;
|
||||||
|
public static bool DBG_SHOW_UUID = true;
|
||||||
|
public static bool DBG_SHOW_LEVEL = false;
|
||||||
|
public static bool DBG_SHOW_REF = false;
|
||||||
|
public static bool DBG_SHOW_COUNT = true;
|
||||||
|
public static bool DBG_SHOW_TAG = true;
|
||||||
|
public static bool DBG_SHOW_TYPE = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
internal static void dbg_action (string msg, string? val = null)
|
||||||
{
|
{
|
||||||
const string YAML_VERSION = "1.2";
|
if (Pluie.Yaml.DEBUG) of.action (msg, val);
|
||||||
const string YAML_VALA_PREFIX = "v";
|
}
|
||||||
const string YAML_VALA_DIRECTIVE = "tag:pluie.org,2018:vala/";
|
|
||||||
|
|
||||||
public static bool DEBUG = false;
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
internal static void dbg_keyval (string key, string val)
|
||||||
|
{
|
||||||
|
if (Pluie.Yaml.DEBUG) of.keyval (key, val);
|
||||||
|
}
|
||||||
|
|
||||||
public static bool DBG_SHOW_INDENT = true;
|
/**
|
||||||
public static bool DBG_SHOW_PARENT = false;
|
*
|
||||||
public static bool DBG_SHOW_UUID = true;
|
*/
|
||||||
public static bool DBG_SHOW_LEVEL = false;
|
internal static void dbg_state (bool done)
|
||||||
public static bool DBG_SHOW_REF = false;
|
{
|
||||||
public static bool DBG_SHOW_COUNT = true;
|
if (Pluie.Yaml.DEBUG) of.state (done);
|
||||||
public static bool DBG_SHOW_TAG = true;
|
}
|
||||||
public static bool DBG_SHOW_TYPE = true;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static void dbg_action (string msg, string? val = null)
|
internal static void dbg (string? msg = null)
|
||||||
{
|
{
|
||||||
if (Pluie.Yaml.DEBUG) of.action (msg, val);
|
if (Pluie.Yaml.DEBUG && msg != null) of.echo (msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* ParseError
|
||||||
*/
|
*/
|
||||||
public static void dbg_keyval (string key, string val)
|
public errordomain AddNodeError
|
||||||
{
|
{
|
||||||
if (Pluie.Yaml.DEBUG) of.keyval (key, val);
|
MAPPING_CONTAINS_CHILD,
|
||||||
}
|
MAPPING_IS_SINGLE_PAIR,
|
||||||
|
MAPPING_NOT_SINGLE_PAIR
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
private const ZlibCompressorFormat ZFORMAT = ZlibCompressorFormat.GZIP;
|
||||||
*
|
|
||||||
*/
|
|
||||||
public static void dbg_state (bool done)
|
|
||||||
{
|
|
||||||
if (Pluie.Yaml.DEBUG) of.state (done);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static void dbg (string? msg = null)
|
private void convert (File source, File dest, Converter converter) throws Error {
|
||||||
{
|
var src_stream = source.read ();
|
||||||
if (Pluie.Yaml.DEBUG && msg != null) of.echo (msg);
|
var dst_stream = dest.replace (null, false, 0);
|
||||||
}
|
var conv_stream = new ConverterOutputStream (dst_stream, converter);
|
||||||
|
// 'splice' pumps all data from an InputStream to an OutputStream
|
||||||
|
conv_stream.splice (src_stream, 0);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ParseError
|
*
|
||||||
*/
|
*/
|
||||||
public errordomain AddNodeError
|
public static uint8[] serialize (GLib.Object? obj, string? dest = null)
|
||||||
{
|
{
|
||||||
MAPPING_CONTAINS_CHILD,
|
Array<uint8> a = new Array<uint8> ();
|
||||||
MAPPING_IS_SINGLE_PAIR,
|
if (obj != null) {
|
||||||
MAPPING_NOT_SINGLE_PAIR
|
var node = obj.get_type ().is_a (typeof (Yaml.Node)) ? obj as Yaml.Node : Yaml.Builder.to_node (obj);
|
||||||
}
|
if (node != null) {
|
||||||
|
var content = node.to_yaml_string ();
|
||||||
private const ZlibCompressorFormat ZFORMAT = ZlibCompressorFormat.GZIP;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private void convert (File source, File dest, Converter converter) throws Error {
|
|
||||||
var src_stream = source.read ();
|
|
||||||
var dst_stream = dest.replace (null, false, 0);
|
|
||||||
var conv_stream = new ConverterOutputStream (dst_stream, converter);
|
|
||||||
// 'splice' pumps all data from an InputStream to an OutputStream
|
|
||||||
conv_stream.splice (src_stream, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public static uint8[] serialize (GLib.Object? obj, string? dest = null)
|
|
||||||
{
|
|
||||||
Array<uint8> a = new Array<uint8> ();
|
|
||||||
if (obj != null) {
|
|
||||||
var node = obj.get_type ().is_a (typeof (Yaml.Node)) ? obj as Yaml.Node : Yaml.Builder.to_node (obj);
|
|
||||||
if (node != null) {
|
|
||||||
var content = node.to_yaml_string ();
|
|
||||||
var date = new GLib.DateTime.now_local ().format ("%s");
|
|
||||||
var path = Path.build_filename (Environment.get_tmp_dir (), "pluie-yaml-%s-%s.source".printf (date, node.uuid));
|
|
||||||
var dpath = dest == null ? path + ".gz" : dest;
|
|
||||||
var writter = new Io.Writter (path);
|
|
||||||
if (writter.write (content.data)) {
|
|
||||||
try {
|
|
||||||
var gzfile = File.new_for_path (dpath);
|
|
||||||
convert (writter.file, gzfile, new ZlibCompressor (ZFORMAT));
|
|
||||||
var reader = new Io.InputChunkStream(dpath, 80);
|
|
||||||
while (!reader.eof ()) {
|
|
||||||
var b = reader.read ();
|
|
||||||
a.append_vals (b, reader.get_buffer_size ());
|
|
||||||
}
|
|
||||||
writter.delete_file ();
|
|
||||||
if (dest == null) {
|
|
||||||
writter.delete_file (gzfile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (GLib.Error e) {
|
|
||||||
of.error (e.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return a.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public static Yaml.Root deserialize (uint8[] zdata)
|
|
||||||
{
|
|
||||||
Yaml.Root? obj = null;
|
|
||||||
if (zdata.length > 0) {
|
|
||||||
var date = new GLib.DateTime.now_local ().format ("%s");
|
var date = new GLib.DateTime.now_local ().format ("%s");
|
||||||
var path = Path.build_filename (Environment.get_tmp_dir (), "pluie-yaml-%s.gz".printf (date));
|
var path = Path.build_filename (Environment.get_tmp_dir (), "pluie-yaml-%s-%s.source".printf (date, node.uuid));
|
||||||
var dpath = Path.build_filename (Environment.get_tmp_dir (), "pluie-yaml-%s.source".printf (date));
|
var dpath = dest == null ? path + ".gz" : dest;
|
||||||
var writter = new Io.Writter (path);
|
var writter = new Io.Writter (path);
|
||||||
if (writter.write (zdata)) {
|
if (writter.write (content.data)) {
|
||||||
var file = File.new_for_path (dpath);
|
|
||||||
try {
|
try {
|
||||||
convert (writter.file, file, new ZlibDecompressor (ZFORMAT));
|
var gzfile = File.new_for_path (dpath);
|
||||||
var config = new Yaml.Config (dpath);
|
convert (writter.file, gzfile, new ZlibCompressor (ZFORMAT));
|
||||||
obj = config.root_node ();
|
var reader = new Io.InputChunkStream(dpath, 80);
|
||||||
|
while (!reader.eof ()) {
|
||||||
|
var b = reader.read ();
|
||||||
|
a.append_vals (b, reader.get_buffer_size ());
|
||||||
|
}
|
||||||
writter.delete_file ();
|
writter.delete_file ();
|
||||||
|
if (dest == null) {
|
||||||
|
writter.delete_file (gzfile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch(GLib.Error e) {
|
catch (GLib.Error e) {
|
||||||
of.error (e.message);
|
of.error (e.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return obj;
|
|
||||||
}
|
}
|
||||||
|
return a.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static Yaml.Root deserialize (uint8[] zdata)
|
||||||
|
{
|
||||||
|
Yaml.Root? obj = null;
|
||||||
|
if (zdata.length > 0) {
|
||||||
|
var date = new GLib.DateTime.now_local ().format ("%s");
|
||||||
|
var path = Path.build_filename (Environment.get_tmp_dir (), "pluie-yaml-%s.gz".printf (date));
|
||||||
|
var dpath = Path.build_filename (Environment.get_tmp_dir (), "pluie-yaml-%s.source".printf (date));
|
||||||
|
var writter = new Io.Writter (path);
|
||||||
|
if (writter.write (zdata)) {
|
||||||
|
var file = File.new_for_path (dpath);
|
||||||
|
try {
|
||||||
|
convert (writter.file, file, new ZlibDecompressor (ZFORMAT));
|
||||||
|
var config = new Yaml.Config (dpath);
|
||||||
|
obj = config.root_node ();
|
||||||
|
writter.delete_file ();
|
||||||
|
}
|
||||||
|
catch(GLib.Error e) {
|
||||||
|
of.error (e.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* haxadecimal sequence
|
||||||
|
*/
|
||||||
|
const string hexa_sequence = "0123456789abcdef";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* convert %02x string to uint8
|
||||||
|
* @param hex2byte string representation of hexadecimal value on 1 byte
|
||||||
|
*/
|
||||||
|
uint8 hex_to_dec (string hexbyte)
|
||||||
|
{
|
||||||
|
return (uint8) (
|
||||||
|
Yaml.hexa_sequence.index_of(hexbyte.data[0].to_string ())*16 +
|
||||||
|
Yaml.hexa_sequence.index_of(hexbyte.data[1].to_string ())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* enum MatchInfo keys of Yaml.Mode.find method related to mode FIND_MODE.SQUARE_BRACKETS of Yaml.Node
|
||||||
|
*/
|
||||||
|
public enum EVT {
|
||||||
|
NONE,
|
||||||
|
STREAM_START,
|
||||||
|
STREAM_END,
|
||||||
|
VERSION_DIRECTIVE,
|
||||||
|
TAG_DIRECTIVE,
|
||||||
|
DOCUMENT_START,
|
||||||
|
DOCUMENT_END,
|
||||||
|
BLOCK_SEQUENCE_START,
|
||||||
|
BLOCK_MAPPING_START,
|
||||||
|
BLOCK_END,
|
||||||
|
FLOW_SEQUENCE_START,
|
||||||
|
FLOW_SEQUENCE_END,
|
||||||
|
FLOW_MAPPING_START,
|
||||||
|
FLOW_MAPPING_END,
|
||||||
|
BLOCK_ENTRY,
|
||||||
|
FLOW_ENTRY,
|
||||||
|
KEY,
|
||||||
|
VALUE,
|
||||||
|
ALIAS,
|
||||||
|
ANCHOR,
|
||||||
|
TAG,
|
||||||
|
SCALAR;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* haxadecimal sequence
|
* @return infos related to EVT
|
||||||
*/
|
*/
|
||||||
const string hexa_sequence = "0123456789abcdef";
|
public string infos ()
|
||||||
|
|
||||||
/**
|
|
||||||
* convert %02x string to uint8
|
|
||||||
* @param hex2byte string representation of hexadecimal value on 1 byte
|
|
||||||
*/
|
|
||||||
uint8 hex_to_dec (string hexbyte)
|
|
||||||
{
|
{
|
||||||
return (uint8) (
|
return this.to_string().substring("PLUIE_YAML_".length);
|
||||||
Yaml.hexa_sequence.index_of(hexbyte.data[0].to_string ())*16 +
|
|
||||||
Yaml.hexa_sequence.index_of(hexbyte.data[1].to_string ())
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* enum MatchInfo keys of Yaml.Mode.find method related to mode FIND_MODE.SQUARE_BRACKETS of Yaml.Node
|
* @return event is key
|
||||||
*/
|
*/
|
||||||
public enum EVT {
|
public bool is_key ()
|
||||||
NONE,
|
|
||||||
STREAM_START,
|
|
||||||
STREAM_END,
|
|
||||||
VERSION_DIRECTIVE,
|
|
||||||
TAG_DIRECTIVE,
|
|
||||||
DOCUMENT_START,
|
|
||||||
DOCUMENT_END,
|
|
||||||
BLOCK_SEQUENCE_START,
|
|
||||||
BLOCK_MAPPING_START,
|
|
||||||
BLOCK_END,
|
|
||||||
FLOW_SEQUENCE_START,
|
|
||||||
FLOW_SEQUENCE_END,
|
|
||||||
FLOW_MAPPING_START,
|
|
||||||
FLOW_MAPPING_END,
|
|
||||||
BLOCK_ENTRY,
|
|
||||||
FLOW_ENTRY,
|
|
||||||
KEY,
|
|
||||||
VALUE,
|
|
||||||
ALIAS,
|
|
||||||
ANCHOR,
|
|
||||||
TAG,
|
|
||||||
SCALAR;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return infos related to EVT
|
|
||||||
*/
|
|
||||||
public string infos ()
|
|
||||||
{
|
|
||||||
return this.to_string().substring("PLUIE_YAML_".length);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return event is key
|
|
||||||
*/
|
|
||||||
public bool is_key ()
|
|
||||||
{
|
|
||||||
return this == EVT.KEY;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return event is anchor
|
|
||||||
*/
|
|
||||||
public bool is_anchor ()
|
|
||||||
{
|
|
||||||
return this == EVT.ANCHOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return event is alias
|
|
||||||
*/
|
|
||||||
public bool is_alias ()
|
|
||||||
{
|
|
||||||
return this == EVT.ALIAS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return event is tag
|
|
||||||
*/
|
|
||||||
public bool is_tag ()
|
|
||||||
{
|
|
||||||
return this == EVT.TAG;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return event is tag
|
|
||||||
*/
|
|
||||||
public bool is_tag_directive ()
|
|
||||||
{
|
|
||||||
return this == EVT.TAG_DIRECTIVE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return event is key
|
|
||||||
*/
|
|
||||||
public bool is_value ()
|
|
||||||
{
|
|
||||||
return this == EVT.VALUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return event is scalar
|
|
||||||
*/
|
|
||||||
public bool is_scalar ()
|
|
||||||
{
|
|
||||||
return this == EVT.SCALAR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return event is mapping start event
|
|
||||||
*/
|
|
||||||
public bool is_mapping_start ()
|
|
||||||
{
|
|
||||||
return this == EVT.BLOCK_MAPPING_START || this == EVT.FLOW_MAPPING_START;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return event is sequence start event
|
|
||||||
*/
|
|
||||||
public bool is_sequence_start ()
|
|
||||||
{
|
|
||||||
return this == EVT.BLOCK_SEQUENCE_START || this == EVT.FLOW_SEQUENCE_START;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return event is sequence end event
|
|
||||||
*/
|
|
||||||
public bool is_sequence_end ()
|
|
||||||
{
|
|
||||||
return this == EVT.BLOCK_END || this == EVT.FLOW_SEQUENCE_END;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return event is sequence entry event
|
|
||||||
*/
|
|
||||||
public bool is_entry ()
|
|
||||||
{
|
|
||||||
return this == EVT.BLOCK_ENTRY || this == EVT.FLOW_ENTRY;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return event is mapping end event
|
|
||||||
*/
|
|
||||||
public bool is_mapping_end ()
|
|
||||||
{
|
|
||||||
return this == EVT.BLOCK_END;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return event is error event
|
|
||||||
*/
|
|
||||||
public bool is_error ()
|
|
||||||
{
|
|
||||||
return this == EVT.NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* enum possible find mode of Yaml.Node.mode
|
|
||||||
*/
|
|
||||||
public enum FIND_MODE
|
|
||||||
{
|
{
|
||||||
DOT,
|
return this == EVT.KEY;
|
||||||
SQUARE_BRACKETS;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public bool is_dot ()
|
|
||||||
{
|
|
||||||
return this == DOT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FIND_MODE MODE = FIND_MODE.DOT;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* enum MatchInfo keys of Yaml.Mode.find method related to mode FIND_MODE.SQUARE_BRACKETS of Yaml.Node
|
|
||||||
*/
|
|
||||||
internal enum FIND_COLLECTION { PATH, OPEN, KEY, CLOSE; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* enum MatchInfo keys of Yaml.Node.find method related to mode FIND_MODE.DOT of Yaml.Node
|
|
||||||
*/
|
|
||||||
internal enum FIND_DOT { PATH, KEY, SEQUENCE; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* enum possible type of Yaml.Node
|
|
||||||
*/
|
|
||||||
public enum NODE_TYPE
|
|
||||||
{
|
|
||||||
UNDEFINED,
|
|
||||||
ROOT,
|
|
||||||
SCALAR,
|
|
||||||
SINGLE_PAIR,
|
|
||||||
MAPPING,
|
|
||||||
SEQUENCE;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return if current NODE_TYPE match a collection node (root|mapping|sequence)
|
|
||||||
*/
|
|
||||||
public bool is_collection ()
|
|
||||||
{
|
|
||||||
return this == MAPPING || this == SEQUENCE || this == ROOT;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return if current NODE_TYPE match a scalar node
|
|
||||||
*/
|
|
||||||
public bool is_scalar ()
|
|
||||||
{
|
|
||||||
return this == SCALAR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return if current NODE_TYPE match a single/pair mapping node
|
|
||||||
*/
|
|
||||||
public bool is_single_pair ()
|
|
||||||
{
|
|
||||||
return this == SINGLE_PAIR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return if current NODE_TYPE match a mapping node
|
|
||||||
*/
|
|
||||||
public bool is_mapping ()
|
|
||||||
{
|
|
||||||
return this == MAPPING;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return if current NODE_TYPE match a sequence node
|
|
||||||
*/
|
|
||||||
public bool is_sequence ()
|
|
||||||
{
|
|
||||||
return this == SEQUENCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return if current NODE_TYPE match a root node
|
|
||||||
*/
|
|
||||||
public bool is_root ()
|
|
||||||
{
|
|
||||||
return this == ROOT;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*@return infos related to NODE_TYPE
|
|
||||||
*/
|
|
||||||
public string infos ()
|
|
||||||
{
|
|
||||||
return this.to_string().substring("PLUIE_YAML_NODE_TYPE_".length);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*@return universal infos related to NODE_TYPE
|
* @return event is anchor
|
||||||
*/
|
*/
|
||||||
public string uuid ()
|
public bool is_anchor ()
|
||||||
{
|
{
|
||||||
var sb = new StringBuilder();
|
return this == EVT.ANCHOR;
|
||||||
for (var i = 0; i < 4; i++) sb.append (Random.next_int ().to_string ("%08x"));
|
}
|
||||||
var h = sb.str;
|
|
||||||
var d = Yaml.hex_to_dec (h.substring (16, 2));
|
/**
|
||||||
d &= 0x3f;
|
* @return event is alias
|
||||||
d |= 0x80;
|
*/
|
||||||
return "%s-%s-4%s-%02x%s-%s".printf (
|
public bool is_alias ()
|
||||||
h.substring (0, 8),
|
{
|
||||||
h.substring (8, 4),
|
return this == EVT.ALIAS;
|
||||||
h.substring (13, 3),
|
}
|
||||||
d,
|
|
||||||
h.substring (18, 2),
|
/**
|
||||||
h.substring (20)
|
* @return event is tag
|
||||||
);
|
*/
|
||||||
|
public bool is_tag ()
|
||||||
|
{
|
||||||
|
return this == EVT.TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return event is tag
|
||||||
|
*/
|
||||||
|
public bool is_tag_directive ()
|
||||||
|
{
|
||||||
|
return this == EVT.TAG_DIRECTIVE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return event is key
|
||||||
|
*/
|
||||||
|
public bool is_value ()
|
||||||
|
{
|
||||||
|
return this == EVT.VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return event is scalar
|
||||||
|
*/
|
||||||
|
public bool is_scalar ()
|
||||||
|
{
|
||||||
|
return this == EVT.SCALAR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return event is mapping start event
|
||||||
|
*/
|
||||||
|
public bool is_mapping_start ()
|
||||||
|
{
|
||||||
|
return this == EVT.BLOCK_MAPPING_START || this == EVT.FLOW_MAPPING_START;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return event is sequence start event
|
||||||
|
*/
|
||||||
|
public bool is_sequence_start ()
|
||||||
|
{
|
||||||
|
return this == EVT.BLOCK_SEQUENCE_START || this == EVT.FLOW_SEQUENCE_START;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return event is sequence end event
|
||||||
|
*/
|
||||||
|
public bool is_sequence_end ()
|
||||||
|
{
|
||||||
|
return this == EVT.BLOCK_END || this == EVT.FLOW_SEQUENCE_END;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return event is sequence entry event
|
||||||
|
*/
|
||||||
|
public bool is_entry ()
|
||||||
|
{
|
||||||
|
return this == EVT.BLOCK_ENTRY || this == EVT.FLOW_ENTRY;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return event is mapping end event
|
||||||
|
*/
|
||||||
|
public bool is_mapping_end ()
|
||||||
|
{
|
||||||
|
return this == EVT.BLOCK_END;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return event is error event
|
||||||
|
*/
|
||||||
|
public bool is_error ()
|
||||||
|
{
|
||||||
|
return this == EVT.NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* enum possible find mode of Yaml.Node.mode
|
||||||
|
*/
|
||||||
|
public enum FIND_MODE
|
||||||
|
{
|
||||||
|
DOT,
|
||||||
|
SQUARE_BRACKETS;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public bool is_dot ()
|
||||||
|
{
|
||||||
|
return this == DOT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static FIND_MODE MODE = FIND_MODE.DOT;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* enum MatchInfo keys of Yaml.Mode.find method related to mode FIND_MODE.SQUARE_BRACKETS of Yaml.Node
|
||||||
|
*/
|
||||||
|
internal enum FIND_COLLECTION { PATH, OPEN, KEY, CLOSE; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* enum MatchInfo keys of Yaml.Node.find method related to mode FIND_MODE.DOT of Yaml.Node
|
||||||
|
*/
|
||||||
|
internal enum FIND_DOT { PATH, KEY, SEQUENCE; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* enum possible type of Yaml.Node
|
||||||
|
*/
|
||||||
|
public enum NODE_TYPE
|
||||||
|
{
|
||||||
|
UNDEFINED,
|
||||||
|
ROOT,
|
||||||
|
SCALAR,
|
||||||
|
SINGLE_PAIR,
|
||||||
|
MAPPING,
|
||||||
|
SEQUENCE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return if current NODE_TYPE match a collection node (root|mapping|sequence)
|
||||||
|
*/
|
||||||
|
public bool is_collection ()
|
||||||
|
{
|
||||||
|
return this == MAPPING || this == SEQUENCE || this == ROOT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return if current NODE_TYPE match a scalar node
|
||||||
|
*/
|
||||||
|
public bool is_scalar ()
|
||||||
|
{
|
||||||
|
return this == SCALAR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return if current NODE_TYPE match a single/pair mapping node
|
||||||
|
*/
|
||||||
|
public bool is_single_pair ()
|
||||||
|
{
|
||||||
|
return this == SINGLE_PAIR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return if current NODE_TYPE match a mapping node
|
||||||
|
*/
|
||||||
|
public bool is_mapping ()
|
||||||
|
{
|
||||||
|
return this == MAPPING;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return if current NODE_TYPE match a sequence node
|
||||||
|
*/
|
||||||
|
public bool is_sequence ()
|
||||||
|
{
|
||||||
|
return this == SEQUENCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return if current NODE_TYPE match a root node
|
||||||
|
*/
|
||||||
|
public bool is_root ()
|
||||||
|
{
|
||||||
|
return this == ROOT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*@return infos related to NODE_TYPE
|
||||||
|
*/
|
||||||
|
public string infos ()
|
||||||
|
{
|
||||||
|
return this.to_string().substring("PLUIE_YAML_NODE_TYPE_".length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*@return universal infos related to NODE_TYPE
|
||||||
|
*/
|
||||||
|
public string uuid ()
|
||||||
|
{
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
for (var i = 0; i < 4; i++) sb.append (Random.next_int ().to_string ("%08x"));
|
||||||
|
var h = sb.str;
|
||||||
|
var d = Yaml.hex_to_dec (h.substring (16, 2));
|
||||||
|
d &= 0x3f;
|
||||||
|
d |= 0x80;
|
||||||
|
return "%s-%s-4%s-%02x%s-%s".printf (
|
||||||
|
h.substring (0, 8),
|
||||||
|
h.substring (8, 4),
|
||||||
|
h.substring (13, 3),
|
||||||
|
d,
|
||||||
|
h.substring (18, 2),
|
||||||
|
h.substring (20)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,11 +31,11 @@
|
||||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
lib="pluie-yaml-0.5"
|
lib="pluie-yaml-0.5"
|
||||||
cd $DIR
|
cd $DIR
|
||||||
valadoc --package-name=$lib --verbose --force --deps -o ./doc --pkg gee-0.8 --pkg gio-2.0 --pkg gobject-2.0 --pkg gmodule-2.0 --pkg glib-2.0 --pkg pluie-echo-0.2 ./src/vala/Pluie/*.vala ./build/install.vala
|
valadoc --package-name=$lib --verbose --force --deps -o ./doc --pkg gee-0.8 --pkg gio-2.0 --pkg gobject-2.0 --pkg gmodule-2.0 --pkg glib-2.0 --pkg pluie-echo-0.2 ./src/vala/Pluie/*.vala ./src/install.vala
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
rm doc/*.png
|
rm doc/*.png
|
||||||
cp resources/doc-scripts.js ./doc/scripts.js
|
cp resources/doc-scripts.js ./doc/scripts.js
|
||||||
cp resources/doc-style.css ./doc/style.css
|
cp resources/doc-style.css ./doc/style.css
|
||||||
rm $lib.tar.gz
|
#~ rm $lib.tar.gz
|
||||||
tar -czvf $lib.tar.gz doc/
|
#~ tar -czvf $lib.tar.gz doc/
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue
Block a user