Merge branch 'tag-impl' of pluie/lib-yaml into master

This commit is contained in:
a-sansara 2018-08-18 23:26:49 +00:00 committed by Gogs
commit 6c6d8db513
40 changed files with 969 additions and 447 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
build/ build/
bin/ bin/
doc/ doc/
pluie-yaml-*.tar.gz

115
README.md
View File

@ -17,7 +17,26 @@ The lib partially manage tag directives and tag values (basic types and Yaml.Obj
_legend display_childs_ : _legend display_childs_ :
``` ```
[ node.name [refCount] node.parent.name node.level node.ntype.infos () node.count () node.uuid ] [ node.name [refCount] node.parent.name node.level node.ntype.infos () node.count () node.uuid node.tag]
```
You can easily manage display tracing of yaml nodes by setting these var according to your needs :
```vala
namespace Pluie
{
namespace Yaml
{
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;
``` ```
## License ## License
@ -46,23 +65,24 @@ sudo ninja install -C build
valac --pkg pluie-echo-0.2 --pkg pluie-yaml-0.4 main.vala valac --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
## Api / Documentation ## Api / Documentation
https://pluie.org/pluie-yaml-0.4/index.htm https://pluie.org/pluie-yaml-0.5/index.htm
## Docker ## Docker
a demo image is now available on docker hub. To run a container : A demo image is now available on docker hub. To run a container :
``` ```
docker run --rm -it pluie/libyaml docker run --rm -it pluie/libyaml
``` ```
then you can execute any samples, for example : Then you can execute any samples, for example :
``` ```
./json-loader ./json-loader
``` ```
@ -125,7 +145,7 @@ load a single document.
```vala ```vala
var path = "./config/main.yml"; var path = "./config/main.yml";
// uncomment to enable debug // uncomment to enable debug
// Pluie.Yaml.Scanner.DEBUG = true; // Pluie.Yaml.DEBUG = true;
var loader = new Yaml.Loader (path /* , displayFile, displayNode */); var loader = new Yaml.Loader (path /* , displayFile, displayNode */);
if ((done = loader.done)) { if ((done = loader.done)) {
Yaml.Node root = loader.get_nodes (); Yaml.Node root = loader.get_nodes ();
@ -136,7 +156,7 @@ load a single document.
### finder ### finder
**lib-yaml** provide a `Yaml.Finder` to easily retriew a particular yaml node. **pluie-yaml** provide a `Yaml.Finder` to easily retriew a particular yaml node.
Search path definition has two mode. Search path definition has two mode.
The default mode is `Yaml.FIND_MODE.DOT` The default mode is `Yaml.FIND_MODE.DOT`
- child mapping node are separated by dot - child mapping node are separated by dot
@ -259,31 +279,100 @@ on yaml side, proceed like that :
type_uint : !v!uint 62005 type_uint : !v!uint 62005
type_float : !v!float 42.36 type_float : !v!float 42.36
type_double : !v!double 95542123.4579512128 type_double : !v!double 95542123.4579512128
!v!Pluie.Yaml.SubExample type_object : type_enum : !v!Pluie.Yaml.NODE_TYPE scalar # or int
!v!Pluie.Yaml.ExampleChild type_object :
toto : totovalue1 toto : totovalue1
tata : tatavalue1 tata : tatavalue1
titi : 123 titi : 123
tutu : 1 tutu : 1
!v!Pluie.Yaml.ExampleStruct type_struct :
red : !v!uint8 214
green : !v!uint8 78
blue : 153
!v!Gee.ArrayList type_gee_al :
- ab_1
- ab_2
- ab_3
- ab_4
``` ```
**note :**
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.
So basic vala types tag, enum tag, struct tag and derived Yaml.Object (here ExampleChild)
or GLib.Object vala tags are not necessary inside a Yaml.Object.
on vala side : on vala side :
```vala ```vala
... ...
Yaml.Example obj = (Yaml.Example) Yaml.Object.from_node (root.first ()); var obj = (Yaml.Example) Yaml.Builder.from_node (root.first ());
of.echo("obj.type_int : %d".printf (o.type_int)); of.echo("obj.type_int : %d".printf (obj.type_int));
// calling ExampleChild method
obj.type_object.method_a () obj.type_object.method_a ()
``` ```
![pluie-yaml-tag](https://www.meta-tech.academy/img/libyaml-tag-ex.png) ![pluie-yaml-tag](https://www.meta-tech.academy/img/pluie-yaml-tag-directives-yaml-node.png?tmp=2)
### Builder
**pluie-yaml** provide a Yaml.Builder which has automatic mechanisms to build Yaml.Object instances (and derived classes)
and set basics types properties, enum properties and based Yaml.Object properties from Yaml.node.
Other types like struct or native GLib.Object (Gee.ArrayList for example) properties need some stuff in order to be populated appropriately
We cannot do introspection on Structure's properties, so you need to implement a method which will do the job.
First at all, in the static construct of your class, you need to register (properties) types that need some glue for instanciation.
```vala
public class Example : Yaml.Object
{
static construct
{
Yaml.Object.register.add_type (typeof (Example), typeof (ExampleStruct));
Yaml.Object.register.add_type (typeof (Example), typeof (Gee.ArrayList));
}
...
```
Secondly you must override the `Yaml.Object populate_by_type (Glib.Type, Yaml.Node node)` original method.
`populate_by_type` is called by the Yaml.Builder only if the type property is prealably registered.
Example of implementation from `src/vala/Pluie/Yaml.Example.vala` :
```vala
public override void populate_by_type(GLib.Type type, Yaml.Node node)
{
if (type == typeof (Yaml.ExampleStruct)) {
this.type_struct = ExampleStruct.from_yaml_node (node);
}
else if (type == typeof (Gee.ArrayList)) {
this.type_gee_al = new Gee.ArrayList<string> ();
if (!node.empty ()) {
foreach (var child in node) {
this.type_gee_al.add(child.data);
}
}
}
}
```
Once your class has this glue, you can deal with complex object and populate them
directly from yaml files.
for more details see :
* `src/vala/Pluie/Yaml.Example.vala`
* `src/vala/Pluie/Yaml.ExampleChild.vala`
* `src/vala/Pluie/Yaml.ExampleStruct.vala`
* `samples/yaml-tag.vala`
code from samples/yaml-tag.vala : code from samples/yaml-tag.vala :
![pluie-yaml-tag](https://www.meta-tech.academy/img/libyaml-tag-code.png) ![pluie-yaml-tag](https://www.meta-tech.academy/img/pluie-yaml-sample-tag-code.png)
output from samples/yaml-tag.vala : output from samples/yaml-tag.vala :
![pluie-yaml-tag](https://www.meta-tech.academy/img/libyaml-tag-ex2.png) ![pluie-yaml-tag](https://www.meta-tech.academy/img/pluie-yaml-sample-tag-output.png?tmp=53)
------------------- -------------------

View File

@ -1,8 +1,9 @@
#!/bin/bash #!/bin/bash
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml> # @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
# @version : 0.4 # @version : 0.5
# @type : library
# @date : 2018 # @date : 2018
# @licence : GPLv3.0 <http://www.gnu.org/licenses/> # @licence : GPLv3.0 <http://www.gnu.org/licenses/>
# @author : a-Sansara <[dev]at[pluie]dot[org]> # @author : a-Sansara <[dev]at[pluie]dot[org]>
@ -10,9 +11,9 @@
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# This file is part of lib-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,14 +24,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 lib-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.4" lib="pluie-yaml-0.5"
c1="\033[1;38;5;215m" c1="\033[1;38;5;215m"
c2="\033[1;38;5;97m" c2="\033[1;38;5;97m"
cok="\033[1;38;5;37m" cok="\033[1;38;5;37m"

View File

@ -1,7 +1,8 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.4 * @version : 0.5
* @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
@ -9,20 +10,20 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* This file is part of lib-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.
* *
* 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 lib-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/ */

View File

@ -1,7 +1,8 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml> # @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
# @version : 0.4 # @version : 0.5
# @type : library
# @date : 2018 # @date : 2018
# @licence : GPLv3.0 <http://www.gnu.org/licenses/> # @licence : GPLv3.0 <http://www.gnu.org/licenses/>
# @author : a-Sansara <[dev]at[pluie]dot[org]> # @author : a-Sansara <[dev]at[pluie]dot[org]>
@ -9,24 +10,24 @@
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# This file is part of lib-yaml. # This file is part of pluie-yaml.
# #
# lib-yaml is free software (free as in speech) : you can redistribute it # lib-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.
# #
# 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 lib-yaml. If not, see <http://www.gnu.org/licenses/>. # along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
project('libpluie-yaml', 'vala', 'c', version:'0.4') project('libpluie-yaml', 'vala', 'c', version:'0.5')
cc = meson.get_compiler('c') cc = meson.get_compiler('c')
dep_glib = dependency('glib-2.0') dep_glib = dependency('glib-2.0')
@ -40,7 +41,7 @@ dep_yaml = cc.find_library('yaml', required : true)
#~ add_global_link_arguments('-lyaml', language : 'c') #~ add_global_link_arguments('-lyaml', language : 'c')
version = '0.4' version = '0.5'
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')
@ -64,21 +65,24 @@ sources = [
'src/vala/Pluie/Yaml.global.vala', 'src/vala/Pluie/Yaml.global.vala',
'src/vala/Pluie/Yaml.AbstractChild.vala', 'src/vala/Pluie/Yaml.AbstractChild.vala',
'src/vala/Pluie/Yaml.AbstractNode.vala', 'src/vala/Pluie/Yaml.AbstractNode.vala',
'src/vala/Pluie/Yaml.Builder.vala',
'src/vala/Pluie/Yaml.Collection.vala', 'src/vala/Pluie/Yaml.Collection.vala',
'src/vala/Pluie/Yaml.Config.vala', 'src/vala/Pluie/Yaml.Config.vala',
'src/vala/Pluie/Yaml.Event.vala', 'src/vala/Pluie/Yaml.Event.vala',
'src/vala/Pluie/Yaml.Example.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.Finder.vala',
'src/vala/Pluie/Yaml.Loader.vala', 'src/vala/Pluie/Yaml.Loader.vala',
'src/vala/Pluie/Yaml.Mapping.vala', 'src/vala/Pluie/Yaml.Mapping.vala',
'src/vala/Pluie/Yaml.Node.vala', 'src/vala/Pluie/Yaml.Node.vala',
'src/vala/Pluie/Yaml.Object.vala', 'src/vala/Pluie/Yaml.Object.vala',
'src/vala/Pluie/Yaml.Processor.vala', 'src/vala/Pluie/Yaml.Processor.vala',
'src/vala/Pluie/Yaml.Register.vala',
'src/vala/Pluie/Yaml.Root.vala', 'src/vala/Pluie/Yaml.Root.vala',
'src/vala/Pluie/Yaml.Scalar.vala', 'src/vala/Pluie/Yaml.Scalar.vala',
'src/vala/Pluie/Yaml.Scanner.vala', 'src/vala/Pluie/Yaml.Scanner.vala',
'src/vala/Pluie/Yaml.Sequence.vala', 'src/vala/Pluie/Yaml.Sequence.vala',
'src/vala/Pluie/Yaml.SubExample.vala',
'src/vala/Pluie/Yaml.Tag.vala', 'src/vala/Pluie/Yaml.Tag.vala',
'src/c/yaml.c' 'src/c/yaml.c'
] ]

View File

@ -1,5 +1,4 @@
%YAML 1.2 %YAML 1.2
%TAG !yaml! tag:yaml.org,2002:
%TAG !v! tag:pluie.org,2018:vala/ %TAG !v! tag:pluie.org,2018:vala/
--- ---
!v!Pluie.Yaml.Example test1 : !v!Pluie.Yaml.Example test1 :
@ -12,11 +11,21 @@
type_uint : !v!uint 62005 type_uint : !v!uint 62005
type_float : !v!float 42.36 type_float : !v!float 42.36
type_double : !v!double 95542123.4579512128 type_double : !v!double 95542123.4579512128
!v!Pluie.Yaml.SubExample type_object : type_enum : !v!Pluie.Yaml.NODE_TYPE scalar # or int
!v!Pluie.Yaml.ExampleChild type_object :
toto : totovalue1 toto : totovalue1
tata : tatavalue1 tata : tatavalue1
titi : 123 titi : 123
tutu : 1 tutu : 1
!v!Pluie.Yaml.ExampleStruct type_struct :
red : !v!uint8 214
green : !v!uint8 78
blue : 153
!v!Gee.ArrayList type_gee_al :
- ab_1
- ab_2
- ab_3
- ab_4
!v!Pluie.Yaml.Example test2 : !v!Pluie.Yaml.Example test2 :
myname : test2object myname : test2object
@ -28,7 +37,8 @@
type_uint : 63005 type_uint : 63005
type_float : 5.28 type_float : 5.28
type_double : 9.28 type_double : 9.28
!v!Pluie.Yaml.SubExample type_object : type_enum : PLUIE_YAML_NODE_TYPE_SCALAR
!v!Pluie.Yaml.ExampleChild type_object :
toto : totovalue2 toto : totovalue2
tata : tatavalue2 tata : tatavalue2
titi : !v!int 456 titi : !v!int 456

View File

@ -1,7 +1,8 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.4 * @version : 0.5
* @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
@ -9,20 +10,20 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* This file is part of lib-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.
* *
* 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 lib-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/ */
@ -39,7 +40,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.Scanner.DEBUG = false; Pluie.Yaml.DEBUG = false;
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 ();

View File

@ -1,7 +1,8 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.4 * @version : 0.5
* @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
@ -9,20 +10,20 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* This file is part of lib-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.
* *
* 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 lib-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/ */
@ -39,7 +40,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.Scanner.DEBUG = false; Pluie.Yaml.DEBUG = false;
var config = new Yaml.Config (path, true); var config = new Yaml.Config (path, true);
var spath = "bo.host{0}"; var spath = "bo.host{0}";
var root = config.root_node (); var root = config.root_node ();

View File

@ -1,7 +1,8 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.4 * @version : 0.5
* @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
@ -9,20 +10,20 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* This file is part of lib-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.
* *
* 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 lib-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/ */
@ -39,7 +40,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.Scanner.DEBUG = false; //~ Pluie.Yaml.DEBUG = false;
var loader = new Yaml.Loader (path, true); var loader = new Yaml.Loader (path, true);
if ((done = loader.done)) { if ((done = loader.done)) {
Yaml.Node root = loader.get_nodes (); Yaml.Node root = loader.get_nodes ();

View File

@ -1,7 +1,8 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.4 * @version : 0.5
* @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
@ -9,24 +10,25 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* This file is part of lib-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.
* *
* 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 lib-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;
@ -40,7 +42,7 @@ int main (string[] args)
of.title ("Pluie Yaml Library", Pluie.Yaml.VERSION, "a-sansara"); of.title ("Pluie Yaml Library", Pluie.Yaml.VERSION, "a-sansara");
Pluie.Yaml.Scanner.DEBUG = false; Pluie.Yaml.DEBUG = false;
var config = new Yaml.Config (path, true); var config = new Yaml.Config (path, true);
var spath = "^imports"; var spath = "^imports";
var node = config.get (spath); var node = config.get (spath);

View File

@ -1,7 +1,8 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.4 * @version : 0.5
* @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
@ -9,24 +10,25 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* This file is part of lib-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.
* *
* 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 lib-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;
@ -39,7 +41,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.Scanner.DEBUG = false; Pluie.Yaml.DEBUG = false;
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 ();

View File

@ -1,7 +1,8 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.4 * @version : 0.5
* @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
@ -9,24 +10,25 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* This file is part of lib-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.
* *
* 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 lib-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;

View File

@ -1,7 +1,8 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.4 * @version : 0.5
* @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
@ -9,24 +10,25 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* This file is part of lib-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.
* *
* 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 lib-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;
@ -39,18 +41,17 @@ 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.Scanner.DEBUG = false; Pluie.Yaml.DEBUG = false;
Yaml.Object? obj = null; Yaml.Object? obj = null;
var config = new Yaml.Config (path, true); var config = new Yaml.Config (path, true);
var root = config.root_node (); var root = config.root_node ();
root.display_childs (); root.display_childs ();
// define a map with base Yaml.Object type rather than target type var list = new Gee.HashMap<string, Yaml.Object> ();
Gee.HashMap<string, Yaml.Object> list = new Gee.HashMap<string, Yaml.Object> ();
if ((done = root != null)) { if ((done = root != null)) {
foreach (var node in root) { foreach (var node in root) {
of.action ("Yaml.Object from node", node.name); of.action ("Yaml.Object from node", node.name);
of.echo (node.to_string (false)); of.echo (node.to_string (false));
if ((obj = Yaml.Object.from_node (node)) != null) { if ((obj = Yaml.Builder.from_node (node)) != null) {
list[node.name] = obj; list[node.name] = obj;
} }
else { else {
@ -69,14 +70,22 @@ int main (string[] args)
of.keyval("type_char" , "%c" .printf(o.type_char)); of.keyval("type_char" , "%c" .printf(o.type_char));
of.keyval("type_string", "%s" .printf(o.type_string)); of.keyval("type_string", "%s" .printf(o.type_string));
of.keyval("type_uchar" , "%u" .printf(o.type_uchar)); of.keyval("type_uchar" , "%u" .printf(o.type_uchar));
of.keyval("type_uint" , "%u" .printf(o.type_uint));
of.keyval("type_float" , "%f" .printf(o.type_float)); of.keyval("type_float" , "%f" .printf(o.type_float));
of.keyval("type_double", "%f" .printf(o.type_double)); of.keyval("type_double", "%f" .printf(o.type_double));
of.keyval("type_struct", "%s" .printf(o.type_struct.to_string ()));
of.keyval("type_object", "%s" .printf(o.type_object.get_type ().name ())); of.keyval("type_object", "%s" .printf(o.type_object.get_type ().name ()));
of.keyval(" toto (string)", "%s" .printf(o.type_object.toto)); of.keyval(" toto" , "%s (string)" .printf(o.type_object.toto));
of.keyval(" tapa (string)", "%s" .printf(o.type_object.tata)); of.keyval(" tapa" , "%s (string)" .printf(o.type_object.tata));
of.keyval(" titi (int)" , "%d" .printf(o.type_object.titi)); of.keyval(" titi" , "%d (int)" .printf(o.type_object.titi));
of.keyval(" tutu (bool)" , "%s" .printf(o.type_object.tutu.to_string ())); of.keyval(" tutu" , "%s (bool)" .printf(o.type_object.tutu.to_string ()));
o.type_object.method_a (); o.type_object.method_a ();
if (o.type_gee_al != null) {
of.keyval("type_gee_al", "(%s)" .printf(o.type_gee_al.get_type ().name ()));
foreach (string v in o.type_gee_al) {
of.echo(" - item : %s".printf (v));
}
}
} }
} }

View File

@ -1,7 +1,8 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.4 * @version : 0.5
* @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
@ -9,24 +10,25 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* This file is part of lib-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.
* *
* 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 lib-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;
@ -39,7 +41,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.Scanner.DEBUG = false; Pluie.Yaml.DEBUG = false;
var config = new Yaml.Config (path, true); var config = new Yaml.Config (path, true);
var node = config.root_node (); var node = config.root_node ();
if ((done = node != null)) { if ((done = node != null)) {

View File

@ -1,7 +1,8 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.4 * @version : 0.5
* @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
@ -9,20 +10,20 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* This file is part of lib-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.
* *
* 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 lib-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/ */

View File

@ -1,7 +1,8 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.4 * @version : 0.5
* @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
@ -9,23 +10,24 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* This file is part of lib-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.
* *
* 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 lib-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;

View File

@ -1,7 +1,8 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.4 * @version : 0.5
* @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
@ -9,20 +10,20 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* This file is part of lib-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.
* *
* 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 lib-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/ */

View File

@ -1,7 +1,8 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.4 * @version : 0.5
* @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
@ -9,20 +10,20 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* This file is part of lib-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.
* *
* 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 lib-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/ */

View File

@ -1,7 +1,8 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.4 * @version : 0.5
* @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
@ -9,20 +10,20 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* This file is part of lib-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.
* *
* 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 lib-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/ */
@ -102,6 +103,4 @@ public abstract class Pluie.Yaml.AbstractNode : GLib.Object
return ""; return "";
} }
} }

View File

@ -0,0 +1,262 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* @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 Yaml.Builder class helping to build vala Yaml.Object from Yaml.Node
*/
public class Pluie.Yaml.Builder
{
/**
*
*/
private static GLib.Module? p_module;
/**
*
*/
private static unowned GLib.Module p_open_module ()
{
if (p_module == null) {
p_module = GLib.Module.open (null, 0);
}
return p_module;
}
/**
*
*/
public static GLib.Type? type_from_string (string name)
{
GLib.Type? type = Type.from_name (name.replace(".", ""));
return type;
}
/**
* retriew GLib.Type related to specified vala name
* @param name a valid vala identifier name
*/
public static Type type_from_vala (string name)
{
void * s;
p_open_module ();
if (!p_module.symbol (resolve_c_name(@"$(name).get_type"), out s)) {
of.error ("cannot resolve type %s (not found)".printf (name));
}
return ((dlgType) s)();
}
/**
* retiew GLib.Type related to specified tag value.
* Type may not be registered yet
*/
public static Type? type_from_tag (string tagValue)
{
var type = type_from_string (tagValue);
if(type != null && type == Type.INVALID) {
type = type_from_vala (tagValue);
}
return type;
}
/**
* retriew corresponding c name related to specified vala name
* @param name a valid vala identifier name
*/
public static string resolve_c_name (string name)
{
string? str = null;
MatchInfo? mi = null;
StringBuilder sb = new StringBuilder ();
bool begin = true;
try {
var reg = new Regex ("([^.]*).?");
for (reg.match (name, 0, out mi) ; mi.matches () ; mi.next ()) {
if ((str = mi.fetch (1)) != null && str.length > 0) {
if (!begin) sb.append_unichar ('_');
else begin = false;
sb.append_unichar (str[0].tolower ());
sb.append (str.substring(1));
}
}
}
catch (GLib.RegexError e) {
of.error (e.message, true);
}
return !begin ? sb.str : name;
}
[CCode (has_target = false)]
private delegate Type dlgType();
/**
*
*/
public static Yaml.Object? from_node (Yaml.Node node, Type otype = GLib.Type.INVALID)
{
Yaml.Object? obj = null;
try {
Type type = node.tag != null ? type_from_tag (node.tag.value) : otype;
if (type != Type.INVALID) {
Yaml.dbg_action ("vala type founded", "%s (%s)".printf (type.name (), type.to_string ()));
if (type.is_object ()) {
obj = (Yaml.Object) GLib.Object.new (type);
if (node!= null && !node.empty ()) {
GLib.ParamSpec? def = null;
Yaml.Node? scalar = null;
foreach (var child in node) {
if ((def = obj.get_class ().find_property (child.name)) != null) {
Yaml.dbg ("== prop [%s] type is : %s".printf (child.name, def.value_type.name ()));
if (child.ntype.is_single_pair () && (scalar = child.first ()) != null) {
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 {
of.warn ("property %s not found".printf (child.name));
}
}
}
}
}
if (obj == null) {
of.warn ("searched type not found : %s".printf (type.name ()));
}
else {
obj.yaml_init ();
}
}
catch (GLib.Error e) {
of.warn (e.message);
}
return obj;
}
/**
*
*/
public static void set_from_collection (ref Yaml.Object obj, GLib.Type parentType, Yaml.Node node, GLib.Type type)
{
if (type.is_a (typeof (Yaml.Object))) {
obj.set (node.name, Yaml.Builder.from_node(node, type));
}
else if (Yaml.Object.register.is_registered_type(parentType, type)) {
Yaml.dbg ("%s is a registered type".printf (type.name ()));
obj.populate_by_type (type, node);
}
else {
Dbg.error ("%s is not registered and cannot be populated".printf (type.name ()), Log.METHOD, Log.LINE);
}
}
/**
*
*/
public static void set_from_scalar (ref Yaml.Object obj, string name, GLib.Type type, string data)
{
GLib.Value v = GLib.Value(type);
Yaml.dbg_action ("Auto setting property value %s".printf (of.c (ECHO.MICROTIME).s (type.name ())), name);
Yaml.dbg (data);
if (type.is_a(Type.ENUM))
set_enum_value (ref v, type, data);
else
set_basic_type_value(ref v, type, data);
obj.set_property(name, v);
}
/**
*
*/
public static void set_basic_type_value (ref Value v, GLib.Type type, string data)
{
switch (type)
{
case Type.STRING :
v.set_string(data);
break;
case Type.CHAR :
v.set_schar((int8)data.data[0]);
break;
case Type.UCHAR :
v.set_uchar((uint8)data.data[0]);
break;
case Type.BOOLEAN :
v.set_boolean (data == "1" || data.down () == "true");
break;
case Type.INT :
v.set_int(int.parse(data));
break;
case Type.UINT :
v.set_uint((uint)long.parse(data));
break;
case Type.LONG :
case Type.INT64 :
v.set_long((long)int64.parse(data));
break;
case Type.ULONG :
case Type.UINT64 :
v.set_ulong((ulong)uint64.parse(data));
break;
case Type.FLOAT :
v.set_float((float)double.parse(data));
break;
case Type.DOUBLE :
v.set_double(double.parse(data));
break;
}
}
/**
*
*/
public static void set_enum_value (ref Value v, GLib.Type type, string data)
{
EnumClass kenum = (EnumClass) type.class_ref();
unowned EnumValue? enumval = kenum.get_value_by_name(data);
if (enumval == null) {
enumval = kenum.get_value_by_nick(data.down());
int64 e = 0;
if(enumval == null) {
if(!int64.try_parse(data, out e)) {
Dbg.error ("invalid enum value %s".printf(data), Log.METHOD, Log.LINE);
}
else enumval = kenum.get_value((int)e);
}
}
v.set_enum(enumval.value);
//~ of.echo ("enumValue : %d".printf (enumval.value));
}
}

View File

@ -1,7 +1,8 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.4 * @version : 0.5
* @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
@ -9,20 +10,20 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* This file is part of lib-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.
* *
* 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 lib-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/ */

View File

@ -1,7 +1,8 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.4 * @version : 0.5
* @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
@ -9,20 +10,20 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* This file is part of lib-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.
* *
* 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 lib-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/ */
@ -144,9 +145,7 @@ public class Pluie.Yaml.Config
subnode.parent = null; subnode.parent = null;
n.add(subnode); n.add(subnode);
} }
//~ root.add (n);
} }
//~ root.update_level();
} }
/** /**
@ -175,7 +174,7 @@ public class Pluie.Yaml.Config
foreach (var v in this.varmap.entries) { foreach (var v in this.varmap.entries) {
if (v.key != "path") { if (v.key != "path") {
this.paths[key] = val.replace ("^%s^".printf (v.key), v.value); this.paths[key] = val.replace ("^%s^".printf (v.key), v.value);
if (Yaml.Scanner.DEBUG) of.keyval (key, this.paths[key]); Yaml.dbg_keyval (key, this.paths[key]);
} }
} }
} }

View File

@ -1,7 +1,8 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.4 * @version : 0.5
* @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
@ -9,20 +10,20 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* This file is part of lib-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.
* *
* 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 lib-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/ */

View File

@ -1,7 +1,8 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.4 * @version : 0.5
* @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
@ -9,27 +10,30 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* This file is part of lib-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.
* *
* 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 lib-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/ */
using GLib;
using Gee;
using Pluie;
/** /**
* a test class to implements yamlize * a test class to implements yamlize
*/ */
public class Pluie.Yaml.Example : Yaml.Object public class Pluie.Yaml.Example : Yaml.Object
{ {
@ -57,7 +61,16 @@ public class Pluie.Yaml.Example : Yaml.Object
public int64 type_int64 { get; set; } public int64 type_int64 { get; set; }
public uint64 type_uint64 { get; set; } public uint64 type_uint64 { get; set; }
public bool type_bool { get; set; } public bool type_bool { get; set; }
public Yaml.SubExample type_object { 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<string> type_gee_al { get; set; }
static construct
{
Yaml.Object.register.add_type (typeof (Yaml.Example), typeof (Yaml.ExampleStruct));
Yaml.Object.register.add_type (typeof (Yaml.Example), typeof (Gee.ArrayList));
}
/** /**
* *
@ -68,4 +81,27 @@ public class Pluie.Yaml.Example : Yaml.Object
Dbg.msg ("Yaml.Object %s (%s) instantiated".printf (this.myname, this.type_from_self ()), Log.LINE, Log.FILE); Dbg.msg ("Yaml.Object %s (%s) instantiated".printf (this.myname, this.type_from_self ()), Log.LINE, Log.FILE);
} }
/**
*
*/
public override void populate_by_type(GLib.Type type, Yaml.Node node)
{
try {
if (type == typeof (Yaml.ExampleStruct)) {
this.type_struct = ExampleStruct.from_yaml_node (node);
}
else if (type == typeof (Gee.ArrayList)) {
this.type_gee_al = new Gee.ArrayList<string> ();
if (!node.empty ()) {
foreach (var child in node) {
this.type_gee_al.add(child.data);
}
}
}
}
catch (GLib.Error e) {
Dbg.error(e.message, Log.METHOD, Log.LINE);
}
}
} }

View File

@ -1,7 +1,8 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.4 * @version : 0.5
* @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
@ -9,29 +10,28 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* This file is part of lib-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.
* *
* 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 lib-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 test class to implements yamlize
*/ */
public class Pluie.Yaml.SubExample : Yaml.Object public class Pluie.Yaml.ExampleChild : 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,59 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* @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/>.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/
public struct Pluie.Yaml.ExampleStruct
{
public uint red;
public uint green;
public uint blue;
public static ExampleStruct from_yaml_node (Yaml.Node node)
{
var s = ExampleStruct ();
foreach (var child in node) {
var v = child.val (typeof (uint));
switch (child.name) {
case "red" :
s.red = v.get_uint ();
break;
case "green" :
s.green = v.get_uint ();
break;
case "blue" :
s.blue = v.get_uint ();
break;
}
}
return s;
}
public string to_string ()
{
return "%s(red:%u,green:%u,blue:%u)".printf ((typeof (ExampleStruct)).name (), this.red, this.green, this.blue);
}
}

View File

@ -1,7 +1,8 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.4 * @version : 0.5
* @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
@ -9,20 +10,20 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* This file is part of lib-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.
* *
* 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 lib-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/ */

View File

@ -1,7 +1,8 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.4 * @version : 0.5
* @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
@ -9,20 +10,20 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* This file is part of lib-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.
* *
* 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 lib-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/ */

View File

@ -1,7 +1,8 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.4 * @version : 0.5
* @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
@ -9,20 +10,20 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* This file is part of lib-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.
* *
* 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 lib-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/ */
@ -143,8 +144,12 @@ public class Pluie.Yaml.Mapping : Yaml.Node
return clone; return clone;
} }
/**
*
*/
public Gee.ArrayList<string>? child_names () public Gee.ArrayList<string>? child_names ()
{ {
return this.keys; return this.keys;
} }
} }

View File

@ -1,7 +1,8 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.4 * @version : 0.5
* @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
@ -9,24 +10,23 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* This file is part of lib-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.
* *
* 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 lib-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;
@ -251,6 +251,17 @@ public class Pluie.Yaml.Node : Yaml.AbstractChild, Pluie.Yaml.Collection
return new Yaml.Node (null, this.ntype, name); return new Yaml.Node (null, this.ntype, name);
} }
/**
*
*/
public GLib.Value val (GLib.Type type)
{
var v = GLib.Value(type);
if (this.ntype.is_single_pair ()) {
Yaml.Builder.set_basic_type_value (ref v, type, this.first ().data);
}
return v;
}
/** /**
* display childs * display childs

View File

@ -1,7 +1,8 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.4 * @version : 0.5
* @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
@ -9,20 +10,20 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* This file is part of lib-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.
* *
* 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 lib-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/ */
@ -37,7 +38,15 @@ public abstract class Pluie.Yaml.Object : GLib.Object
/** /**
* *
*/ */
private static GLib.Module? p_module; public static Yaml.Register register { get; private set; }
/**
*
*/
static construct
{
register = new Yaml.Register();
}
/** /**
* *
@ -47,53 +56,6 @@ public abstract class Pluie.Yaml.Object : GLib.Object
Dbg.msg ("Yaml.Object (%s) instantiated".printf (this.type_from_self ()), Log.LINE, Log.FILE); Dbg.msg ("Yaml.Object (%s) instantiated".printf (this.type_from_self ()), Log.LINE, Log.FILE);
} }
/**
*
*/
private static unowned GLib.Module p_open_module ()
{
if (p_module == null) {
p_module = GLib.Module.open (null, 0);
}
return p_module;
}
/**
*
*/
public static GLib.Type? type_from_string (string name)
{
GLib.Type? type = Type.from_name (name.replace(".", ""));
return type;
}
/**
* retriew GLib.Type related to specified vala name
* @param name a valid vala identifier name
*/
public static Type type_from_vala (string name)
{
void * s;
p_open_module ();
if (!p_module.symbol (resolve_c_name(@"$(name).get_type"), out s)) {
of.error ("cannot resolve type %s (not found)".printf (name));
}
return ((dlgType) s)();
}
/**
* retiew GLib.Type related to specified tag value.
* Type may not be registered yet
*/
public static Type? type_from_tag (string tagValue)
{
var type = type_from_string (tagValue);
if(type != null && type == Type.INVALID) {
type = type_from_vala (tagValue);
}
return type;
}
/** /**
* retiew GLib.Type related to instance * retiew GLib.Type related to instance
*/ */
@ -102,124 +64,13 @@ public abstract class Pluie.Yaml.Object : GLib.Object
return Type.from_instance (this).name (); return Type.from_instance (this).name ();
} }
/**
* retriew corresponding c name related to specified vala name
* @param name a valid vala identifier name
*/
public static string resolve_c_name (string name)
{
string? str = null;
MatchInfo? mi = null;
StringBuilder sb = new StringBuilder ();
bool begin = true;
try {
var reg = new Regex ("([^.]*).?");
for (reg.match (name, 0, out mi) ; mi.matches () ; mi.next ()) {
if ((str = mi.fetch (1)) != null && str.length > 0) {
if (!begin) sb.append_unichar ('_');
else begin = false;
sb.append_unichar (str[0].tolower ());
sb.append (str.substring(1));
}
}
}
catch (GLib.RegexError e) {
of.error (e.message, true);
}
return !begin ? sb.str : name;
}
[CCode (has_target = false)]
private delegate Type dlgType();
/** /**
* *
*/ */
public static Yaml.Object? from_node (Yaml.Node node) public virtual void populate_by_type(GLib.Type type, Yaml.Node node)
{ {
Yaml.Object? obj = null; if (type.is_a (typeof (Yaml.Object))) {
try { this.set (node.name, Yaml.Builder.from_node(node, type));
if (node.tag != null) {
if (Yaml.Scanner.DEBUG) of.action ("tag value", node.tag.value);
Type? type = type_from_tag (node.tag.value);
if (type != null && type.is_object ()) {
if (Yaml.Scanner.DEBUG) of.echo ("object type founded : %s".printf (type.to_string ()));
obj = (Yaml.Object) GLib.Object.new (type);
if (node!= null && !node.empty ()) {
GLib.ParamSpec? def = null;
Yaml.Node? scalar = null;
foreach (var child in node) {
if ((def = obj.get_class ().find_property (child.name)) != null) {
if (child.ntype.is_single_pair ()) {
if ((scalar = child.first ()) != null) {
obj.set_from_scalar (def.name, def.value_type, scalar);
}
}
else if (child.ntype.is_mapping ()) {
obj.set (child.name, from_node(child));
} }
} }
} }
}
}
else {
of.echo ("searched type : %s".printf (type.to_string ()));
}
}
}
catch (GLib.Error e) {
of.warn (e.message);
}
obj.yaml_init ();
return obj;
}
/**
*
*/
public void set_from_scalar (string name, GLib.Type type, Yaml.Node node)
{
GLib.Value v = GLib.Value(type);
var data = node.data;
if (Yaml.Scanner.DEBUG) {
of.action("Auto setting property value %s".printf (of.c (ECHO.MICROTIME).s (type.name ())), name);
of.echo (data);
}
switch (type)
{
case Type.STRING :
v.set_string(data);
break;
case Type.CHAR :
v.set_schar((int8)data.data[0]);
break;
case Type.UCHAR :
v.set_uchar((uint8)data.data[0]);
break;
case Type.BOOLEAN :
v.set_boolean (data == "1" || data.down () == "true");
break;
case Type.INT :
v.set_int(int.parse(data));
break;
case Type.UINT :
v.set_uint((uint)long.parse(data));
break;
case Type.LONG :
case Type.INT64 :
v.set_long((long)int64.parse(data));
break;
case Type.ULONG :
case Type.UINT64 :
v.set_ulong((ulong)uint64.parse(data));
break;
case Type.FLOAT :
v.set_float((float)double.parse(data));
break;
case Type.DOUBLE :
v.set_double(double.parse(data));
break;
}
this.set_property(name, v);
}
}

