Overview

Description

This library provides a complete lexer/parser to produce a property abstract syntax tree according to the java properties grammar (https://docs.oracle.com/javase/8/docs/api/java/util/Properties.html).

It supports all kinds of properties configuration styles:

  • Common java properties

! Config file for mosquitto

retry_interval=20
#sys_interval=10

address=127.0.0.1:8085    \
        192.168.0.12:6036 \
        192.168.0.0:8036

auth_opt_db_host=127.0.0.1
auth_opt_db_port=80
auth_opt_db_username=john.doe
auth_opt_db_password=dummy
  • Linux configuration file

# Config file for mosquitto

retry_interval       20
#sys_interval        10

address              127.0.0.1:8085    \
                     192.168.0.12:6036 \
                     192.168.0.0:8036

auth_opt_db_host     127.0.0.1
auth_opt_db_port     80
auth_opt_db_username john.doe
auth_opt_db_password dummy
  • YAML like

# Config file for mosquitto

retry_interval:       20
#sys_interval:        10

address: 127.0.0.1:8085 192.168.0.12:6036 192.168.0.0:8036

auth_opt_db_host:     127.0.0.1
auth_opt_db_port:     80
auth_opt_db_username: john.doe
auth_opt_db_password: dummy

Requirements

The library requires only C++11

Header-Only

To use as header-only; that is, to eliminate the requirement to link a program to a static or dynamic cpp_properties library, simply place the following lines in exactly one new or existing source file in your project.

#include <cpp_properties/action/properties_action.hpp>
#include <cpp_properties/actor/properties_actor.hpp>
#include <cpp_properties/actor/traits/properties_actor_traits.hpp>
#include <cpp_properties/parser.hpp>

Dependencies

This library internally use Boost.Spirit/lex

Supported Compilers

GCC 5 or later with -std=c11 or above Clang 3.5 or later with -std=c11 or above Visual Studio 2015, 2017, 2019

Properties grammar

EBNF

  • properties

properties
  • comment

comment
  • space

space
  • end-of-property

end of property
  • end-of-line

end of line
  • blanks

blanks
  • line-break

line break
  • key

key
  • first-key-chars

first keys chars
  • key-chars

key chars
  • separator

separator
  • separator-blanks

separator blanks
  • separator-chars

separator chars
  • value

value
  • value-chars

value
  • escape

escape
  • escape-chars

escape chars
  • unicode

unicode
  • hexa-chars

hexa chars