Compare commits

..

16 Commits
0.53 ... master

Author SHA1 Message Date
a-sansara
3794af72b2 add minimal Gee.HashMap support 2018-09-06 18:46:44 +02:00
a-Sansara
626e88b37f update readme amend valadoc 2018-09-05 03:02:32 +02:00
a-Sansara
6d58329670 version 0.60 2018-09-05 02:33:21 +02:00
a-Sansara
83e6aa5729 fix processor 2018-09-05 02:07:59 +02:00
a-Sansara
c019ff1749 update gitignore, hide local mess 2018-09-05 02:06:58 +02:00
a-Sansara
3f8c77ebd7 fix & automated valadoc deployment 2018-09-05 02:06:06 +02:00
a-Sansara
3b915dcc92 add LOCAL build option 2018-09-05 02:04:22 +02:00
a-sansara
36f7cdcc6f fix processor 2018-09-04 18:47:16 +02:00
a-sansara
1ef7559309 fix error on Processor for nested mapping entries 2018-08-31 18:14:20 +02:00
a-sansara
48c00f3ae5 improve doc 2018-08-29 18:42:10 +02:00
a-sansara
f73d7d8545 amend readme 2018-08-29 16:59:06 +02:00
a-sansara
c840747e18 version 0.55 2018-08-29 16:37:11 +02:00
a-sansara
2acc2930ce extract samples classes from lib 2018-08-29 16:27:04 +02:00
a-sansara
487a5cd107 use berel to write files header 2018-08-28 14:57:04 +02:00
a-Sansara
ca6a46421d fix error loading bad file 2018-08-28 01:58:14 +02:00
a-Sansara
efe4a48d8f fix lines count in yaml_root 2018-08-24 21:03:56 +02:00
57 changed files with 2396 additions and 1507 deletions

74
.berel.yml Normal file
View File

@ -0,0 +1,74 @@
%YAML 1.2
%TAG !v! tag:pluie.org,2018:vala/
---
!v!Pluie.Berel.Meta meta :
keys :
software : pluie-yaml; <https://git.pluie.org/pluie/lib-yaml>
version : 0.60
type : library
date : 2018
license : GPLv3.0; <http://www.gnu.org/licenses/>
author : a-Sansara; <[dev]at[pluie]dot[org]>
copyright : pluie.org; <http://www.pluie.org>
headers :
- sh :
file :
- build.sh
- valadoc.sh
startline : 2 # to embed shebang before header tpl
sepline :
motif : "# "
repeat : 40
comment :
start : "#^#"
end : "#^#"
begin : "# "
- meson :
file :
- meson.build
- src/meson.build
sepline :
motif : "# "
repeat : 40
comment :
start : "#^#"
end : "#^#"
begin : "# "
- vala :
dir :
- src
- samples
extension :
- .vala
- .c
sepline :
motif : " *"
repeat : 40
comment :
start : "/*^"
end : "^*/"
begin : " * "
tpl : |
^sepline^
^keys^
^sepline^
This file is part of ^software.name^.
^software.name^ is free software (free as in speech) : you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the License,
or (at your option) any later version.
^software.name^ is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License
along with ^software.name^. If not, see ^license.address^.
^sepline^

4
.gitignore vendored
View File

@ -2,3 +2,7 @@ build/
bin/ bin/
doc/ doc/
pluie-yaml-*.tar.gz pluie-yaml-*.tar.gz
.geany
docfix*
docsvg.tar.gz
tag-generated.yml

View File