View File

@ -1,7 +1,8 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.4 * @version : 0.5
* @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
@ -9,20 +10,20 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* This file is part of lib-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.
* *
* 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 lib-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/ */
@ -158,10 +159,8 @@ public class Pluie.Yaml.Processor
*/ */
public bool run () public bool run ()
{ {
if (Yaml.Scanner.DEBUG) { if (Yaml.DEBUG) this.read ();
this.read (); Yaml.dbg_action ("Processing events");
of.action ("Processing events");
}
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 ();
@ -180,7 +179,9 @@ public class Pluie.Yaml.Processor
this.on_entry (); this.on_entry ();
} }
if (this.beginFlowSeq && this.event.evtype.is_scalar ()) { if (this.beginFlowSeq && this.event.evtype.is_scalar ()) {
if (!this.change) {
this.on_scalar (true); this.on_scalar (true);
}
this.beginFlowSeq = false; this.beginFlowSeq = false;
} }
if (this.event.evtype.is_key () && (this.event = this.get_value_key_event ()) != null) { if (this.event.evtype.is_key () && (this.event = this.get_value_key_event ()) != null) {
@ -264,8 +265,7 @@ public class Pluie.Yaml.Processor
*/ */
private void on_tag_directive () private void on_tag_directive ()
{ {
if (Yaml.Scanner.DEBUG) Yaml.dbg_action ("on_tag_directive %s".printf (this.event.data["handle"]), this.event.data["prefix"]);
of.action ("on_tag_directive %s".printf (this.event.data["handle"]), this.event.data["prefix"]);
this.root.tag_directives[this.event.data["handle"]] = this.event.data["prefix"]; this.root.tag_directives[this.event.data["handle"]] = this.event.data["prefix"];
} }
@ -309,8 +309,7 @@ public class Pluie.Yaml.Processor
private void on_tag (bool onKey = false) private void on_tag (bool onKey = false)
{ {
if (this.event.evtype.is_tag ()) { if (this.event.evtype.is_tag ()) {
if (Yaml.Scanner.DEBUG) Yaml.dbg_keyval ("tag %s".printf (this.event.data["handle"]), this.event.data["suffix"]);
of.keyval ("tag %s".printf (this.event.data["handle"]), this.event.data["suffix"]);
if (this.root.tag_directives.has_key (this.event.data["handle"])) { if (this.root.tag_directives.has_key (this.event.data["handle"])) {
var tag = new Yaml.Tag (this.event.data["suffix"], this.event.data["handle"].replace("!", "")); var tag = new Yaml.Tag (this.event.data["suffix"], this.event.data["handle"].replace("!", ""));
if (onKey) if (onKey)
@ -444,12 +443,12 @@ public class Pluie.Yaml.Processor
private void on_update () private void on_update ()
{ {
if (this.node != null) { if (this.node != null) {
if (Yaml.Scanner.DEBUG) of.echo (this.node.name); Yaml.dbg (this.node.name);
} }
if (this.change) { if (this.change) {
if (Yaml.Scanner.DEBUG) of.action ("on change", this.node.name); Yaml.dbg_action ("on change", this.node.name != null ? this.node.name : this.node.data);
if (this.keyTag != null) { if (this.keyTag != null) {
if (Yaml.Scanner.DEBUG) of.action ("setting tag", this.keyTag.@value); Yaml.dbg_action ("setting tag", this.keyTag.@value);
this.node.tag = this.keyTag; this.node.tag = this.keyTag;
} }
else if (this.valueTag != null) { else if (this.valueTag != null) {

View File

@ -0,0 +1,94 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* @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 Pluie;
using Gee;
/**
* a class registering type which could be populated
*/
public class Pluie.Yaml.Register : GLib.Object
{
/**
*
*/
public static Gee.HashMap<Type, Gee.ArrayList<GLib.Type>> reg { get; internal set; }
/**
*
*/
static construct {
Yaml.Register.reg = new Gee.HashMap<Type, Gee.ArrayList<GLib.Type>> ();
}
/**
*
*/
private Gee.ArrayList<GLib.Type> init_type_list ()
{
return new Gee.ArrayList<GLib.Type> ();
}
/**
*
*/
public Gee.ArrayList<GLib.Type>? get_type_list (GLib.Type type)
{
return reg.get (type);
}
/**
*
*/
public bool add_type (GLib.Type type, GLib.Type addedType)
{
if (!this.is_registered (type)) {
reg.set (type, this.init_type_list ());
}
return reg.get (type).add (addedType);
}
/**
*
*/
public bool is_registered (GLib.Type type)
{
return reg.has_key (type);
}
/**
*
*/
public bool is_registered_type (GLib.Type type, GLib.Type checktype)
{
return this.is_registered (type) && reg.get (type).contains (checktype);
}
}

View File

@ -1,7 +1,8 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.4 * @version : 0.5
* @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
@ -9,20 +10,20 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* This file is part of lib-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.
* *
* 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 lib-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/ */

View File

@ -1,7 +1,8 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.4 * @version : 0.5
* @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
@ -9,20 +10,20 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* This file is part of lib-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.
* *
* 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 lib-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/ */

View File

@ -1,7 +1,8 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.4 * @version : 0.5
* @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
@ -9,20 +10,20 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* This file is part of lib-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.
* *
* 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 lib-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/ */
@ -37,7 +38,6 @@ extern void yaml_parse_file(string srcPath, string destPath);
*/ */
public class Pluie.Yaml.Scanner public class Pluie.Yaml.Scanner
{ {
public static bool DEBUG = false;
/** /**
* Regex pattern use to find EVENT * Regex pattern use to find EVENT
*/ */
@ -143,14 +143,14 @@ public class Pluie.Yaml.Scanner
this.before_run (path); this.before_run (path);
this.processor = new Yaml.Processor (); this.processor = new Yaml.Processor ();
this.done = false; this.done = false;
if (Pluie.Yaml.Scanner.DEBUG) of.action ("Scanning events", path); Yaml.dbg_action ("Scanning events", path);
while (this.reader.readable) { while (this.reader.readable) {
this.scan_event (this.reader.read ()); this.scan_event (this.reader.read ());
} }
this.done = true; this.done = true;
if (Pluie.Yaml.Scanner.DEBUG) of.state (this.done); Yaml.dbg_state (this.done);
this.done = this.done && this.processor.run (); this.done = this.done && this.processor.run ();
if (Pluie.Yaml.Scanner.DEBUG) of.state (this.done); Yaml.dbg_state (this.done);
Dbg.out (Log.METHOD, "done:%d".printf ((int)done), Log.LINE, Log.FILE); Dbg.out (Log.METHOD, "done:%d".printf ((int)done), Log.LINE, Log.FILE);
return this.done; return this.done;
} }

View File

@ -1,7 +1,8 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.4 * @version : 0.5
* @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
@ -9,20 +10,20 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* This file is part of lib-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.
* *
* 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 lib-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/ */

View File

@ -1,7 +1,8 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.4 * @version : 0.5
* @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
@ -9,20 +10,20 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* This file is part of lib-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.
* *
* 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 lib-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/ */
@ -30,10 +31,9 @@ using GLib;
using Gee; using Gee;
/** /**
* a test class to implements yamlize * a Tag class to store handle and value tag for Yaml.Node
*/ */
public class Pluie.Yaml.Tag : GLib.Object public class Pluie.Yaml.Tag
{ {
public string handle { get; internal set; } public string handle { get; internal set; }
public string @value { get; internal set; } public string @value { get; internal set; }

View File

@ -1,7 +1,8 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* @software : lib-yaml <https://git.pluie.org/pluie/lib-yaml> * @software : pluie-yaml <https://git.pluie.org/pluie/lib-yaml>
* @version : 0.4 * @version : 0.5
* @type : library
* @date : 2018 * @date : 2018
* @licence : GPLv3.0 <http://www.gnu.org/licenses/> * @licence : GPLv3.0 <http://www.gnu.org/licenses/>
* @author : a-Sansara <[dev]at[pluie]dot[org]> * @author : a-Sansara <[dev]at[pluie]dot[org]>
@ -9,20 +10,20 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* This file is part of lib-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.
* *
* 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 lib-yaml. If not, see <http://www.gnu.org/licenses/>. * along with pluie-yaml. If not, see <http://www.gnu.org/licenses/>.
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/ */
@ -31,6 +32,8 @@ namespace Pluie
{ {
namespace Yaml namespace Yaml
{ {
public static bool DEBUG = false;
public static bool DBG_SHOW_INDENT = true; public static bool DBG_SHOW_INDENT = true;
public static bool DBG_SHOW_PARENT = false; public static bool DBG_SHOW_PARENT = false;
public static bool DBG_SHOW_UUID = true; public static bool DBG_SHOW_UUID = true;
@ -40,6 +43,38 @@ namespace Pluie
public static bool DBG_SHOW_TAG = true; public static bool DBG_SHOW_TAG = true;
public static bool DBG_SHOW_TYPE = true; public static bool DBG_SHOW_TYPE = true;
/**
*
*/
public static void dbg_action (string msg, string? val = null)
{
if (Pluie.Yaml.DEBUG) of.action (msg, val);
}
/**
*
*/
public static void dbg_keyval (string key, string val)
{
if (Pluie.Yaml.DEBUG) of.keyval (key, val);
}
/**
*
*/
public static void dbg_state (bool done)
{
if (Pluie.Yaml.DEBUG) of.state (done);
}
/**
*
*/
public static void dbg (string? msg = null)
{
if (Pluie.Yaml.DEBUG && msg != null) of.echo (msg);
}
/** /**
* ParseError * ParseError
*/ */

View File

@ -1,6 +1,40 @@
#!/bin/bash #!/bin/bash
valadoc --package-name=pluie-yaml-0.4 --verbose --force --deps -o ./doc --pkg gee-0.8 --pkg gio-2.0 --pkg gobject-2.0 --pkg glib-2.0 --pkg pluie-echo-0.2 ./src/vala/Pluie/*.vala ./build/install.vala #!/bin/bash
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
# @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.
#
# lib-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/>.
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
lib="pluie-yaml-0.5"
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
rm doc/*.png rm doc/*.png
cp resources/doc-scripts.js ./doc/scripts.js cp resources/doc-scripts.js ./doc/scripts.js
cp resources/doc-style.css ./doc/style.css cp resources/doc-style.css ./doc/style.css
rm $lib.tar.gz
tar -czvf $lib.tar.gz doc/