1Config::Model::Backend:U:sCedrsFCiolnet(r3i)buted Perl DCoocnufmiegn:t:aMtoidoenl::Backend::CdsFile(3)
2
3
4

NAME

6       Config::Model::Backend::CdsFile - Read and write config as a Cds data
7       structure
8

VERSION

10       version 2.152
11

SYNOPSIS

13        use Config::Model ;
14        use Data::Dumper ;
15
16        # define configuration tree object
17        my $model = Config::Model->new ;
18        $model ->create_config_class (
19           name => "MyClass",
20           element => [
21               [qw/foo bar/] => {
22                   type => 'leaf',
23                   value_type => 'string'
24               },
25               baz => {
26                   type => 'hash',
27                   index_type => 'string' ,
28                   cargo => {
29                       type => 'leaf',
30                       value_type => 'string',
31                   },
32               },
33           ],
34         rw_config  => {
35            backend => 'cds_file' ,
36            config_dir => '/tmp',
37            file  => 'foo.pl',
38            auto_create => 1,
39         }
40        ) ;
41
42        my $inst = $model->instance(root_class_name => 'MyClass' );
43
44        my $root = $inst->config_root ;
45
46        my $steps = 'foo=yada bar="bla bla" baz:en=hello
47                    baz:fr=bonjour baz:hr="dobar dan"';
48        $root->load( steps => $steps ) ;
49        $inst->write_back ;
50
51       Now, "/tmp/foo.pl" contains:
52
53        {
54          bar => 'bla bla',
55          baz => {
56            en => 'hello',
57            fr => 'bonjour',
58            hr => 'dobar dan'
59          },
60          foo => 'yada'
61        }
62

DESCRIPTION

64       This module is used directly by Config::Model to read or write the
65       content of a configuration tree written with Cds syntax in
66       "Config::Model" configuration tree.
67
68       Note:
69
70       •   Undefined values are skipped for list element. I.e. if a list
71           element contains "('a',undef,'b')", the data structure contains
72           'a','b'.
73
74       •   Cds file is not created (and may be deleted) when no data is to be
75           written.
76

backend parameter

78   config_dir
79       Mandoatory parameter to specify where is the Cds configuration file.
80

CONSTRUCTOR

82   new
83       Inherited from Config::Model::Backend::Any. The constructor is called
84       by Config::Model::BackendMgr.
85
86   read
87       Of all parameters passed to this read call-back, only "file_path" is
88       used.
89
90       It can also be undef. In which case "read" returns 0.
91
92       When a file is read,  "read" returns 1.
93
94   write
95       Of all parameters passed to this write call-back, only "file_path" is
96       used.
97
98       "write" returns 1.
99

AUTHOR

101       Dominique Dumont, (ddumont at cpan dot org)
102

SEE ALSO

104       Config::Model, Config::Model::BackendMgr, Config::Model::Backend::Any,
105

AUTHOR

107       Dominique Dumont
108
110       This software is Copyright (c) 2005-2022 by Dominique Dumont.
111
112       This is free software, licensed under:
113
114         The GNU Lesser General Public License, Version 2.1, February 1999
115
116
117
118perl v5.36.0                      2023-01-20Config::Model::Backend::CdsFile(3)
Impressum