source: source/ariba/utility/misc/StringFormat.cpp@ 7042

Last change on this file since 7042 was 2452, checked in by mies, 16 years ago

implemented bootstrap info parser

File size: 1.3 KB
Line 
1
2#include "StringFormat.h"
3
4#include "boost/xpressive/xpressive.hpp"
5
6namespace ariba {
7namespace utility {
8namespace string_format {
9
10using namespace boost::xpressive;
11
12// regex: string
13const sregex rstring = '"' >> keep(*~(boost::xpressive::set = '"'))
14 >> '"';
15
16// regex: base64 encoding
17const sregex rbase64 = '!' >> +(range('a', 'z') | range('A', 'Z')
18 | range('0', '9') | '/' | '+') >> *(boost::xpressive::set = '=');
19
20// regex: raw alphabet
21const sregex rchars = +(range('a', 'z') | range('A', 'Z'));
22
23// regex: integer
24const sregex rint = '0' | (range('1', '9') >> !(range('0', '9')));
25
26// regex: binary label
27const sregex rlabel = rchars | rstring | rbase64;
28
29// regex: dot separated identifier
30const sregex rid = rlabel >> *('.' >> rlabel) >> *('.' >> rint);
31
32// regex: "leaf" data
33const sregex rdata = !(boost::xpressive::set = '!') >> '{'
34 >> *(keep(+~(boost::xpressive::set = '{', '}')) | by_ref(rdata))
35 >> '}';
36
37// regex: fields
38const sregex rfield_label = rlabel >> '=';
39const sregex rfield = !rfield_label >> (rid | rdata);
40const sregex rfields = '(' >> rfield >> *(',' >> rfield) >> ')';
41
42// regex objects
43const sregex robject_data = (rdata | rfields);
44const sregex robject_id = rid;
45const sregex robject = robject_id >> robject_data;
46const sregex robjects = robject >> *(',' >> robject);
47
48}}}
Note: See TracBrowser for help on using the repository browser.