HerbertKoelman / cpp-atmi

Application-to-Transaction Monitor Interface (ATMI) C++ library
http://herbertkoelman.github.com/cpp-atmi
Other
7 stars 0 forks source link

Implement a utility class to parse YAML configuration files #24

Closed HerbertKoelman closed 11 years ago

HerbertKoelman commented 11 years ago

Propose a class to parse a YAML configuration file. The parsed data will be converted into key/value pairs. Each key is pa unique path to a value. A value is either a single value or multiple values separated by a sequence separator (for example white space).

This is the kind of yaml file it should be able to parse and convert into a map of key/value pairs:

#  Tuxedo client configuration file
# Client: atm/atmw

basedir: /home/herbert/

# Tuxedo onfiguration
tuxconfig:
  - /home/herbert/conf/ubbconfig.red.bin
  - /home/herbert/conf/ubbconfig.blue.bin

# Listens
network:
  - listen:
      - //0.0.0.0:2000
      - //0.0.0.0:2001

# Database
database:
  url: database://hostname:1521/monitoring
  user: dbuser
  password: A1Q2W3

# Queue Manager
mqseries:
  queuemanager: CLBPE
  hostname: etoile
  port: 141
  queues:
    - queries: LBP.OPO.Q
    - responses: LBP.OPO.R
  subscriptions:
    opposition:
      - notif.opo.reseau
        notif.opo.bo

The map should contain the following pairs:

root.basedir: /home/herbert/
root.database.password: A1Q2W3
root.database.url: database://hostname:1521/monitoring
root.database.user: dbuser
root.mqseries.hostname: etoile
root.mqseries.port: 141
root.mqseries.queuemanager: CLBPE
root.mqseries.queues.queries: LBP.OPO.Q
root.mqseries.queues.responses: LBP.OPO.R
root.mqseries.subscriptions.opposition: notif.opo.reseau notif.opo.bo 
root.network.listen: //0.0.0.0:2000 //0.0.0.0:2001 
root.tuxconfig: /home/herbert/conf/ubbconfig.red.bin /home/herbert/conf/ubbconfig.blue.bin 
HerbertKoelman commented 11 years ago

Information about yaml file format can be found here.

HerbertKoelman commented 11 years ago

First implementation in this commit 9a9ad476d8a5110bf23f7d75625661c7be8544fb and a sample YAML config file was added in this one 8eb7596678bc327ba55a477a4b6b51d54029f848

The parser facility is made of:

Errors are (or rather will be) handle throught the exception YamlException