@ -28,7 +28,7 @@ GNU GPL v3
## Prerequisites ## Prerequisites
`valac meson ninja libyaml glib gobject gmodule gee pluie-echo` `valac meson ninja libyaml glib gobject gmodule gio gee pluie-echo`
see https://git.pluie.org/pluie/libpluie-echo in order to install pluie-echo-0.2 pkg see https://git.pluie.org/pluie/libpluie-echo in order to install pluie-echo-0.2 pkg
@ -45,15 +45,32 @@ sudo ninja install -C build
## Compilation ## Compilation
``` ```
valac --pkg pluie-echo-0.2 --pkg pluie-yaml-0.4 main.vala valac --pkg glib-2.0 \
--pkg gobject-2.0 \
--pkg gmodule-2.0 \
--pkg gio-2.0 \
--pkg gee-0.8 \
--pkg pluie-echo-0.2 \
--pkg pluie-yaml-0.4 \
main.vala
``` ```
You can use `./build.sh` to rebuild/install the **pluie-yaml** lib and compile samples files You can use `./build.sh` to rebuild/install the **pluie-yaml** lib and compile samples files
```
# rebuild lib + build all samples
./build.sh
# rebuild lib + build only single sample (give sample file name without extension)
./build.sh yaml-serialize
# rebuild lib in local mode
# local mode avoid to rebuild when modifying yaml files in resources dir
# must be in the root directory
./build.sh yaml-serialize 1
```
## Api / Documentation ## Api / Documentation
https://pluie.org/pluie-yaml-0.5/index.htm https://pluie.org/pluie-yaml-0.6/index.htm
## Docker ## Docker
@ -280,7 +297,7 @@ on yaml side, proceed like that :
%YAML 1.2 %YAML 1.2
%TAG !v! tag:pluie.org,2018:vala/ %TAG !v! tag:pluie.org,2018:vala/
--- ---
!v!Pluie.Yaml.Example test1 : !v!Pluie.Samples.YamlObject test1 :
myname : test1object myname : test1object
type_int : !v!int 3306 type_int : !v!int 3306
type_bool : !v!bool false type_bool : !v!bool false
@ -291,12 +308,12 @@ on yaml side, proceed like that :
type_float : !v!float 42.36 type_float : !v!float 42.36
type_double : !v!double 95542123.4579512128 type_double : !v!double 95542123.4579512128
type_enum : !v!Pluie.Yaml.NODE_TYPE scalar # or int type_enum : !v!Pluie.Yaml.NODE_TYPE scalar # or int
!v!Pluie.Yaml.ExampleChild type_object : !v!Pluie.Samples.YamlChild type_object :
toto : totovalue1 toto : totovalue1
tata : tatavalue1 tata : tatavalue1
titi : 123 titi : 123
tutu : 1 tutu : 1
!v!Pluie.Yaml.ExampleStruct type_struct : !v!Pluie.Samples.YamlStruct type_struct :
red : !v!uint8 214 red : !v!uint8 214
green : !v!uint8 78 green : !v!uint8 78
blue : 153 blue : 153
@ -311,16 +328,18 @@ on yaml side, proceed like that :
**note :** **note :**
only the first level of yaml node matching a vala object need a tag. only the first level of yaml node matching a vala object need a tag.
**pluie-yaml** has mechanisms to retriew properties types of a Yaml.Object. **pluie-yaml** has mechanisms to retriew properties types of a Yaml.Object.
So basic vala types tag, enum tag, struct tag and derived Yaml.Object (here ExampleChild) So basic vala types tag, enum tag, struct tag and derived Yaml.Object (here Samples.YamlObject & Samples.YamlChild)
or GLib.Object vala tags are not necessary inside a Yaml.Object. or GLib.Object.
vala tags are not necessary inside a Yaml.Object.
on vala side : on vala side :
```vala ```vala
using pluie;
... ...
var obj = (Yaml.Example) Yaml.Builder.from_node (root.first ()); var obj = (Samples.YamlObject) Yaml.Builder.from_node (root.first ());
of.echo("obj.type_int : %d".printf (obj.type_int)); of.echo("obj.type_int : %d".printf (obj.type_int));
// calling ExampleChild method // calling Samples.YamlChild method
obj.type_object.method_a () obj.type_object.method_a ()
``` ```
@ -337,13 +356,15 @@ We cannot do introspection on Structure's properties, so you need to implement a
First at all, in the static construct of your class, you need to register (properties) types that need some glue for instanciation. First at all, in the static construct of your class, you need to register (properties) types that need some glue for instanciation.
```vala ```vala
public class Yaml.Example : Yaml.Object using Pluie;
public class Pluie.Samples.YamlObject : Yaml.Object
{ {
static construct static construct
{ {
Yaml.Register.add_type ( Yaml.Register.add_type (
typeof (Yaml.Example), // owned type typeof (Samples.YamlObject), // owner type
typeof (Yaml.ExampleStruct), // property type typeof (Samples.YamlStruct), // property type
typeof (Gee.ArrayList) // property type typeof (Gee.ArrayList) // property type
); );
} }
@ -353,13 +374,13 @@ public class Yaml.Example : Yaml.Object
Secondly you must override the `public void populate_from_node (Glib.Type, Yaml.Node node)` Yaml.Object original method. Secondly you must override the `public void populate_from_node (Glib.Type, Yaml.Node node)` Yaml.Object original method.
`populate_from_node` is automatically called by the Yaml.Builder if the type property is prealably registered. `populate_from_node` is automatically called by the Yaml.Builder if the type property is prealably registered.
Example of implementation from `src/vala/Pluie/Yaml.Example.vala` : Example of implementation from `src/vala/Pluie/Samples.YamlObject.vala` :
```vala ```vala
public override void populate_from_node(GLib.Type type, Yaml.Node node) public override void populate_from_node(GLib.Type type, Yaml.Node node)
{ {
if (type == typeof (Yaml.ExampleStruct)) { if (type == typeof (Samples.YamlStruct)) {
this.type_struct = ExampleStruct.from_yaml_node (node); this.type_struct = Samples.YamlStruct.from_yaml_node (node);
} }
else if (type == typeof (Gee.ArrayList)) { else if (type == typeof (Gee.ArrayList)) {
this.type_gee_al = new Gee.ArrayList<string> (); this.type_gee_al = new Gee.ArrayList<string> ();
@ -375,9 +396,9 @@ Once your class has this glue, you can deal with complex object and populate the
directly from yaml files. directly from yaml files.
for more details see : for more details see :
* `src/vala/Pluie/Yaml.Example.vala` * `src/vala/Pluie/Samples.YamlObject.vala`
* `src/vala/Pluie/Yaml.ExampleChild.vala` * `src/vala/Pluie/Samples.YamlChild.vala`
* `src/vala/Pluie/Yaml.ExampleStruct.vala` * `src/vala/Pluie/Samples.YamlStruct.vala`
* `samples/yaml-tag.vala` * `samples/yaml-tag.vala`
code from samples/yaml-tag.vala : code from samples/yaml-tag.vala :
@ -399,7 +420,7 @@ reverse build mechanism is also possible but have the same limitation.
root.display_childs (); root.display_childs ();
of.action ("Yaml.Builder.from_node", root.first ().name); of.action ("Yaml.Builder.from_node", root.first ().name);
var obj = (Yaml.Example) Yaml.Builder.from_node (root.first ()); var obj = (Samples.YamlObject) Yaml.Builder.from_node (root.first ());
obj.type_object.method_a (); obj.type_object.method_a ();
of.action ("Yaml.Builder.to_node", obj.get_type ().name ()); of.action ("Yaml.Builder.to_node", obj.get_type ().name ());
@ -412,7 +433,7 @@ reverse build mechanism is also possible but have the same limitation.
you need to override the `public Yaml.Node? populate_to_node(GLib.Type type, string name)` Yaml.Object original method you need to override the `public Yaml.Node? populate_to_node(GLib.Type type, string name)` Yaml.Object original method
`populate_to_node` is also automatically called by the Yaml.Builder if the type property is prealably registered. `populate_to_node` is also automatically called by the Yaml.Builder if the type property is prealably registered.
Example of implementation from `src/vala/Pluie/Yaml.Example.vala` : Example of implementation from `src/vala/Pluie/Samples.YamlObject.vala` :
```vala ```vala
public override Yaml.Node? populate_to_node(GLib.Type type, string name) public override Yaml.Node? populate_to_node(GLib.Type type, string name)
@ -420,7 +441,7 @@ Example of implementation from `src/vala/Pluie/Yaml.Example.vala` :
Yaml.Node? node = base.populate_to_node (type, name); Yaml.Node? node = base.populate_to_node (type, name);
// non Yaml.Object type & registered type // non Yaml.Object type & registered type
if (node == null) { if (node == null) {
if (type == typeof (Yaml.ExampleStruct)) { if (type == typeof (Samples.YamlStruct)) {
node = this.type_struct.to_yaml_node (name); node = this.type_struct.to_yaml_node (name);
} }
else if (type == typeof (Gee.ArrayList)) { else if (type == typeof (Gee.ArrayList)) {

View File

@ -1,13 +1,13 @@
#!/bin/bash #!/bin/bash
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #^# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> # @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
# @version : 0.5 # @version : 0.60
# @type : library # @type : library
# @date : 2018 # @date : 2018
# @licence : GPLv3.0 <http://www.gnu.org/licenses/> # @license : GPLv3.0 <http://www.gnu.org/licenses/>
# @author : a-Sansara <[dev]at[pluie]dot[org]> # @author : a-Sansara <[dev]at[pluie]dot[org]>
# @copyright : pluie.org <http://www.pluie.org/> # @copyright : pluie.org <http://www.pluie.org>
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
@ -18,26 +18,28 @@
# published by the Free Software Foundation, either version 3 of the License, # published by the Free Software Foundation, either version 3 of the License,
# or (at your option) any later version. # or (at your option) any later version.
# #
# lib-yaml is distributed in the hope that it will be useful, but WITHOUT # pluie-yaml is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details. # more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>. # along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #^#
# -------------------------------------------------------- # --------------------------------------------------------
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
lib="pluie-yaml-0.5" lib="pluie-yaml-0.6"
c1="\033[1;38;5;215m" samples=" src/vala/Pluie/Samples.YamlObject.vala \
c2="\033[1;38;5;97m" src/vala/Pluie/Samples.YamlChild.vala \
cok="\033[1;38;5;37m" src/vala/Pluie/Samples.YamlStruct.vala "
cko="\033[1;38;5;204m" c1="\033[1;38;5;215m"
off="\033[m" c2="\033[1;38;5;97m"
resume= cok="\033[1;38;5;37m"
cko="\033[1;38;5;204m"
off="\033[m"
resume=
# -------------------------------------------------------- # --------------------------------------------------------
function build.title() function build.title()
{ {
@ -63,6 +65,11 @@ function build.lib()
cd "$DIR" cd "$DIR"
build.title "$lib LIB BUILD" build.title "$lib LIB BUILD"
meson --prefix=/usr ./ build meson --prefix=/usr ./ build
if [ "$1" -eq 1 ]; then
meson configure -DLOCAL=true build
else
meson configure -DLOCAL=false build
fi
if [ "$UID" != "0" ]; then if [ "$UID" != "0" ]; then
sudo ninja -v install -C build sudo ninja -v install -C build
else else
@ -95,9 +102,9 @@ function build.sample()
local f="$(basename $1)" local f="$(basename $1)"
local fx="${f:0:-5}" local fx="${f:0:-5}"
local state="FAILED" local state="FAILED"
local cmd="valac -v --pkg gee-0.8 --pkg gio-2.0 --pkg pluie-echo-0.2 --pkg $lib $1 -o ./bin/$fx" local cmd="valac -v -X -Wno-discarded-qualifiers -X -Wno-deprecated-declarations --pkg gee-0.8 --pkg gio-2.0 --pkg pluie-echo-0.2 --pkg $lib $samples $1 -o ./bin/$fx"
build.title "$f SAMPLE BUILD" build.title "$f SAMPLE BUILD"
echo -e "\n$cmd" echo
$cmd $cmd
local done=$? local done=$?
resume="$resume$done$f " resume="$resume$done$f "
@ -110,10 +117,10 @@ function build.main()
if [ ! -z "$1" ]; then if [ ! -z "$1" ]; then
onefile="./samples/$1.vala" onefile="./samples/$1.vala"
fi fi
build.lib build.lib "$2"
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
build.samples $onefile build.samples $onefile
fi fi
} }
build.main "$1" build.main "$1" "${2:-0}"

View File

@ -1,38 +0,0 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.5
* @type : library
* @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org/>
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* This file is part of pluie-yaml.
*
* pluie-yaml is free software (free as in speech) : you can redistribute it
* and/or modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* pluie-yaml is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/
namespace Pluie
{
namespace Yaml
{
protected const string INSTALL_PATH = "@INSTALL_PATH@";
public const string DATA_PATH = "@DATA_PATH@";
public const string VERSION = "@VERSION@";
}
}

View File

@ -1,18 +1,18 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #^# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> # @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
# @version : 0.5 # @version : 0.60
# @type : library # @type : library
# @date : 2018 # @date : 2018
# @licence : GPLv3.0 <http://www.gnu.org/licenses/> # @license : GPLv3.0 <http://www.gnu.org/licenses/>
# @author : a-Sansara <[dev]at[pluie]dot[org]> # @author : a-Sansara <[dev]at[pluie]dot[org]>
# @copyright : pluie.org <http://www.pluie.org/> # @copyright : pluie.org <http://www.pluie.org>
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# This file is part of pluie-yaml. # This file is part of pluie-yaml.
# #
# lib-yaml is free software (free as in speech) : you can redistribute it # pluie-yaml is free software (free as in speech) : you can redistribute it
# and/or modify it under the terms of the GNU General Public License as # and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the License, # published by the Free Software Foundation, either version 3 of the License,
# or (at your option) any later version. # or (at your option) any later version.
@ -23,87 +23,65 @@
# more details. # more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>. # along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #^#
#
project('pluie-yaml', 'vala', 'c', version:'0.5') project('pluie-yaml', ['vala', 'c'], version:'0.6')
cc = meson.get_compiler('c') cc = meson.get_compiler('c')
dep_glib = dependency('glib-2.0')
dep_gobject = dependency('gobject-2.0')
dep_gmodule = dependency('gmodule-2.0')
dep_gio = dependency('gio-2.0')
dep_gee = dependency('gee-0.8')
dep_echo = dependency('pluie-echo-0.2')
dep_m = cc.find_library('m', required : false)
dep_yaml = cc.find_library('yaml', required : true)
#~ add_global_link_arguments('-lyaml', language : 'c')
version = meson.project_version() version = meson.project_version()
bindir = join_paths(get_option('prefix'), get_option('bindir')) bindir = join_paths(get_option('prefix'), get_option('bindir'))
datadir = join_paths(get_option('prefix'), get_option('datadir'), 'pluie/yaml') datadir = join_paths(get_option('prefix'), get_option('datadir'), 'pluie/yaml')
libdir = join_paths(get_option('prefix'), get_option('libdir'), 'pkgconfig') libdir = join_paths(get_option('prefix'), get_option('libdir'), 'pkgconfig')
incdir = join_paths(get_option('prefix'), get_option('includedir'), 'pluie') incdir = join_paths(get_option('prefix'), get_option('includedir'), 'pluie')
conf = configuration_data() conf = configuration_data()
conf.set('VERSION' , version) conf.set('VERSION' , version)
conf.set('INSTALL_PATH', bindir) conf.set('INSTALL_PATH', bindir)
conf.set('DATA_PATH' , datadir) if get_option('LOCAL')
conf.set('DATA_PATH' , './resources')
else
conf.set('DATA_PATH' , datadir)
endif
configure_file( configure_file(
input: 'install.vala.in', input: 'src/vala/install.vala.in',
output: 'install.vala', output: 'install.vala',
configuration: conf configuration: conf
) )
sources = [ install_data([
'build/install.vala', 'resources/main.yml',
'src/vala/Pluie/Io.Reader.vala', 'resources/tag.yml',
'src/vala/Pluie/Io.InputChunkStream.vala', 'resources/bug.yml',
'src/vala/Pluie/Io.StreamLineMark.vala', 'resources/test.yml',
'src/vala/Pluie/Io.Writter.vala', 'resources/test.json'
'src/vala/Pluie/Yaml.global.vala', ],
'src/vala/Pluie/Yaml.AbstractChild.vala', install_dir : datadir
'src/vala/Pluie/Yaml.AbstractNode.vala', )
'src/vala/Pluie/Yaml.Builder.vala',
'src/vala/Pluie/Yaml.Collection.vala',
'src/vala/Pluie/Yaml.Config.vala',
'src/vala/Pluie/Yaml.Dumper.vala',
'src/vala/Pluie/Yaml.Event.vala',
'src/vala/Pluie/Yaml.Example.vala',
'src/vala/Pluie/Yaml.ExampleChild.vala',
'src/vala/Pluie/Yaml.ExampleStruct.vala',
'src/vala/Pluie/Yaml.Finder.vala',
'src/vala/Pluie/Yaml.GeeBuilder.vala',
'src/vala/Pluie/Yaml.Loader.vala',
'src/vala/Pluie/Yaml.Mapping.vala',
'src/vala/Pluie/Yaml.Node.vala',
'src/vala/Pluie/Yaml.Object.vala',
'src/vala/Pluie/Yaml.Processor.vala',
'src/vala/Pluie/Yaml.Register.vala',
'src/vala/Pluie/Yaml.Root.vala',
'src/vala/Pluie/Yaml.Scalar.vala',
'src/vala/Pluie/Yaml.Scanner.vala',
'src/vala/Pluie/Yaml.Sequence.vala',
'src/vala/Pluie/Yaml.Tag.vala',
'src/c/yaml.c'
]
install_data('resources/main.yml', install_dir : datadir)
install_data('resources/tag.yml', install_dir : datadir)
install_data('resources/test.yml', install_dir : datadir)
install_data('resources/test.json', install_dir : datadir)
install_data('resources/config/db.yml', install_dir : join_paths(datadir, 'config')) install_data('resources/config/db.yml', install_dir : join_paths(datadir, 'config'))
install_data('resources/config/subdir/test.yml', install_dir : join_paths(datadir, 'config/subdir')) install_data('resources/config/subdir/test.yml', install_dir : join_paths(datadir, 'config/subdir'))
subdir('src')
add_global_arguments('-D DEBUG', language : 'valac')
libpluie_yaml = library( libpluie_yaml = library(
'pluie-yaml-' + version, 'pluie-yaml-' + version,
sources, src_files,
vala_header : 'pluie_yaml.h', vala_header : 'pluie_yaml.h',
vala_vapi : 'pluie-yaml-' +version+'.vapi', vala_vapi : 'pluie-yaml-' +version+'.vapi',
dependencies : [dep_glib, dep_gobject, dep_gmodule, dep_gio, dep_gee, dep_echo, dep_m, dep_yaml], dependencies : [
dependency('glib-2.0'),
dependency('gobject-2.0'),
dependency('gmodule-2.0'),
dependency('gio-2.0'),
dependency('gee-0.8'),
dependency('pluie-echo-0.2'),
cc.find_library('m', required : false),
cc.find_library('yaml', required : true)
],
install : true, install : true,
version : version, version : version,
install_dir : [get_option('libdir'), incdir, true] install_dir : [get_option('libdir'), incdir, true]

1
meson_options.txt Normal file
View File

@ -0,0 +1 @@
option('LOCAL', type : 'boolean', value : false)

82
resources/bug.yml Normal file
View File

@ -0,0 +1,82 @@
%YAML 1.2
%TAG !v! tag:pluie.org,2018:vala/
---
!v!Pluie.Berel.Meta meta :
!v!Gee.ArrayList keys :
- software : berel; <https://git.pluie.org/pluie/berel>
- version : 0.24
- type : program
- date : 2018
- license : GPLv3.0; <http://www.gnu.org/licenses/>
- author : a-Sansara; <[dev]at[pluie]dot[org]>
- copyright : pluie.org; <http://www.pluie.org>
!v!Gee.ArrayList headers :
- !v!Pluie.Berel.HeaderDef sh :
file :
- build.sh
startline : 2 # to embed shebang before header tpl
sepline :
motif : "# "
repeat : 40
comment :
start : "#^#"
end : "#^#"
begin : "# "
- !v!Pluie.Berel.HeaderDef meson :
file :
- meson.build
- src/meson.build
sepline :
motif : "# "
repeat : 40
comment :
start : "#^#"
end : "#^#"
begin : "# "
- !v!Pluie.Berel.HeaderDef vala :
dir :
- src
extension :
- .vala
sepline :
motif : " *"
repeat : 40
comment :
start : "/*^"
end : "^*/"
begin : " * "
tpl : |
^sepline^
^keys^
^sepline^
This file is part of ^software.name^.
^software.name^ is free software (free as in speech) : you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the License,
or (at your option) any later version.
^software.name^ is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License
along with ^software.name^. If not, see <http://www.gnu.org/licenses/>.
^sepline^
product:
- sku : BL394D
quantity : 5
description : Basketball
price : 450.00
- sku : BL394D
quantity : 5
description : Basketball
price : 450.00

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
%YAML 1.2 %YAML 1.2
%TAG !v! tag:pluie.org,2018:vala/ %TAG !v! tag:pluie.org,2018:vala/
--- ---
!v!Pluie.Yaml.Example test1 : !v!Pluie.Samples.YamlObject test1 :
myname : test1object myname : test1object
type_int : !v!int 3306 type_int : !v!int 3306
type_bool : !v!bool false type_bool : !v!bool false
@ -12,12 +12,12 @@
type_float : !v!float 42.36 type_float : !v!float 42.36
type_double : !v!double 95542123.4579512128 type_double : !v!double 95542123.4579512128
type_enum : !v!Pluie.Yaml.NODE_TYPE scalar # or int type_enum : !v!Pluie.Yaml.NODE_TYPE scalar # or int
!v!Pluie.Yaml.ExampleChild type_object : !v!Pluie.Samples.YamlChild type_object :
toto : totovalue1 toto : totovalue1
tata : tatavalue1 tata : tatavalue1
titi : 123 titi : 123
tutu : 1 tutu : 1
!v!Pluie.Yaml.ExampleStruct type_struct : !v!Pluie.Samples.YamlStruct type_struct :
red : !v!uint8 214 red : !v!uint8 214
green : !v!uint8 78 green : !v!uint8 78
blue : 153 blue : 153
@ -43,3 +43,35 @@
tata : tatavalue4 tata : tatavalue4
titi : 44 titi : 44
tutu : 0 tutu : 0
!v!Gee.HashMap type_gee_hmap :
- key : key1
!v!Pluie.Samples.YamlChild val :
toto : key1toto
tata : kay1tata
titi : 5
tutu : 0
- key : key2
val :
toto : key2toto
tata : kay2tata
titi : 46
tutu : 1
!v!Gee.HashMap type_gee_hmap2 :
- !v!Pluie.Samples.YamlStruct key :
red : !v!uint8 214
green : !v!uint8 78
blue : 153
!v!Pluie.Samples.YamlChild val :
toto : key1toto
tata : kay1tata
titi : 5
tutu : 0
- key :
red : !v!uint8 82
green : !v!uint8 109
blue : 35
val :
toto : key2toto
tata : kay2tata
titi : 46
tutu : 1

View File

@ -1,20 +1,20 @@
{ {
"glossary": { "glossary": {
"title": "example glossary", "title": "example glossary",
"GlossDiv": { "GlossDiv": {
"title": "S", "title": "S",
"GlossList": { "GlossList": {
"GlossEntry": { "GlossEntry": {
"ID": "SGML", "ID": "SGML",
"SortAs": "SGML", "SortAs": "SGML",
"GlossTerm": "Standard Generalized Markup Language", "GlossTerm": "Standard Generalized Markup Language",
"Acronym": "SGML", "Acronym": "SGML",
"Abbrev": "ISO 8879:1986", "Abbrev": "ISO 8879:1986",
"GlossDef": { "GlossDef": {
"para": "A meta-markup language, used to create markup languages such as DocBook.", "para": "A meta-markup language, used to create markup languages such as DocBook.",
"GlossSeeAlso": ["GML", "XML"] "GlossSeeAlso": ["GML", "XML"]
}, },
"GlossSee": "markup" "GlossSee": "markup"
} }
} }
} }

View File

@ -1,3 +1,32 @@
/*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.60
* @type : library
* @date : 2018
* @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org>
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* This file is part of pluie-yaml.
*
* pluie-yaml is free software (free as in speech) : you can redistribute it
* and/or modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* pluie-yaml is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
@ -40,7 +69,7 @@ int main (string[] args)
var done = false; var done = false;
of.title ("Pluie Yaml Library", Pluie.Yaml.VERSION, "a-sansara"); of.title ("Pluie Yaml Library", Pluie.Yaml.VERSION, "a-sansara");
Pluie.Yaml.DEBUG = false; Pluie.Yaml.DEBUG = true;
var loader = new Yaml.Loader (path, true, true); var loader = new Yaml.Loader (path, true, true);
if ((done = loader.done)) { if ((done = loader.done)) {
var root = loader.get_nodes (); var root = loader.get_nodes ();

85
samples/yaml-bug.vala Normal file
View File

@ -0,0 +1,85 @@
/*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.60
* @type : library
* @date : 2018
* @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org>
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* This file is part of pluie-yaml.
*
* pluie-yaml is free software (free as in speech) : you can redistribute it
* and/or modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* pluie-yaml is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.5
* @type : library
* @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org/>
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* This file is part of pluie-yaml.
*
* pluie-yaml is free software (free as in speech) : you can redistribute it
* and/or modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* pluie-yaml is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/
using GLib;
using Gee;
using Pluie;
int main (string[] args)
{
Echo.init(false);
var path = Yaml.DATA_PATH + "/bug.yml";
var done = false;
of.title ("Pluie Yaml Library", Pluie.Yaml.VERSION, "a-sansara");
Pluie.Yaml.DEBUG = false;
Yaml.Loader.PACK_NESTED_ENTRIES = true;
var loader = new Yaml.Loader (path, true, true);
if ((done = loader.done)) {
var root = loader.get_nodes ();
done = root != null;
}
of.rs (done);
of.echo ();
return (int) done;
}

View File

@ -1,3 +1,32 @@
/*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.60
* @type : library
* @date : 2018
* @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org>
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* This file is part of pluie-yaml.
*
* pluie-yaml is free software (free as in speech) : you can redistribute it
* and/or modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* pluie-yaml is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>

View File

@ -1,3 +1,32 @@
/*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.60
* @type : library
* @date : 2018
* @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org>
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* This file is part of pluie-yaml.
*
* pluie-yaml is free software (free as in speech) : you can redistribute it
* and/or modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* pluie-yaml is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
@ -46,21 +75,13 @@ int main (string[] args)
if ((done = root != null)) { if ((done = root != null)) {
root.display_childs (); root.display_childs ();
of.action("Yaml.Node", "to_yaml_string"); of.action("Yaml.Node", "to_yaml_string");
string yaml = root.to_yaml_string ();
string genpath = "./tag-generated.yml"; string genpath = "./tag-generated.yml";
try { var writter = new Io.Writter (genpath, true);
var writter = new Io.Writter (genpath, true); long written = 0;
long written = 0; writter.write (root.to_yaml_string ().data, out written);
writter.write (yaml.data, out written); of.echo ("write %ld bytes in `%s`".printf ((long) written, genpath));
of.echo ("write %ld bytes in `%s`".printf ((long) written, genpath)); Yaml.Dumper.show_yaml_string (root, true, true, true);
Yaml.Dumper.show_yaml_string (root, true, true, true);
}
catch (Error e) {
stderr.printf ("%s\n", e.message);
return 1;
}
} }

View File

@ -1,3 +1,32 @@
/*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.60
* @type : library
* @date : 2018
* @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org>
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* This file is part of pluie-yaml.
*
* pluie-yaml is free software (free as in speech) : you can redistribute it
* and/or modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* pluie-yaml is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>

View File

@ -1,3 +1,32 @@
/*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.60
* @type : library
* @date : 2018
* @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org>
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* This file is part of pluie-yaml.
*
* pluie-yaml is free software (free as in speech) : you can redistribute it
* and/or modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* pluie-yaml is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>

View File

@ -1,3 +1,32 @@
/*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.60
* @type : library
* @date : 2018
* @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org>
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* This file is part of pluie-yaml.
*
* pluie-yaml is free software (free as in speech) : you can redistribute it
* and/or modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* pluie-yaml is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>

View File

@ -1,3 +1,32 @@
/*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.60
* @type : library
* @date : 2018
* @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org>
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* This file is part of pluie-yaml.
*
* pluie-yaml is free software (free as in speech) : you can redistribute it
* and/or modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* pluie-yaml is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>

View File

@ -1,12 +1,12 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.5 * @version : 0.60
* @type : library * @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org/> * @copyright : pluie.org <http://www.pluie.org>
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
@ -23,16 +23,15 @@
* more details. * more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
*/
using GLib; using GLib;
using Gee; using Gee;
using Pluie; using Pluie;
public void test_object(Yaml.Example obj) public void test_object(Samples.YamlObject obj)
{ {
of.action ("Test Object", obj.yaml_name); of.action ("Test Object", obj.yaml_name);
obj.type_object.method_a (); obj.type_object.method_a ();
@ -68,6 +67,31 @@ public void test_object(Yaml.Example obj)
of.keyval(" tutu" , "%s (bool)" .printf(child.tutu.to_string ())); of.keyval(" tutu" , "%s (bool)" .printf(child.tutu.to_string ()));
child.method_a (); child.method_a ();
} }
if (obj.type_gee_hmap != null) {
of.keyval("type_gee_hmap", "(%s<%s, %s>)" .printf(obj.type_gee_hmap.get_type ().name (), obj.type_gee_hmap.key_type.name (), obj.type_gee_hmap.value_type.name ()));
foreach (var child in obj.type_gee_hmap.entries) {
of.echo(" == entry (%s) ==".printf(child.key));
of.keyval(" toto" , "%s (string)" .printf(child.value.toto));
of.keyval(" tapa" , "%s (string)" .printf(child.value.tata));
of.keyval(" titi" , "%d (int)" .printf(child.value.titi));
of.keyval(" tutu" , "%s (bool)" .printf(child.value.tutu.to_string ()));
}
}
if (obj.type_gee_hmap2 != null) {
of.keyval("type_gee_hmap", "(%s<%s, %s>)" .printf(obj.type_gee_hmap2.get_type ().name (), obj.type_gee_hmap2.key_type.name (), obj.type_gee_hmap2.value_type.name ()));
foreach (var child in obj.type_gee_hmap2.entries) {
of.echo(" == key ==");
of.keyval(" obj :" , "%s" .printf(child.key.to_string ()));
of.echo(" == val (%s) ==".printf(child.value.get_type ( ).name ()));
of.keyval(" toto" , "%s (string)" .printf(child.value.toto));
of.keyval(" tapa" , "%s (string)" .printf(child.value.tata));
of.keyval(" titi" , "%d (int)" .printf(child.value.titi));
of.keyval(" tutu" , "%s (bool)" .printf(child.value.tutu.to_string ()));
}
}
else {
of.echo ("hmap2 null");
}
} }
} }
@ -86,8 +110,7 @@ int main (string[] args)
root.display_childs (); root.display_childs ();
of.action ("Yaml build first child", root.first ().name); of.action ("Yaml build first child", root.first ().name);
Yaml.Example obj = (Yaml.Example) Yaml.Builder.from_node (root.first ()); var obj = (Samples.YamlObject) Yaml.Builder.from_node (root.first ());
obj = (Yaml.Example) Yaml.Builder.from_node (root.first ());
test_object (obj); test_object (obj);
of.action ("Serialize", obj.yaml_name); of.action ("Serialize", obj.yaml_name);
@ -100,7 +123,7 @@ int main (string[] args)
root = Yaml.deserialize (zdata); root = Yaml.deserialize (zdata);
root.display_childs (); root.display_childs ();
of.action ("Yaml build first child", obj.yaml_name); of.action ("Yaml build first child", obj.yaml_name);
obj = (Yaml.Example) Yaml.Builder.from_node (root.first ()); obj = (Samples.YamlObject) Yaml.Builder.from_node (root.first ());
test_object (obj); test_object (obj);
} }

View File

@ -1,3 +1,32 @@
/*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.60
* @type : library
* @date : 2018
* @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org>
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* This file is part of pluie-yaml.
*
* pluie-yaml is free software (free as in speech) : you can redistribute it
* and/or modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* pluie-yaml is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
@ -60,11 +89,12 @@ int main (string[] args)
node = node.next_sibling (); node = node.next_sibling ();
} }
} }
// hard code // hard code
Yaml.Example? o = null; Samples.YamlObject? o = null;
foreach (var entry in list.entries) { foreach (var entry in list.entries) {
if ((o = (Yaml.Example) entry.value)!=null) { if ((o = (Samples.YamlObject) entry.value)!=null) {
of.action ("Getting Hard coded values for Yaml.Object %s".printf (of.c (ECHO.MICROTIME).s (o.get_type().name ())), entry.key); of.action ("Getting Hard coded values for Samples.YamlObject %s".printf (of.c (ECHO.MICROTIME).s (o.get_type().name ())), entry.key);
of.keyval("yaml_name" , "%s" .printf(o.yaml_name)); of.keyval("yaml_name" , "%s" .printf(o.yaml_name));
of.keyval("type_int" , "%d" .printf(o.type_int)); of.keyval("type_int" , "%d" .printf(o.type_int));
of.keyval("type_bool" , "%s" .printf(o.type_bool.to_string ())); of.keyval("type_bool" , "%s" .printf(o.type_bool.to_string ()));
@ -99,6 +129,31 @@ int main (string[] args)
child.method_a (); child.method_a ();
} }
} }
if (o.type_gee_hmap != null) {
of.keyval("type_gee_hmap", "(%s<%s, %s>)" .printf(o.type_gee_hmap.get_type ().name (), o.type_gee_hmap.key_type.name (), o.type_gee_hmap.value_type.name ()));
foreach (var child in o.type_gee_hmap.entries) {
of.echo(" == entry (%s) ==".printf(child.key));
of.keyval(" toto" , "%s (string)" .printf(child.value.toto));
of.keyval(" tapa" , "%s (string)" .printf(child.value.tata));
of.keyval(" titi" , "%d (int)" .printf(child.value.titi));
of.keyval(" tutu" , "%s (bool)" .printf(child.value.tutu.to_string ()));
}
}
if (o.type_gee_hmap2 != null) {
of.keyval("type_gee_hmap", "(%s<%s, %s>)" .printf(o.type_gee_hmap2.get_type ().name (), o.type_gee_hmap2.key_type.name (), o.type_gee_hmap2.value_type.name ()));
foreach (var child in o.type_gee_hmap2.entries) {
of.echo(" == key ==");
of.keyval(" obj :" , "%s" .printf(child.key.to_string ()));
of.echo(" == val (%s) ==".printf(child.value.get_type ( ).name ()));
of.keyval(" toto" , "%s (string)" .printf(child.value.toto));
of.keyval(" tapa" , "%s (string)" .printf(child.value.tata));
of.keyval(" titi" , "%d (int)" .printf(child.value.titi));
of.keyval(" tutu" , "%s (bool)" .printf(child.value.tutu.to_string ()));
}
}
else {
of.echo ("hmap2 null");
}
} }
} }

View File

@ -1,3 +1,32 @@
/*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.60
* @type : library
* @date : 2018
* @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org>
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* This file is part of pluie-yaml.
*
* pluie-yaml is free software (free as in speech) : you can redistribute it
* and/or modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* pluie-yaml is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
@ -46,7 +75,7 @@ int main (string[] args)
root.first ().display_childs (); root.first ().display_childs ();
of.action ("with signal Yaml.Builder.from_node", root.first ().name); of.action ("with signal Yaml.Builder.from_node", root.first ().name);
Yaml.Example obj = (Yaml.Example) Yaml.Builder.from_node (root.first ()); Samples.YamlObject obj = (Samples.YamlObject) Yaml.Builder.from_node (root.first ());
obj.type_object.method_a (); obj.type_object.method_a ();
if (obj.type_gee_al != null) { if (obj.type_gee_al != null) {
of.keyval("type_gee_al", "(%s<%s>)" .printf(obj.type_gee_al.get_type ().name (), obj.type_gee_al.element_type.name ())); of.keyval("type_gee_al", "(%s<%s>)" .printf(obj.type_gee_al.get_type ().name (), obj.type_gee_al.element_type.name ()));

View File

@ -1,3 +1,32 @@
/*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.60
* @type : library
* @date : 2018
* @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org>
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* This file is part of pluie-yaml.
*
* pluie-yaml is free software (free as in speech) : you can redistribute it
* and/or modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* pluie-yaml is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
@ -103,13 +132,14 @@ int main (string[] args)
var done = false; var done = false;
of.title ("Pluie Yaml Library", Pluie.Yaml.VERSION, "a-sansara"); of.title ("Pluie Yaml Library", Pluie.Yaml.VERSION, "a-sansara");
Pluie.Yaml.DEBUG = true; Pluie.Yaml.DEBUG = false;
var config = new Yaml.Config (path, true); var config = new Yaml.Config (path, true);
var root = config.root_node () as Yaml.Root; var root = config.root_node ();
root.display_childs ();
root.first ().display_childs (); root.first ().display_childs ();
of.action ("Yaml.Builder.from_node", root.first ().name); of.action ("Yaml.Builder.from_node", root.first ().name);
var obj = (Yaml.Example) Yaml.Builder.from_node (root.first ()); Samples.YamlObject obj = (Samples.YamlObject) Yaml.Builder.from_node (root.first ());
obj.type_object.method_a (); obj.type_object.method_a ();
if (obj.type_gee_al != null) { if (obj.type_gee_al != null) {
of.keyval("type_gee_al", "(%s)" .printf(obj.type_gee_al.get_type ().name ())); of.keyval("type_gee_al", "(%s)" .printf(obj.type_gee_al.get_type ().name ()));
@ -123,91 +153,6 @@ int main (string[] args)
n.display_childs (); n.display_childs ();
} }
//~ double?[] data = { 46548970.54324546464, 2.2, 2.1, 2.4, 5.7 };
//~ var list = new Gee.ArrayList<double?> ();
//~ list.add_all_array (data);
//~ Gee.ArrayList* p = list;
//~ var mynode = new Yaml.Root ();
//~ Yaml.GeeBuilder.arraylist_to_node (p, "Gee.ArrayList<double?>", mynode);
//~ string[] data2 = { "mastring1", "mastring2", "mastring3", "mastring4", "mastring5" };
//~ var list2 = new Gee.ArrayList<string> ();
//~ list2.add_all_array (data2);
//~ p = list2;
//~ Yaml.GeeBuilder.arraylist_to_node (p, "Gee.ArrayList<string>", mynode);
//~ int[] data3 = { 123, 456, 9875, 64205, 9924563 };
//~ var list3 = new Gee.ArrayList<int> ();
//~ list3.add_all_array (data3);
//~ p = list3;
//~ Yaml.GeeBuilder.arraylist_to_node (p, "Gee.ArrayList<int>", mynode);
//~ int64?[] data4 = { 123, 456, -9875, 64205, -549924563 };
//~ var list4 = new Gee.ArrayList<int64?> ();
//~ list4.add_all_array (data4);
//~ p = list4;
//~ Yaml.GeeBuilder.arraylist_to_node (p, "Gee.ArrayList<int64?>", mynode);
//~ long?[] data5 = { 123, 456, -9875, 64205, -549924563 };
//~ var list5 = new Gee.ArrayList<long?> ();
//~ list5.add_all_array (data5);
//~ p = list5;
//~ Yaml.GeeBuilder.arraylist_to_node (p, "Gee.ArrayList<long?>", mynode);
//~ uint[] data6 = { 123, 456, 19875, 64205, 1549924563 };
//~ var list6 = new Gee.ArrayList<uint> ();
//~ list6.add_all_array (data6);
//~ p = list6;
//~ Yaml.GeeBuilder.arraylist_to_node (p, "Gee.ArrayList<uint>", mynode);
//~ uint8[] data7 = { 97, 99, 122, 72 };
//~ var list7 = new Gee.ArrayList<uint8> ();
//~ list7.add_all_array (data7);
//~ foreach (uint8 u in list7) {
//~ of.echo(" - item7 : %u".printf (u));
//~ }
//~ p = list7;
//~ Yaml.GeeBuilder.arraylist_to_node (p, "Gee.ArrayList<uint8>", mynode);
//~ uchar[] data8 = { 'a', 'c', 'z', 'H' };
//~ var list8 = new Gee.ArrayList<uchar> ();
//~ list8.add_all_array (data8);
//~ foreach (uchar u in list8) {
//~ of.echo(" - item8 : %c".printf (u));
//~ }
//~ p = list8;
//~ Yaml.GeeBuilder.arraylist_to_node (p, "Gee.ArrayList<uchar>", mynode, true);
//~ unichar[] data9 = { '水', 'は', '方', 'の', 'é', 'à', 'ï', 'Ô' };
//~ var list9 = new Gee.ArrayList<unichar> ();
//~ list9.add_all_array (data9);
//~ foreach (unichar u in list9) {
//~ of.echo(" - item9 : %s (%lu)".printf (u.to_string (), u));
//~ }
//~ p = list9;
//~ Yaml.GeeBuilder.arraylist_to_node (p, "Gee.ArrayList<unichar?>", mynode, true);
//~ uint64?[] data10 = { 4521, 8954354, 4535213213 };
//~ var list10 = new Gee.ArrayList<uint64?> ();
//~ list10.add_all_array (data10);
//~ foreach (uint64 u in list10) {
//~ of.echo(" - item10 : %s".printf (u.to_string ()));
//~ }
//~ p = list10;
//~ Yaml.GeeBuilder.arraylist_to_node (p, "Gee.ArrayList<uint64?>", mynode);
//~ mynode.display_childs ();
of.rs (done); of.rs (done);
of.echo (); of.echo ();
return (int) done; return (int) done;

View File

@ -1,3 +1,32 @@
/*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.60
* @type : library
* @date : 2018
* @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org>
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* This file is part of pluie-yaml.
*
* pluie-yaml is free software (free as in speech) : you can redistribute it
* and/or modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* pluie-yaml is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>

View File

@ -1,12 +1,12 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.5 * @version : 0.60
* @type : library * @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org/> * @copyright : pluie.org <http://www.pluie.org>
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
@ -23,10 +23,9 @@
* more details. * more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
*/
#include <stdio.h> #include <stdio.h>
#include <yaml.h> #include <yaml.h>

58
src/meson.build Normal file
View File

@ -0,0 +1,58 @@
#^# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
# @version : 0.60
# @type : library
# @date : 2018
# @license : GPLv3.0 <http://www.gnu.org/licenses/>
# @author : a-Sansara <[dev]at[pluie]dot[org]>
# @copyright : pluie.org <http://www.pluie.org>
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# This file is part of pluie-yaml.
#
# pluie-yaml is free software (free as in speech) : you can redistribute it
# and/or modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the License,
# or (at your option) any later version.
#
# pluie-yaml is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License
# along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #^#
src_files = [
'src/c/yaml.c',
'build/install.vala',
'src/vala/Pluie/Io.Reader.vala',
'src/vala/Pluie/Io.InputChunkStream.vala',
'src/vala/Pluie/Io.StreamLineMark.vala',
'src/vala/Pluie/Io.Writter.vala',
'src/vala/Pluie/Yaml.global.vala',
'src/vala/Pluie/Yaml.AbstractChild.vala',
'src/vala/Pluie/Yaml.AbstractNode.vala',
'src/vala/Pluie/Yaml.Builder.vala',
'src/vala/Pluie/Yaml.Collection.vala',
'src/vala/Pluie/Yaml.Config.vala',
'src/vala/Pluie/Yaml.Dumper.vala',
'src/vala/Pluie/Yaml.Event.vala',
'src/vala/Pluie/Yaml.Finder.vala',
'src/vala/Pluie/Yaml.GeeBuilder.vala',
'src/vala/Pluie/Yaml.Loader.vala',
'src/vala/Pluie/Yaml.Mapping.vala',
'src/vala/Pluie/Yaml.Node.vala',
'src/vala/Pluie/Yaml.Object.vala',
'src/vala/Pluie/Yaml.Processor.vala',
'src/vala/Pluie/Yaml.Register.vala',
'src/vala/Pluie/Yaml.Root.vala',
'src/vala/Pluie/Yaml.Scalar.vala',
'src/vala/Pluie/Yaml.Scanner.vala',
'src/vala/Pluie/Yaml.Sequence.vala',
'src/vala/Pluie/Yaml.Tag.vala'
]

View File

@ -1,12 +1,12 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.5 * @version : 0.60
* @type : library * @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org/> * @copyright : pluie.org <http://www.pluie.org>
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
@ -23,10 +23,9 @@
* more details. * more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
*/
using GLib; using GLib;
@ -35,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;
/** /**

View File

@ -1,12 +1,12 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.5 * @version : 0.60
* @type : library * @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org/> * @copyright : pluie.org <http://www.pluie.org>
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
@ -23,10 +23,9 @@
* more details. * more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
*/
using GLib; using GLib;
using Gee; using Gee;

View File

@ -1,12 +1,12 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.5 * @version : 0.60
* @type : library * @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org/> * @copyright : pluie.org <http://www.pluie.org>
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
@ -23,10 +23,9 @@
* more details. * more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
*/
/** /**
* a class representing a stream mark recording a line and it's position in the stream * a class representing a stream mark recording a line and it's position in the stream

View File

@ -1,12 +1,12 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.5 * @version : 0.60
* @type : library * @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org/> * @copyright : pluie.org <http://www.pluie.org>
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
@ -23,10 +23,9 @@
* more details. * more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
*/
using GLib; using GLib;
using Gee; using Gee;

View File

@ -1,12 +1,12 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.5 * @version : 0.60
* @type : library * @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org/> * @copyright : pluie.org <http://www.pluie.org>
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
@ -23,15 +23,14 @@
* more details. * more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
*/
/** /**
* a test class to implements yamlize * a YamlCHild test class
*/ */
public class Pluie.Yaml.ExampleChild : Yaml.Object public class Pluie.Samples.YamlChild : Yaml.Object
{ {
public string toto { get; set; } public string toto { get; set; }
public string tata { get; set; } public string tata { get; set; }

View File

@ -0,0 +1,204 @@
/*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.60
* @type : library
* @date : 2018
* @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org>
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* This file is part of pluie-yaml.
*
* pluie-yaml is free software (free as in speech) : you can redistribute it
* and/or modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* pluie-yaml is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
using GLib;
using Gee;
using Pluie;
/**
* a YamlObject test class
*/
public class Pluie.Samples.YamlObject : Yaml.Object
{
public string myname { get; set; }
public string type_string { get; set; }
public int type_int { get; set; }
public uint type_uint { get; set; }
public float type_float { get; set; }
public double type_double { get; set; }
public char type_char { get; set; }
public uchar type_uchar { get; set; }
public unichar type_unichar { get; set; }
public short type_short { get; set; }
public ushort type_ushort { get; set; }
public long type_long { get; set; }
public ulong type_ulong { get; set; }
public size_t type_size_t { get; set; }
public ssize_t type_ssize_t { get; set; }
public int8 type_int8 { get; set; }
public uint8 type_uint8 { get; set; }
public int16 type_int16 { get; set; }
public uint16 type_uint16 { get; set; }
public int32 type_int32 { get; set; }
public uint32 type_uint32 { get; set; }
public int64 type_int64 { get; set; }
public uint64 type_uint64 { get; set; }
public bool type_bool { get; set; }
public Samples.YamlChild type_object { get; set; }
public Yaml.NODE_TYPE type_enum { get; set; }
public Samples.YamlStruct type_struct { get; set; }
public Gee.ArrayList<double?> type_gee_al { get; set; }
public Gee.ArrayList<Samples.YamlChild> type_gee_alobject { get; set; }
public Gee.HashMap<string, Samples.YamlChild> type_gee_hmap { get; set; }
public Gee.HashMap<YamlStruct?, Samples.YamlChild> type_gee_hmap2 { get; set; }
/**
*
*/
static construct
{
Yaml.Register.add_type (
typeof (Samples.YamlObject),
typeof (Samples.YamlChild),
typeof (Samples.YamlStruct),
typeof (Gee.ArrayList),
typeof (Gee.HashMap)
);
}
/**
*
*/
protected override void yaml_construct ()
{
this.type_gee_al = new Gee.ArrayList<double?> ();
this.type_gee_alobject = new Gee.ArrayList<Samples.YamlChild> ();
this.type_gee_hmap = new Gee.HashMap<string, Samples.YamlChild> ();
this.type_gee_hmap2 = new Gee.HashMap<Samples.YamlStruct?, Samples.YamlChild> ();
Yaml.Register.add_namespace("Gee", "Pluie.Samples");
Dbg.msg ("%s (%s) instantiated".printf (this.yaml_name, this.get_type().name ()), Log.LINE, Log.FILE);
}
/**
*
*/
protected override void yaml_init ()
{
Dbg.msg ("%s (%s) initialized".printf (this.yaml_name, this.get_type().name ()), Log.LINE, Log.FILE);
}
/**
*
*/
public override void populate_from_node (string name, GLib.Type type, Yaml.Node node) {
if (type == typeof (Samples.YamlStruct)) {
this.type_struct = Samples.YamlStruct.from_yaml_node (node);
}
else if (type == typeof (Gee.ArrayList)) {
foreach (var child in node) {
switch (name) {
case "type_gee_al":
this.type_gee_al.add(double.parse(child.data));
break;
case "type_gee_alobject":
this.type_gee_alobject.add((Samples.YamlChild) Yaml.Builder.from_node (child, typeof (Samples.YamlChild)));
break;
}
}
}
else if (type == typeof (Gee.HashMap)) {
Yaml.Mapping? c;
foreach (var child in node) {
c = child as Yaml.Mapping;
switch (name) {
case "type_gee_hmap":
Value key = c.item ("key").val (typeof (string));
var entry = (Samples.YamlChild) Yaml.Builder.from_node (c.item ("val"), typeof (Samples.YamlChild));
this.type_gee_hmap.set((string) key, entry);
break;
case "type_gee_hmap2":
var key = Samples.YamlStruct.from_yaml_node (c.item ("key"));
var entry = (Samples.YamlChild) Yaml.Builder.from_node (c.item ("val"), typeof (Samples.YamlChild));
this.type_gee_hmap2.set(key, entry);
break;
}
}
}
else {
var obj = Yaml.Builder.from_node(node, type);
if (name == "type_object") {
this.set (node.name, (Samples.YamlChild) obj);
}
else {
this.set (node.name, obj);
}
}
}
/**
*
*/
public override Yaml.Node? populate_to_node (string name, GLib.Type type, Yaml.Node parent) {
Yaml.Node? node = null;
if (type == typeof (Samples.YamlStruct)) {
node = this.type_struct.to_yaml_node (name);
}
else if (type == typeof (Gee.ArrayList)) {
switch (name) {
case "type_gee_al" :
Yaml.GeeBuilder.fundamental_arraylist_to_node (this.type_gee_al, name, parent);
break;
case "type_gee_alobject" :
Yaml.Object.objects_collection_to_node (this.type_gee_alobject, name, parent);
break;
}
}
else if (type == typeof (Gee.HashMap)) {
switch (name) {
case "type_gee_hmap" :
Yaml.Object.objects_mapkstr_to_node (this.type_gee_hmap, name, parent);
break;
case "type_gee_hmap2" :
this.hmap2_to_node (name, parent);
break;
}
}
else {
base.populate_to_node (name, type, parent);
}
return node;
}
/**
*
*/
public void hmap2_to_node (string name, Yaml.Node? parent = null)
{
of.echo (Log.METHOD);
var node = new Yaml.Sequence (parent, name);
node.tag = new Yaml.Tag (Yaml.Register.resolve_namespace_type(this.type_gee_hmap2.get_type ()), "v");
var i = 0;
foreach (var child in this.type_gee_hmap2.entries) {
var entryNode = new Yaml.Mapping (node, "_%d".printf (i));
entryNode.add (child.key.to_yaml_node ("key"));
Yaml.Builder.to_node ((GLib.Object) child.value, entryNode, false, null, "val");
}
}
}

View File

@ -1,12 +1,12 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.5 * @version : 0.60
* @type : library * @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org/> * @copyright : pluie.org <http://www.pluie.org>
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
@ -23,14 +23,14 @@
* more details. * more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
*/
/** /**
* * YamlStruct test structure
*/ */
public struct Pluie.Yaml.ExampleStruct public struct Pluie.Samples.YamlStruct
{ {
/** /**
* *
@ -46,11 +46,12 @@ public struct Pluie.Yaml.ExampleStruct
public uint blue; public uint blue;
/** /**
* * get a new YamlStruct populated by specified node
* @param node the source Yaml.Node
*/ */
public static ExampleStruct from_yaml_node (Yaml.Node node) public static YamlStruct from_yaml_node (Yaml.Node node)
{ {
ExampleStruct s = {}; YamlStruct s = {};
foreach (var child in node) { foreach (var child in node) {
var v = child.val (typeof (uint)); var v = child.val (typeof (uint));
switch (child.name) { switch (child.name) {
@ -79,6 +80,6 @@ public struct Pluie.Yaml.ExampleStruct
*/ */
public string to_string () public string to_string ()
{ {
return "%s(red:%u,green:%u,blue:%u)".printf ((typeof (ExampleStruct)).name (), this.red, this.green, this.blue); return "%s(red:%u,green:%u,blue:%u)".printf ((typeof (YamlStruct)).name (), this.red, this.green, this.blue);
} }
} }

View File

@ -1,12 +1,12 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.5 * @version : 0.60
* @type : library * @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org/> * @copyright : pluie.org <http://www.pluie.org>
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
@ -23,10 +23,9 @@
* more details. * more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
*/
using GLib; using GLib;
using Pluie; using Pluie;
@ -139,6 +138,4 @@ public abstract class Pluie.Yaml.AbstractChild : Yaml.AbstractNode
{ {
this.anchor = id; this.anchor = id;
} }
} }

View File

@ -1,12 +1,12 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.5 * @version : 0.60
* @type : library * @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org/> * @copyright : pluie.org <http://www.pluie.org>
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
@ -23,10 +23,9 @@
* more details. * more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
*/
using GLib; using GLib;
using Gee; using Gee;

View File

@ -1,12 +1,12 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.5 * @version : 0.60
* @type : library * @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org/> * @copyright : pluie.org <http://www.pluie.org>
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
@ -23,10 +23,9 @@
* more details. * more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
*/
using GLib; using GLib;
using Gee; using Gee;
@ -91,20 +90,40 @@ public class Pluie.Yaml.Builder
return type; return type;
} }
/**
*
*/
private static string resolve_c_subname (string name) throws GLib.RegexError
{
MatchInfo? mi = null;
bool update = false;
var reg = new Regex ("([A-Z]{1}[a-z]+)");
string? str = null;
var sb = new StringBuilder();
for (reg.match (name, 0, out mi) ; mi.matches () ; mi.next ()) {
if ((str = mi.fetch (1)) != null && str.length > 0) {
sb.append ("%s%s%s".printf (update ? "_" : "", str[0].tolower ().to_string (), str.substring(1)));
if (!update) update = true;
}
}
return update ? sb.str : name;
}
/** /**
* retriew corresponding c name related to specified vala name * retriew corresponding c name related to specified vala name
* @param name a valid vala identifier name * @param name a valid vala identifier name
*/ */
public static string resolve_c_name (string name) public static string resolve_c_name (string name)
{ {
string? str = null; string? str = null;
MatchInfo? mi = null; MatchInfo? mi = null;
StringBuilder sb = new StringBuilder (); StringBuilder sb = new StringBuilder ();
bool begin = true; bool begin = true;
try { try {
var reg = new Regex ("([^.]*).?"); var reg = new Regex ("([^.]*).?");
for (reg.match (name, 0, out mi) ; mi.matches () ; mi.next ()) { for (reg.match (name, 0, out mi) ; mi.matches () ; mi.next ()) {
if ((str = mi.fetch (1)) != null && str.length > 0) { str = Yaml.Builder.resolve_c_subname(mi.fetch (1));
if (str != null && str.length > 0) {
if (!begin) sb.append_unichar ('_'); if (!begin) sb.append_unichar ('_');
else begin = false; else begin = false;
sb.append_unichar (str[0].tolower ()); sb.append_unichar (str[0].tolower ());
@ -129,47 +148,42 @@ public class Pluie.Yaml.Builder
public static GLib.Object? from_node (Yaml.Node node, Type otype = GLib.Type.INVALID) public static GLib.Object? from_node (Yaml.Node node, Type otype = GLib.Type.INVALID)
{ {
GLib.Object? obj = null; GLib.Object? obj = null;
try { Type type = node.tag != null ? type_from_tag (node.tag.value) : otype;
Type type = node.tag != null ? type_from_tag (node.tag.value) : otype; if (type != Type.INVALID) {
if (type != Type.INVALID) { Yaml.dbg_action ("vala type founded", "%s (%s)".printf (type.name (), type.to_string ()));
Yaml.dbg_action ("vala type founded", "%s (%s)".printf (type.name (), type.to_string ())); if (type.is_object ()) {
if (type.is_object ()) { obj = GLib.Object.new (type);
obj = GLib.Object.new (type); if (type.is_a (typeof (Yaml.Object))) {
if (type.is_a (typeof (Yaml.Object))) { (obj as Yaml.Object).set ("yaml_name", node.name);
(obj as Yaml.Object).set ("yaml_name", node.name); (obj as Yaml.Object).yaml_construct ();
(obj as Yaml.Object).yaml_construct (); }
} if (node!= null && !node.empty ()) {
if (node!= null && !node.empty ()) { GLib.ParamSpec? def = null;
GLib.ParamSpec? def = null; Yaml.Node? scalar = null;
Yaml.Node? scalar = null; foreach (var child in node) {
foreach (var child in node) { if ((def = obj.get_class ().find_property (child.name)) != null) {
if ((def = obj.get_class ().find_property (child.name)) != null) { Yaml.dbg ("== prop [%s] type is : %s".printf (child.name, def.value_type.name ()));
Yaml.dbg ("== prop [%s] type is : %s".printf (child.name, def.value_type.name ())); if (child.ntype.is_single_pair () && (scalar = child.first ()) != null) {
if (child.ntype.is_single_pair () && (scalar = child.first ()) != null) { set_from_scalar (ref obj, def.name, def.value_type, scalar.data);
set_from_scalar (ref obj, def.name, def.value_type, scalar.data);
}
else if (child.ntype.is_collection ()) {
set_from_collection (ref obj, type, child, def.value_type);
}
} }
else { else if (child.ntype.is_collection ()) {
of.warn ("property %s not found".printf (child.name)); set_from_collection (ref obj, type, child, def.value_type);
} }
} }
else {
of.warn ("property %s not found".printf (child.name));
}
} }
} }
} }
if (obj == null) {
of.warn ("searched type not found : %s".printf (type.name ()));
}
else {
if (type.is_a (typeof (Yaml.Object))) {
(obj as Yaml.Object).yaml_init ();
}
}
} }
catch (GLib.Error e) { if (obj == null) {
of.warn (e.message); of.warn ("searched type not found : %s".printf (type.name ()));
}
else {
if (type.is_a (typeof (Yaml.Object))) {
(obj as Yaml.Object).yaml_init ();
}
} }
return obj; return obj;
} }

View File

@ -1,12 +1,12 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.5 * @version : 0.60
* @type : library * @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org/> * @copyright : pluie.org <http://www.pluie.org>
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
@ -23,10 +23,9 @@
* more details. * more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
*/
using GLib; using GLib;
using Gee; using Gee;

View File

@ -1,12 +1,12 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.5 * @version : 0.60
* @type : library * @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org/> * @copyright : pluie.org <http://www.pluie.org>
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
@ -23,13 +23,49 @@
* more details. * more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
*/
/** /**
* 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
{ {
@ -81,10 +117,12 @@ public class Pluie.Yaml.Config
this.display_file = display_file; this.display_file = display_file;
if (this.path != null) { if (this.path != null) {
this.loader = new Yaml.Loader (this.path, display_file, false); this.loader = new Yaml.Loader (this.path, display_file, false);
Yaml.Node? root = this.loader.get_nodes (); if (this.loader.done) {
if (root != null) { Yaml.Node? root = this.loader.get_nodes ();
this.finder = new Yaml.Finder(root); if (root != null) {
this.get_imports (); this.finder = new Yaml.Finder(root);
this.get_imports ();
}
} }
} }
} }
@ -105,9 +143,9 @@ public class Pluie.Yaml.Config
/** /**
* retriew the corresponding Yaml.Root node for loaded yaml file * retriew the corresponding Yaml.Root node for loaded yaml file
*/ */
public Yaml.Root root_node () public Yaml.Root? root_node ()
{ {
return this.finder.context as Yaml.Root; return this.finder!=null ? this.finder.context as Yaml.Root : null;
} }
/** /**

View File

@ -1,12 +1,12 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.5 * @version : 0.60
* @type : library * @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org/> * @copyright : pluie.org <http://www.pluie.org>
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
@ -23,10 +23,9 @@
* more details. * more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
*/
using GLib; using GLib;
using Gee; using Gee;
@ -179,11 +178,11 @@ public class Pluie.Yaml.Dumper
yaml.append(! SHOW_LINE ? "" : of.c (ECHO.NUM).s ("%03d %s".printf (line++, of.c (ECHO.FILE).s ("|")))); yaml.append(! SHOW_LINE ? "" : of.c (ECHO.NUM).s ("%03d %s".printf (line++, of.c (ECHO.FILE).s ("|"))));
yaml.append("%YAML %s\n".printf (Yaml.YAML_VERSION)); yaml.append("%YAML %s\n".printf (Yaml.YAML_VERSION));
foreach (var entry in node.tag_directives.entries) { foreach (var entry in node.tag_directives.entries) {
yaml.append(! SHOW_LINE ? "" : of.c (ECHO.NUM).s ("%03d %s".printf (line, of.c (ECHO.FILE).s ("|")))); yaml.append(! SHOW_LINE ? "" : of.c (ECHO.NUM).s ("%03d %s".printf (line++, of.c (ECHO.FILE).s ("|"))));
yaml.append ("%TAG %s %s\n".printf (entry.key, entry.value)); yaml.append ("%TAG %s %s\n".printf (entry.key, entry.value));
} }
if (show_doc) { if (show_doc) {
yaml.append(! SHOW_LINE ? "" : of.c (ECHO.NUM).s ("%03d %s".printf (line, of.c (ECHO.FILE).s ("|")))); yaml.append(! SHOW_LINE ? "" : of.c (ECHO.NUM).s ("%03d %s".printf (line++, of.c (ECHO.FILE).s ("|"))));
yaml.append ("---\n"); yaml.append ("---\n");
} }
} }

View File

@ -1,12 +1,12 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.5 * @version : 0.60
* @type : library * @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org/> * @copyright : pluie.org <http://www.pluie.org>
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
@ -23,10 +23,9 @@
* more details. * more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
*/
using GLib; using GLib;
using Gee; using Gee;

View File

@ -1,161 +0,0 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.5
* @type : library
* @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org/>
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* This file is part of pluie-yaml.
*
* pluie-yaml is free software (free as in speech) : you can redistribute it
* and/or modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* pluie-yaml is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/
using GLib;
using Gee;
using Pluie;
/**
* a test class to implements yamlize
*/
public class Pluie.Yaml.Example : Yaml.Object
{
public string myname { get; set; }
public string type_string { get; set; }
public int type_int { get; set; }
public uint type_uint { get; set; }
public float type_float { get; set; }
public double type_double { get; set; }
public char type_char { get; set; }
public uchar type_uchar { get; set; }
public unichar type_unichar { get; set; }
public short type_short { get; set; }
public ushort type_ushort { get; set; }
public long type_long { get; set; }
public ulong type_ulong { get; set; }
public size_t type_size_t { get; set; }
public ssize_t type_ssize_t { get; set; }
public int8 type_int8 { get; set; }
public uint8 type_uint8 { get; set; }
public int16 type_int16 { get; set; }
public uint16 type_uint16 { get; set; }
public int32 type_int32 { get; set; }
public uint32 type_uint32 { get; set; }
public int64 type_int64 { get; set; }
public uint64 type_uint64 { get; set; }
public bool type_bool { get; set; }
public Yaml.ExampleChild type_object { get; set; }
public Yaml.NODE_TYPE type_enum { get; set; }
public Yaml.ExampleStruct type_struct { get; set; }
public Gee.ArrayList<double?> type_gee_al { get; set; }
public Gee.ArrayList<Yaml.ExampleChild> type_gee_alobject { get; set; }
static construct
{
Yaml.Register.add_type (
typeof (Yaml.Example),
typeof (Yaml.ExampleChild),
typeof (Yaml.ExampleStruct),
typeof (Gee.ArrayList)
);
}
/**
*
*/
protected override void yaml_construct ()
{
this.type_gee_al = new Gee.ArrayList<double?> ();
this.type_gee_alobject = new Gee.ArrayList<Yaml.ExampleChild> ();
Yaml.Register.add_namespace("Gee", "GLib");
Dbg.msg ("%s (%s) instantiated".printf (this.yaml_name, this.get_type().name ()), Log.LINE, Log.FILE);
}
/**
*
*/
protected override void yaml_init ()
{
Dbg.msg ("%s (%s) initialized".printf (this.yaml_name, this.get_type().name ()), Log.LINE, Log.FILE);
}
/**
*
*/
public override void populate_from_node (string name, GLib.Type type, Yaml.Node node) {
if (type == typeof (Yaml.ExampleStruct)) {
this.type_struct = Yaml.ExampleStruct.from_yaml_node (node);
}
else if (type == typeof (Gee.ArrayList)) {
foreach (var child in node) {
switch (name) {
case "type_gee_al":
this.type_gee_al.add(double.parse(child.data));
break;
case "type_gee_alobject":
this.type_gee_alobject.add((Yaml.ExampleChild) Yaml.Builder.from_node (child, typeof (Yaml.ExampleChild)));
break;
}
}
}
else {
var obj = Yaml.Builder.from_node(node, type);
if (name == "type_object") {
this.set (node.name, (Yaml.ExampleChild) obj);
}
else {
this.set (node.name, obj);
}
}
}
/**
* match delegate CastYamlObject
*/
public GLib.Object cast_child_collection (string name, GLib.Object obj)
{
return (GLib.Object) ((Yaml.ExampleChild) obj);
}
/**
*
*/
public override Yaml.Node? populate_to_node (string name, GLib.Type type, Yaml.Node parent) {
Yaml.Node? node = null;
if (type == typeof (Yaml.ExampleStruct)) {
node = this.type_struct.to_yaml_node (name);
}
else if (type == typeof (Gee.ArrayList)) {
switch (name) {
case "type_gee_al" :
Yaml.GeeBuilder.fundamental_arraylist_to_node (this.type_gee_al, name, parent);
break;
case "type_gee_alobject" :
Yaml.Object.objects_collection_to_node (this.type_gee_alobject, name, parent);
break;
}
}
else {
base.populate_to_node (name, type, parent);
}
return node;
}
}

View File

@ -1,12 +1,12 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.5 * @version : 0.60
* @type : library * @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org/> * @copyright : pluie.org <http://www.pluie.org>
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
@ -23,10 +23,9 @@
* more details. * more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
*/
using GLib; using GLib;
using Gee; using Gee;
@ -34,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
{ {
@ -53,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

View File

@ -1,12 +1,12 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.5 * @version : 0.60
* @type : library * @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org/> * @copyright : pluie.org <http://www.pluie.org>
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
@ -23,10 +23,9 @@
* more details. * more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
*/
using GLib; using GLib;
using Gee; using Gee;
@ -39,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

View File

@ -1,12 +1,12 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.5 * @version : 0.60
* @type : library * @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org/> * @copyright : pluie.org <http://www.pluie.org>
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
@ -23,10 +23,9 @@
* more details. * more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
*/
using GLib; using GLib;
using Gee; using Gee;
@ -37,20 +36,23 @@ using Pluie;
*/ */
public class Pluie.Yaml.Loader public class Pluie.Yaml.Loader
{ {
/**
* Flag PACK_NESTED_ENTRIES
*/
public static bool PACK_NESTED_ENTRIES { public get; public set; default = false; }
/** /**
* Yaml.Scanner used to retriew yaml events * Yaml.Scanner used to retriew yaml events
*/ */
Yaml.Scanner scanner { public get; internal set; } Yaml.Scanner scanner { public get; internal set; }
/** /**
* indicate if file has been sucessfully loaded * indicate if file has been sucessfully loaded
*/ */
public bool done { get; internal set; } public bool done { get; internal set; }
/** /**
* Reader used to load content yaml file * Reader used to load content yaml file
*/ */
Io.Reader reader; Io.Reader reader;
/** /**
* default constructor of Yaml.Loader * default constructor of Yaml.Loader
@ -61,20 +63,22 @@ public class Pluie.Yaml.Loader
public Loader (string path, bool display_file = false, bool displayNode = false ) public Loader (string path, bool display_file = false, bool displayNode = false )
{ {
this.reader = new Io.Reader (path); this.reader = new Io.Reader (path);
this.scanner = new Yaml.Scanner (path); if (this.reader.readable) {
if (display_file) this.display_file (); this.scanner = new Yaml.Scanner (path);
if (display_file) this.display_file ();
if ((this.done = this.scanner.run())) { if ((this.done = this.scanner.run())) {
if (displayNode) { if (displayNode) {
var n = this.get_nodes (); var n = this.get_nodes ();
if (n != null) n.display_childs (); if (n != null) n.display_childs ();
of.state(n != null); of.state(n != null);
}
}
else {
var evt = this.scanner.get_error_event ();
of.error ("line %d (%s)".printf (evt.line, evt.data["error"]));
this.display_file (evt.line);
} }
}
else {
var evt = this.scanner.get_error_event ();
of.error ("line %d (%s)".printf (evt.line, evt.data["error"]));
this.display_file (evt.line);
} }
} }
@ -83,7 +87,33 @@ public class Pluie.Yaml.Loader
*/ */
public Yaml.Node? get_nodes () public Yaml.Node? get_nodes ()
{ {
return this.scanner.get_nodes (); Yaml.Node? n = this.scanner.get_nodes ();
if (PACK_NESTED_ENTRIES) {
this.pack_entries (n);
}
return n;
}
/**
*
*/
private void pack_entries (Yaml.Node? node = null)
{
bool restart = false;
if (node != null) {
if (node.ntype.is_sequence ()) {
foreach (var child in node) {
if (child.ntype.is_mapping () && child.name[0] == '_' && child.count () == 1) {
var sub = child.first ().clone_node ();
node.replace_node (child, sub);
restart = true;
break;
}
}
if (restart) pack_entries (node);
}
else foreach (var child in node) this.pack_entries (child);
}
} }
/** /**

View File

@ -1,12 +1,12 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.5 * @version : 0.60
* @type : library * @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org/> * @copyright : pluie.org <http://www.pluie.org>
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
@ -23,10 +23,9 @@
* more details. * more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
*/
using GLib; using GLib;
using Pluie; using Pluie;

View File

@ -1,12 +1,12 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.5 * @version : 0.60
* @type : library * @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org/> * @copyright : pluie.org <http://www.pluie.org>
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
@ -23,10 +23,10 @@
* more details. * more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
*/
using GLib; using GLib;
using Gee; using Gee;
@ -76,6 +76,8 @@ public class Pluie.Yaml.Node : Yaml.AbstractChild, Pluie.Yaml.Collection
} }
catch (Yaml.AddNodeError e) { catch (Yaml.AddNodeError e) {
of.warn (e.message); of.warn (e.message);
Yaml.dbg (this.to_string ());
this.display_childs ();
} }
return done; return done;
} }
@ -261,6 +263,21 @@ public class Pluie.Yaml.Node : Yaml.AbstractChild, Pluie.Yaml.Collection
return v; return v;
} }
/**
*
*/
public void replace_node (Yaml.Node child, Yaml.Node new_child)
{
int index = this.list.index_of (child);
if (index > -1) {
new_child.level = this.level + 1;
new_child.parent = this;
new_child.update_level ();
this.list.remove_at (index);
this.list.insert (index, new_child);
}
}
/** /**
* display childs * display childs
* @param withTitle display a title before the childs node presentation * @param withTitle display a title before the childs node presentation
@ -326,7 +343,7 @@ public class Pluie.Yaml.Node : Yaml.AbstractChild, Pluie.Yaml.Collection
) )
: "", : "",
of.c (ECHO.OPTION).s ("]"), of.c (ECHO.OPTION).s ("]"),
withTag && this.ntype.is_root () ? (this as Yaml.Root).get_display_tag_directives () : "" withTag && this.ntype.is_root () && (this as Yaml.Root) !=null ? (this as Yaml.Root).get_display_tag_directives () : ""
); );
} }
} }

View File

@ -1,12 +1,12 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.5 * @version : 0.60
* @type : library * @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org/> * @copyright : pluie.org <http://www.pluie.org>
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
@ -23,10 +23,10 @@
* more details. * more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
*/
using GLib; using GLib;
using Gee; using Gee;
@ -127,18 +127,53 @@ public abstract class Pluie.Yaml.Object : GLib.Object
*/ */
public static Yaml.Node? objects_collection_to_node (Gee.Collection list, string name, Yaml.Node? parent = null) public static Yaml.Node? objects_collection_to_node (Gee.Collection list, string name, Yaml.Node? parent = null)
{ {
of.echo (Log.METHOD);
var node = new Yaml.Sequence (parent, name); var node = new Yaml.Sequence (parent, name);
node.tag = new Yaml.Tag (Yaml.Register.resolve_namespace_type(list.get_type ()), "v"); node.tag = new Yaml.Tag (Yaml.Register.resolve_namespace_type(list.get_type ()), "v");
var it = list.iterator (); var it = list.iterator ();
var i = 0; var i = 0;
while (it.next ()) { while (it.next ()) {
Yaml.Builder.to_node ( Yaml.Builder.to_node ((GLib.Object) it.get (), node, false, i++);
(GLib.Object) it.get (), }
node, return node;
false, }
i++
); /**
* build an object Gee.HashMap<string, Yaml.Object> to a Yaml.Node
* @param map the gee hashmap to transform
* @param name name of map sequence node
* @param parent parent node of the map
* @return the resulting Yaml.Node
*/
public static Yaml.Node? objects_mapkstr_to_node (Gee.HashMap map, string name, Yaml.Node? parent = null)
{
var node = new Yaml.Sequence (parent, name);
node.tag = new Yaml.Tag (Yaml.Register.resolve_namespace_type(map.get_type ()), "v");
var i = 0;
foreach (var child in map.entries) {
var entryNode = new Yaml.Mapping (node, "_%d".printf (i++));
new Yaml.Mapping.with_scalar (entryNode, "key", (string) child.key);
Yaml.Builder.to_node ((GLib.Object) child.value, entryNode, false, null, "val");
}
return node;
}
/**
* build an object Gee.HashMap<string, Yaml.Object> to a Yaml.Node
* @param map the gee hashmap to transform
* @param name name of map sequence node
* @param parent parent node of the map
* @return the resulting Yaml.Node
*/
public static Yaml.Node? objects_mapobjects_to_node (Gee.HashMap map, string name, Yaml.Node? parent = null)
{
var node = new Yaml.Sequence (parent, name);
node.tag = new Yaml.Tag (Yaml.Register.resolve_namespace_type(map.get_type ()), "v");
var i = 0;
foreach (var child in map.entries) {
var entryNode = new Yaml.Mapping (node, "_%d".printf (i++));
Yaml.Builder.to_node ((GLib.Object) child.key, entryNode, false, null, "key");
Yaml.Builder.to_node ((GLib.Object) child.value, entryNode, false, null, "val");
} }
return node; return node;
} }

View File

@ -1,12 +1,12 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.5 * @version : 0.60
* @type : library * @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org/> * @copyright : pluie.org <http://www.pluie.org>
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
@ -23,10 +23,9 @@
* more details. * more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
*/
using GLib; using GLib;
using Gee; using Gee;
@ -47,6 +46,21 @@ public class Pluie.Yaml.Processor
*/ */
bool change; bool change;
/**
* indicates if document start begin
*/
bool begin;
/**
* indicates if new node is a sequence entry
*/
bool isEntry;
/**
* indicates if new node is a sequence entry mapping
*/
bool isEntryMapping;
/** /**
* indicates if begon a flow sequence * indicates if begon a flow sequence
*/ */
@ -175,7 +189,7 @@ public class Pluie.Yaml.Processor
this.reset (); this.reset ();
for (var has_next = this.iterator.next (); has_next; has_next = this.iterator.next ()) { for (var has_next = this.iterator.next (); has_next; has_next = this.iterator.next ()) {
this.event = this.iterator.get (); this.event = this.iterator.get ();
Yaml.dbg (" 0>>>>> [EVENT event [%d] %s <<<<< %s".printf (this.indexEvt++, this.event.evtype.infos (), Log.METHOD)); Yaml.dbg (" [[[ EVENT %d %s ]]]".printf (this.indexEvt++, this.event.evtype.infos ()));
if (this.event.evtype.is_tag_directive ()) { if (this.event.evtype.is_tag_directive ()) {
this.on_tag_directive (); this.on_tag_directive ();
} }
@ -183,34 +197,54 @@ public class Pluie.Yaml.Processor
this.on_error (); this.on_error ();
break; break;
} }
if (this.event.evtype.is_mapping_end () || this.event.evtype.is_sequence_end ()) { if (!this.begin) {
this.on_block_end (); if (this.event.evtype.is_sequence_start () || this.event.evtype.is_mapping_start ()) {
continue; this.begin = true;
} continue;
if (this.event.evtype.is_entry ()) { }
this.on_entry (); else if (this.event.evtype.is_document_start ()) {
} this.begin = true;
if (this.beginFlowSeq && this.event.evtype.is_scalar ()) { // to do
if (!this.change) { this.event = this.next_event ();
this.on_scalar (true); if (this.event.evtype.is_tag ()) {
this.root.tag = new Yaml.Tag (this.event.data["suffix"], this.event.data["handle"].replace("!", ""));
this.event = this.next_event ();
}
continue;
} }
this.beginFlowSeq = false;
} }
if (this.event.evtype.is_key () && (this.event = this.get_value_key_event ()) != null) { else {
this.on_key (); if (this.event.evtype.is_anchor ()) {
} this.on_anchor ();
if (this.event.evtype.is_value () && (this.event = this.get_value_event ()) != null) { }
this.on_value (); else if (this.event.evtype.is_alias ()) {
if (this.event.evtype.is_mapping_start ()) { this.on_alias ();
this.on_mapping_start (); }
else if (this.event.evtype.is_mapping_end () || this.event.evtype.is_sequence_end ()) {
this.on_block_end ();
continue;
}
else if (this.event.evtype.is_key () && (this.event = this.get_value_key_event ()) != null) {
this.on_key ();
}
else if (this.event.evtype.is_entry ()) {
this.on_entry ();
}
else if (this.event.evtype.is_mapping_start ()) {
this.create_mapping (this.isEntry);
} }
else if (this.event.evtype.is_sequence_start ()) { else if (this.event.evtype.is_sequence_start ()) {
this.on_sequence_start (); this.on_sequence_start ();
} }
else if (this.event.evtype.is_value ()) {
continue;
}
else if (this.event.evtype.is_scalar ()) {
this.on_scalar ();
}
this.add_anchor_if_needed (); this.add_anchor_if_needed ();
this.ckey = null; this.on_update ();
} }
this.on_update ();
} }
this.done = error_event == null && this.root != null; this.done = error_event == null && this.root != null;
return done; return done;
@ -221,19 +255,22 @@ public class Pluie.Yaml.Processor
*/ */
private void reset () private void reset ()
{ {
this.root = new Yaml.Root (); this.root = new Yaml.Root ();
this.prev_node = this.root; this.prev_node = this.root;
this.parent_node = this.root; this.parent_node = this.root;
this.iterator = this.events.iterator (); this.iterator = this.events.iterator ();
this.change = false; this.change = false;
this.ckey = null; this.ckey = null;
this.idAnchor = null; this.idAnchor = null;
this.tagHandle = null; this.tagHandle = null;
this.keyTag = null; this.keyTag = null;
this.valueTag = null; this.valueTag = null;
this.beginFlowSeq = false; this.beginFlowSeq = false;
this.nextValueEvt = null; this.nextValueEvt = null;
this.indexEvt = 0; this.indexEvt = 0;
this.isEntry = false;
this.begin = false;
this.isEntryMapping = false;
} }
/** /**
@ -244,7 +281,20 @@ public class Pluie.Yaml.Processor
Yaml.Event? evt = null; Yaml.Event? evt = null;
if (this.iterator.has_next () && this.iterator.next ()) { if (this.iterator.has_next () && this.iterator.next ()) {
evt = this.iterator.get (); evt = this.iterator.get ();
Yaml.dbg (" 1>>>>> [EVENT event [%d] %s <<<<< %s".printf (this.indexEvt++, evt.evtype.infos (), Log.METHOD)); Yaml.dbg (" >>>>> [EVENT event [%d] %s <<<<< %s".printf (this.indexEvt++, evt.evtype.infos (), Log.METHOD));
}
return evt;
}
/**
* retriew the next Yaml Event without use of iterator
*/
private Yaml.Event? get_next_event ()
{
Yaml.Event? evt = null;
var i = this.indexEvt;
if (i < this.events.size) {
evt = this.events.get (i);
} }
return evt; return evt;
} }
@ -282,13 +332,15 @@ public class Pluie.Yaml.Processor
private Yaml.Event? get_next_value_event () private Yaml.Event? get_next_value_event ()
{ {
Yaml.Event? evt = null; Yaml.Event? evt = null;
var i = this.indexEvt+1; var i = this.indexEvt;
Yaml.dbg (" >>> %s from %d".printf (Log.METHOD, i));
var search = true; var search = true;
while (search) { while (search) {
if (i < this.events.size) { if (i < this.events.size) {
var e = this.events.get (i++); var e = this.events.get (i++);
if (e != null && e.evtype.is_value ()) { if (e != null && e.evtype.is_value ()) {
evt = this.events.get (i); evt = this.events.get (i);
Yaml.dbg (" >>> %s > %d : %s".printf (Log.METHOD, i, evt.evtype.infos ()));
break; break;
} }
} }
@ -328,22 +380,13 @@ public class Pluie.Yaml.Processor
*/ */
private void on_block_end () private void on_block_end ()
{ {
if (!this.prev_node.ntype.is_collection ()) { if (this.prev_node.ntype.is_scalar () || (this.prev_node.ntype.is_single_pair () && this.prev_node.parent != null && this.prev_node.parent.ntype.is_mapping ())) {
this.prev_node = this.prev_node.parent; this.prev_node = this.prev_node.parent;
} }
bool is_nested = this.is_entry_nested_block (this.prev_node); this.parent_node = this.prev_node.parent != null && this.prev_node.parent != this.root
if (!is_nested || (is_nested && (this.prev_node as Yaml.Sequence).close_block)) {
this.parent_node = this.prev_node.parent != null && this.prev_node.parent != this.root
? this.prev_node.parent ? this.prev_node.parent
: this.root; : this.root;
this.prev_node = this.parent_node; this.prev_node = this.parent_node;
}
if (is_nested) {
var seq = this.prev_node as Yaml.Sequence;
if (seq != null) {
seq.close_block = true;
}
}
} }
/** /**
@ -351,15 +394,13 @@ public class Pluie.Yaml.Processor
*/ */
private void on_entry () private void on_entry ()
{ {
this.event = this.next_event(); this.isEntry = true;
Yaml.Event? e = null; this.ckey = null;
// look up for sequence enrty nested block var e = this.get_next_event ();
e = get_next_value_event (); if (e!= null && e.evtype.is_mapping_start ()) {
if (this.event.evtype.is_mapping_start () && (e!= null && !e.evtype.is_mapping_start ())) { this.isEntryMapping = true;
this.on_mapping_start (true); this.create_mapping (true);
} this.next_event ();
else if (this.event.evtype.is_scalar ()) {
this.on_scalar (true);
} }
} }
@ -391,23 +432,9 @@ public class Pluie.Yaml.Processor
private void on_key () private void on_key ()
{ {
this.on_tag (true); this.on_tag (true);
this.ckey = this.event.data["data"];
}
/**
*
*/
private void on_value ()
{
this.on_tag (false);
if (this.event.evtype.is_scalar ()) { if (this.event.evtype.is_scalar ()) {
this.on_scalar (); this.ckey = this.event.data["data"];
} Yaml.dbg (" >> node name : %s".printf (this.ckey));
else if (this.event.evtype.is_anchor ()) {
this.on_anchor ();
}
else if (this.event.evtype.is_alias ()) {
this.on_alias ();
} }
} }
@ -416,16 +443,13 @@ public class Pluie.Yaml.Processor
*/ */
private void on_scalar (bool entry = false) private void on_scalar (bool entry = false)
{ {
if (!entry) { if (this.ckey != null && this.parent_node.ntype.is_collection ()) {
if (this.ckey != null) { this.node = new Yaml.Mapping.with_scalar (this.parent_node, this.ckey, this.event.data["data"]);
this.node = new Yaml.Mapping.with_scalar (this.parent_node, this.ckey, this.event.data["data"]);
this.change = true;
}
} }
else { else {
this.node = new Yaml.Scalar (this.parent_node, this.event.data["data"]); this.node = new Yaml.Scalar (this.parent_node, this.event.data["data"]);
this.change = true;
} }
this.change = true;
} }
/** /**
@ -433,8 +457,9 @@ public class Pluie.Yaml.Processor
*/ */
private void on_anchor () private void on_anchor ()
{ {
this.idAnchor = this.event.data["id"]; if (this.event.data != null) {
this.event = this.next_event (); this.idAnchor = this.event.data["id"];
}
} }
/** /**
@ -442,12 +467,14 @@ public class Pluie.Yaml.Processor
*/ */
private void on_alias () private void on_alias ()
{ {
this.idAnchor = this.event.data["id"]; if (this.event.data != null) {
Yaml.Node? refnode = this.anchors.get(this.idAnchor); this.idAnchor = this.event.data["id"];
if (refnode != null) { Yaml.Node? refnode = this.anchors.get(this.idAnchor);
this.node = refnode.clone_node (this.ckey); if (refnode != null) {
this.parent_node.add (this.node); this.node = refnode.clone_node (this.ckey);
this.prev_node = this.node; this.parent_node.add (this.node);
this.prev_node = this.node;
}
} }
} }
@ -458,7 +485,6 @@ public class Pluie.Yaml.Processor
{ {
this.node = new Yaml.Sequence (this.parent_node, this.ckey); this.node = new Yaml.Sequence (this.parent_node, this.ckey);
this.change = true; this.change = true;
this.beginFlowSeq = true;
} }
/** /**
@ -466,11 +492,24 @@ public class Pluie.Yaml.Processor
*/ */
private void on_mapping_start (bool entry = false) private void on_mapping_start (bool entry = false)
{ {
if (entry) { this.ckey = null;
this.create_mapping (entry); this.event = this.next_event ();
this.ckey = null; if (this.event.evtype.is_key ()) {
this.event = this.next_event ();
this.on_tag (true);
if (this.event.evtype.is_scalar ()) {
this.ckey = this.event.data["data"];
}
var e = this.get_next_value_event();
if (e!=null) {
if ( e.evtype.is_sequence_start ()) {
this.on_sequence_start ();
}
else {
this.create_mapping (this.isEntry);
}
}
} }
else this.create_mapping ();
} }
/** /**
@ -478,7 +517,7 @@ public class Pluie.Yaml.Processor
*/ */
private void create_mapping (bool entry = false) private void create_mapping (bool entry = false)
{ {
if (entry) { if (entry && this.ckey == null) {
this.ckey = "_%d".printf(this.parent_node.count()); this.ckey = "_%d".printf(this.parent_node.count());
} }
this.node = new Yaml.Mapping (this.parent_node, this.ckey); this.node = new Yaml.Mapping (this.parent_node, this.ckey);
@ -490,10 +529,8 @@ public class Pluie.Yaml.Processor
*/ */
private void add_anchor_if_needed () private void add_anchor_if_needed ()
{ {
if (this.idAnchor != null) { if (this.idAnchor != null && this.node != null) {
if (this.node != null) { this.anchors.set(this.idAnchor, this.node);
this.anchors.set(this.idAnchor, this.node);
}
this.idAnchor = null; this.idAnchor = null;
} }
} }
@ -504,7 +541,10 @@ public class Pluie.Yaml.Processor
private void on_update () private void on_update ()
{ {
if (this.node != null) { if (this.node != null) {
Yaml.dbg (Log.METHOD);
Yaml.dbg (this.node.name); Yaml.dbg (this.node.name);
Yaml.dbg (this.node.ntype.infos ());
Yaml.dbg ("anchor ? %s".printf (this.idAnchor));
} }
if (this.change) { if (this.change) {
if (this.node.parent.ntype.is_sequence ()) { if (this.node.parent.ntype.is_sequence ()) {
@ -535,7 +575,10 @@ public class Pluie.Yaml.Processor
this.keyTag = null; this.keyTag = null;
this.valueTag = null; this.valueTag = null;
this.node = null; this.node = null;
this.isEntryMapping = false;
this.change = false; this.change = false;
this.isEntry = false;
this.ckey = null;
} }
} }

View File

@ -1,12 +1,12 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.5 * @version : 0.60
* @type : library * @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org/> * @copyright : pluie.org <http://www.pluie.org>
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
@ -23,10 +23,9 @@
* more details. * more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
*/
using GLib; using GLib;
using Pluie; using Pluie;

View File

@ -1,12 +1,12 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.5 * @version : 0.60
* @type : library * @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org/> * @copyright : pluie.org <http://www.pluie.org>
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
@ -23,10 +23,9 @@
* more details. * more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
*/
using GLib; using GLib;
using Pluie; using Pluie;

View File

@ -1,12 +1,12 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.5 * @version : 0.60
* @type : library * @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org/> * @copyright : pluie.org <http://www.pluie.org>
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
@ -23,10 +23,9 @@
* more details. * more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
*/
using GLib; using GLib;
using Pluie; using Pluie;

View File

@ -1,12 +1,12 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.5 * @version : 0.60
* @type : library * @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org/> * @copyright : pluie.org <http://www.pluie.org>
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
@ -23,10 +23,9 @@
* more details. * more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
*/
using GLib; using GLib;
using Gee; using Gee;

View File

@ -1,12 +1,12 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.5 * @version : 0.60
* @type : library * @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org/> * @copyright : pluie.org <http://www.pluie.org>
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
@ -23,10 +23,9 @@
* more details. * more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
*/
using GLib; using GLib;
using Pluie; using Pluie;

View File

@ -1,12 +1,12 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.5 * @version : 0.60
* @type : library * @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org/> * @copyright : pluie.org <http://www.pluie.org>
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
@ -23,10 +23,10 @@
* more details. * more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
*/
using GLib; using GLib;
using Gee; using Gee;

View File

@ -1,12 +1,12 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.5 * @version : 0.60
* @type : library * @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org/> * @copyright : pluie.org <http://www.pluie.org>
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
@ -23,424 +23,439 @@
* more details. * more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
*/
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 * serialize an object as a yaml compressed document data
*/ * @param obj the object to serialize
public errordomain AddNodeError * @param dest path destination if you want to write to a file
{ */
MAPPING_CONTAINS_CHILD, public static uint8[] serialize (GLib.Object? obj, string? dest = null)
MAPPING_IS_SINGLE_PAIR, {
MAPPING_NOT_SINGLE_PAIR 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);
private const ZlibCompressorFormat ZFORMAT = ZlibCompressorFormat.GZIP; if (node != null) {
var content = node.to_yaml_string ();
/**
*
*/
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;
}
/**
* deserialize yaml compressed document data to a Yaml.Object
* @param zdata the data to deserialized
*/
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;
}
/**
* @return event is document start event
*/
public bool is_document_start ()
{
return this == EVT.DOCUMENT_START;
}
/**
* @return event is stream start event
*/
public bool is_stream_start ()
{
return this == EVT.STREAM_START;
}
}
/**
* 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 a universal unique identifier (type 4)
*/
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)
);
}
} }

68
src/vala/install.vala.in Normal file
View File

@ -0,0 +1,68 @@
/*^* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.56
* @type : library
* @date : 2018
* @license : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]>
* @copyright : pluie.org <http://www.pluie.org>
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* This file is part of pluie-yaml.
*
* pluie-yaml is free software (free as in speech) : you can redistribute it
* and/or modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* pluie-yaml is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *^*/
/**
* root namespace of various Pluie lib
*/
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
{
protected const string INSTALL_PATH = "@INSTALL_PATH@";
public const string DATA_PATH = "@DATA_PATH@";
public const string VERSION = "@VERSION@";
}
}

View File

@ -1,13 +1,13 @@
#!/bin/bash #!/bin/bash
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #^# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml> # @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
# @version : 0.5 # @version : 0.60
# @type : library # @type : library
# @date : 2018 # @date : 2018
# @licence : GPLv3.0 <http://www.gnu.org/licenses/> # @license : GPLv3.0 <http://www.gnu.org/licenses/>
# @author : a-Sansara <[dev]at[pluie]dot[org]> # @author : a-Sansara <[dev]at[pluie]dot[org]>
# @copyright : pluie.org <http://www.pluie.org/> # @copyright : pluie.org <http://www.pluie.org>
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
@ -18,22 +18,31 @@
# published by the Free Software Foundation, either version 3 of the License, # published by the Free Software Foundation, either version 3 of the License,
# or (at your option) any later version. # or (at your option) any later version.
# #
# lib-yaml is distributed in the hope that it will be useful, but WITHOUT # pluie-yaml is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details. # more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>. # along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #^#
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
lib="pluie-yaml-0.5" lib="pluie-yaml-0.6"
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 ./build/install.vala
rm doc/*.png if [ $? -eq 0 ]; then
cp resources/doc-scripts.js ./doc/scripts.js rm doc/*.png
cp resources/doc-style.css ./doc/style.css cp resources/doc-scripts.js ./doc/scripts.js
rm $lib.tar.gz cp resources/doc-style.css ./doc/style.css
tar -czvf $lib.tar.gz doc/ if [ -f "./docfix" ]; then
./docfix
if [ $? -eq 0 ]; then
rm $lib.tar.gz
tar -czvf $lib.tar.gz doc/
scp $lib.tar.gz pluie@pluie.org:/home/pluie/
ssh pluie@pluie.org "./updatedoc.sh $lib"
fi
fi
fi