root/lang/objective-cplusplus/i3/trunk/src/ConfigFile.h @ 34447

Revision 34447, 1.4 kB (checked in by saturday06, 5 years ago)

iojasdfaodfd

Line 
1#pragma once
2#include "Common.h"
3#include <boost/preprocessor/cat.hpp>
4#include <boost/preprocessor/seq/for_each.hpp>
5#include <boost/preprocessor/control/if.hpp>
6#include <boost/cstdint.hpp>
7
8#define I3_CONFIG_integer       0
9#define I3_CONFIG_string        1
10#define I3_CONFIG_integer_array 2
11#define I3_CONFIG_string_array  3
12
13#define CONFIG_MEMBER(type, name) ((I3_CONFIG_##type, name, #name))
14
15#define CONFIG_MEMBERS \
16    CONFIG_MEMBER(integer,       integer_key) \
17    CONFIG_MEMBER(string ,       string_key) \
18    CONFIG_MEMBER(integer_array, integer_array_key) \
19    CONFIG_MEMBER(string_array,  string_array_key)
20
21namespace i3 {
22
23struct Config {
24    ////MACRO WILL BE EXPANDED
25    //boost::int32_t i;
26    //TCHAR* s;
27    //std::vector<boost::int32_t> ia;
28    //std::vector<TCHAR*> sa;
29
30#define I3_CONFIG_MACRO(r, data, elem) \
31            BOOST_PP_IF(BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(3, 0, elem), I3_CONFIG_integer) , boost::int32_t, \
32                    BOOST_PP_IF(BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(3, 0, elem), I3_CONFIG_string) , TCHAR*, \
33                        BOOST_PP_IF(BOOST_PP_EQUAL(BOOST_PP_TUPLE_ELEM(3, 0, elem), I3_CONFIG_integer_array) , std::vector<boost::int32_t>, std::vector<TCHAR*>))) \
34            BOOST_PP_TUPLE_ELEM(3, 1, elem);
35
36    BOOST_PP_SEQ_FOR_EACH(I3_CONFIG_MACRO, data, CONFIG_MEMBERS)
37    ;
38};
39
40
41Config parse_config(const TCHAR* str);
42
43}
44
Note: See TracBrowser for help on using the browser.