AnCH Framework  0.1
Another C++ Hack Framework
AnCH resource library documentation

Table of Contents

Introduction

AnCh resource library aims to provide facilities to handle resource/configuration files.

Prerequisites

Installation

TODO fill this section

Conception

AnCH resource library is a thread safe configuration files management library.
Every resources will be store in application cache and will be available with static methods.

Configuration files has to be formatted with classic key=value syntax. It supports comments with # character.
Resource files can also contains categories which will be declared between brackets.

Configuration file example:

# Some comment
key=value
key1=value1
[category]
key=value # Other comment
key2=value2


Library interface is done in a single class: anch::resource::Resource.
Resource files are retrieved through getResource static method which returns a anch::resource::Resource instance.
Resource parameters are retrieved through getParameter method.

Example

Resource file "test.ini":

# Comments
toto=tata
tata=tutu # test with comments
[TOTO]
toto=titi


C++ example:

#include <iostream>
#include "resource/resource.hpp"
using std::cout;
using std::endl;
using std::string;
int
main(void) {
cout << "Enter in test resource" << endl;
cout << "Parse file" << endl;
const Resource& res = Resource::getResource("test.ini");
cout << "File has been parsed" << endl;
string value;
bool found = res.getParameter(value,"toto");
if(found) {
cout << "toto=" << value << endl;
} else {
cout << "toto has not been found" << endl;
}
found = res.getParameter(value,"toto","TOTO");
if(found) {
cout << "TOTO/toto=" << value << endl;
} else {
cout << "TOTO/toto has not been found" << endl;
}
found = res.getParameter(value,"tata");
if(found) {
cout << "tata=" << value << endl;
} else {
cout << "tata has not been found" << endl;
}
cout << "Exit test resource" << endl;
return 0;
}