Giter VIP home page Giter VIP logo

cccp-configxml's Introduction

NAME

CCCP::ConfigXML - load XML config files or string

SYNOPSIS

Load XML file. Example:

# foo_config.xml
    <foo>
        <name>TestApp</name>
        <component name="Controller::Foo">
            <foo>bar</foo>
        </component>
        <model name="Baz">
            <qux>Stop!</qux>
        </model>
    </foo>
# bar_config.xml    
    <bar>
        <val>x1</val>
        <val>x2</val>
        <val>x3</val>
        <val>x4</val>
    </bar>
# baz_config.xml    
    <foo>
        <model name="Bar">
            <qux>Go!</qux>
        </model>
    </foo>
    

In your code:

use CCCP::ConfigXML;
# or if you want singletone
use CCCP::ConfigXML as => 'singletone';

# like XML::Bare
my $cnf = CCCP::ConfigXML->new( file => ['foo_config.xml', 'bar_config.xml'] );

# now, you can read
$cnf->{foo}->{name}->{value};                        # TestApp
$cnf->{foo}->{component}->{foo}->{value};            # bar
$cnf->{foo}->{component}->{name}->{value};           # Controller::Foo    
$cnf->{foo}->{model}->{qux}->{value}                 # Stop!

$cnf->add_file(baz_config.xml);
$cnf->{foo}->{model}->{qux}->{value}                 # Go!

DESCRIPTION

Simple and usefull wrapper on XML::Bare and Hash::Merge::Simple.

METHODS

new(file => [...list xml-files...], text => [...list xml-string...], @param_parse)

Constructor. All arguments are optional. @param_parse - another parametrs for XML::Bare

add_file($file[, @param_parse])

Extend instance from $file.

add_text($xml_str[, @param_parse])

Extend instance from xml-string.

PACKAGE VARIABLES

$CCCP::ConfigXML::like_singletone

By default 0. Set true when

use CCCP::ConfigXML as => 'singletone';
# or
use CCCP::ConfigXML;
CCCP::ConfigXML->import(as => 'singletone');
# or :)
$CCCP::ConfigXML::like_singletone = 1;

When value is true, then new returns a singleton if this is possible.

AUTHOR

mr.Rico <catamoose at yandex.ru>

cccp-configxml's People

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.