1Config::Model::Dumper(3U)ser Contributed Perl DocumentatiCoonnfig::Model::Dumper(3)
2
3
4
6 Config::Model::Dumper - Serialize data of config tree
7
9 version 2.138
10
12 use Config::Model ;
13
14 # define configuration tree object
15 my $model = Config::Model->new ;
16 $model ->create_config_class (
17 name => "MyClass",
18 element => [
19 [qw/foo bar/] => {
20 type => 'leaf',
21 value_type => 'string'
22 },
23 baz => {
24 type => 'hash',
25 index_type => 'string' ,
26 cargo => {
27 type => 'leaf',
28 value_type => 'string',
29 },
30 },
31
32 ],
33 ) ;
34
35 my $inst = $model->instance(root_class_name => 'MyClass' );
36
37 my $root = $inst->config_root ;
38
39 # put some data in config tree the hard way
40 $root->fetch_element('foo')->store('yada') ;
41 $root->fetch_element('bar')->store('bla bla') ;
42 $root->fetch_element('baz')->fetch_with_id('en')->store('hello') ;
43
44 # put more data the easy way
45 my $steps = 'baz:fr=bonjour baz:hr="dobar dan"';
46 $root->load( steps => $steps ) ;
47
48 # dump only customized data
49 print $root->dump_tree;
50
52 This module is used directly by Config::Model::Node to serialize
53 configuration data in a compact (but readable) string.
54
55 The serialization can be done in standard mode where only customized
56 values are dumped in the string. I.e. only data modified by the user
57 are dumped.
58
59 All other mode supported by "fetch" in Config::Model::Value can be
60 used, for instance, to get default values.
61
62 The serialized string can be used by Config::Model::Loader to store the
63 data back into a configuration tree.
64
65 Note that undefined values are skipped for list element. I.e. if a list
66 element contains "('a',undef,'b')", the dump then contains 'a','b'.
67
69 new
70 No parameter. The constructor should be used only by
71 Config::Model::Node.
72
74 dump_tree
75 Return a string that contains a dump of the object tree with all the
76 values. This string follows the convention defined by
77 Config::Model::Loader.
78
79 The serialized string can be used by Config::Model::Loader to store the
80 data back into a configuration tree.
81
82 Parameters are:
83
84 mode
85 "full" dumps all configuration data including default values.
86
87 All mode values from "fetch" in Config::Model::Value can be used.
88
89 By default, the dump contains only data modified by the user (i.e.
90 "custom" data that differ from default or preset values).
91
92 node
93 Reference to the Config::Model::Node object that is dumped. All
94 nodes and leaves attached to this node are also dumped.
95
96 skip_auto_write ( <backend_name> )
97 Skip node that have a write capability matching "backend_name" in
98 their model. See Config::Model::BackendMgr.
99
100 This option must be used when using Dumper to write back
101 configuration data. When a configuration model contains several
102 backends (one at the tree root and others in tree nodes), setting
103 this option ensure that the "root" configuration file does not
104 contain data duplicated in configuration file of others tree nodes.
105
106 auto_vivify
107 Scan and create data for nodes elements even if no actual data was
108 stored in them. This may be useful to trap missing mandatory
109 values. (default: 0)
110
111 check
112 Check value before dumping. Valid check are 'yes', 'no' and 'skip'.
113
115 Dominique Dumont, (ddumont at cpan dot org)
116
118 Config::Model,Config::Model::Node,Config::Model::Loader
119
121 Dominique Dumont
122
124 This software is Copyright (c) 2005-2019 by Dominique Dumont.
125
126 This is free software, licensed under:
127
128 The GNU Lesser General Public License, Version 2.1, February 1999
129
130
131
132perl v5.30.1 2020-01-29 Config::Model::Dumper(3)