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

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

implemented bootstrap info parser

File size: 1.3 KB
RevLine 
[2444]1
2#include "StringFormat.h"
3
4#include "boost/xpressive/xpressive.hpp"
5
[2452]6namespace ariba {
7namespace utility {
8namespace string_format {
9
[2444]10using namespace boost::xpressive;
11
12// regex: string
[2452]13const sregex rstring = '"' >> keep(*~(boost::xpressive::set = '"'))
[2444]14 >> '"';
15
16// regex: base64 encoding
[2452]17const sregex rbase64 = '!' >> +(range('a', 'z') | range('A', 'Z')
[2444]18 | range('0', '9') | '/' | '+') >> *(boost::xpressive::set = '=');
19
20// regex: raw alphabet
[2452]21const sregex rchars = +(range('a', 'z') | range('A', 'Z'));
[2444]22
23// regex: integer
[2452]24const sregex rint = '0' | (range('1', '9') >> !(range('0', '9')));
[2444]25
26// regex: binary label
[2452]27const sregex rlabel = rchars | rstring | rbase64;
[2444]28
29// regex: dot separated identifier
[2452]30const sregex rid = rlabel >> *('.' >> rlabel) >> *('.' >> rint);
[2444]31
32// regex: "leaf" data
[2452]33const sregex rdata = !(boost::xpressive::set = '!') >> '{'
[2444]34 >> *(keep(+~(boost::xpressive::set = '{', '}')) | by_ref(rdata))
35 >> '}';
36
37// regex: fields
[2452]38const sregex rfield_label = rlabel >> '=';
39const sregex rfield = !rfield_label >> (rid | rdata);
40const sregex rfields = '(' >> rfield >> *(',' >> rfield) >> ')';
[2444]41
[2452]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.