pluie-yaml/samples/yaml-tonode.vala

63 lines
2.0 KiB
Vala

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