Index: source/ariba/utility/misc/StringFormat.cpp
===================================================================
--- source/ariba/utility/misc/StringFormat.cpp	(revision 2444)
+++ source/ariba/utility/misc/StringFormat.cpp	(revision 2452)
@@ -4,38 +4,45 @@
 #include "boost/xpressive/xpressive.hpp"
 
+namespace ariba {
+namespace utility {
+namespace string_format {
+
 using namespace boost::xpressive;
 
 // regex: string
-const sregex StringFormat::rstring = '"' >> keep(*~(boost::xpressive::set = '"'))
+const sregex rstring = '"' >> keep(*~(boost::xpressive::set = '"'))
 		>> '"';
 
 // regex: base64 encoding
-const sregex StringFormat::rbase64 = '!' >> +(range('a', 'z') | range('A', 'Z')
+const sregex rbase64 = '!' >> +(range('a', 'z') | range('A', 'Z')
 		| range('0', '9') | '/' | '+') >> *(boost::xpressive::set = '=');
 
 // regex: raw alphabet
-const sregex StringFormat::rchars = +(range('a', 'z') | range('A', 'Z'));
+const sregex rchars = +(range('a', 'z') | range('A', 'Z'));
 
 // regex: integer
-const sregex StringFormat::rint = '0' | (range('1', '9') >> !(range('0', '9')));
+const sregex rint = '0' | (range('1', '9') >> !(range('0', '9')));
 
 // regex: binary label
-const sregex StringFormat::rlabel = rchars | rstring | rbase64;
+const sregex rlabel = rchars | rstring | rbase64;
 
 // regex: dot separated identifier
-const sregex StringFormat::rid = rlabel >> *('.' >> rlabel) >> *('.' >> rint);
+const sregex rid = rlabel >> *('.' >> rlabel) >> *('.' >> rint);
 
 // regex: "leaf" data
-const sregex StringFormat::rdata = !(boost::xpressive::set = '!') >> '{'
+const sregex rdata = !(boost::xpressive::set = '!') >> '{'
 		>> *(keep(+~(boost::xpressive::set = '{', '}')) | by_ref(rdata))
 		>> '}';
 
 // regex: fields
-const sregex StringFormat::rfield_label = rlabel >> '=';
-const sregex StringFormat::rfield = !rfield_label >> (rid | rdata);
-const sregex StringFormat::rfields = '(' >> rfield >> *(',' >> rfield) >> ')';
+const sregex rfield_label = rlabel >> '=';
+const sregex rfield = !rfield_label >> (rid | rdata);
+const sregex rfields = '(' >> rfield >> *(',' >> rfield) >> ')';
 
-// regex: objects
-const sregex StringFormat::robject_data = (rdata | rfields);
-const sregex StringFormat::robject = rid >> robject_data;
-const sregex StringFormat::robjects = robject >> *(',' >> robject);
+// regex objects
+const sregex robject_data = (rdata | rfields);
+const sregex robject_id = rid;
+const sregex robject = robject_id >> robject_data;
+const sregex robjects = robject >> *(',' >> robject);
+
+}}}
Index: source/ariba/utility/misc/StringFormat.h
===================================================================
--- source/ariba/utility/misc/StringFormat.h	(revision 2444)
+++ source/ariba/utility/misc/StringFormat.h	(revision 2452)
@@ -5,44 +5,90 @@
 #include "boost/xpressive/xpressive.hpp"
 
+namespace ariba {
+namespace utility {
+namespace string_format {
+
 using boost::xpressive::sregex;
 
-/**
- * This class defines some regular expressions ...
- *
- * @author Sebastian Mies
- */
-class StringFormat {
+class regex_nav {
+private:
+	typedef boost::xpressive::smatch _match;
+	typedef _match::nested_results_type nested_results;
+	typedef nested_results::const_iterator nested_iterator;
+	const _match& match;
+
 public:
-	// regex: string
-	static const sregex rstring;
+	regex_nav(const _match& match) :
+		match(match) {
+	}
 
-	// regex: base64 encoding
-	static const sregex rbase64;
+	regex_nav() :
+		match(*((const _match*) NULL)) {
+	}
 
-	// regex: raw alphabet
-	static const sregex rchars;
+	bool matched() const {
+		return &match != NULL;
+	}
 
-	// regex: integer
-	static const sregex rint;
+	regex_nav operator[] (const sregex& type) const {
+		const nested_results& nr = match.nested_results();
+		for (nested_iterator i = nr.begin(); i != nr.end(); i++) {
+			if (i->regex_id() == type.regex_id()) return regex_nav(*i);
+		}
+		return regex_nav();
+	}
 
-	// regex: binary label
-	static const sregex rlabel;
+	regex_nav operator[](int index) const {
+		const nested_results& nr = match.nested_results();
+		for (nested_iterator i = nr.begin(); i != nr.end() && index >= 0; i++) {
+			if (index == 0) return regex_nav(*i);
+			index--;
+		}
+		return regex_nav();
+	}
 
-	// regex: dot separated identifier
-	static const sregex rid;
+	int size() const {
+		return match.nested_results().size();
+	}
 
-	// regex: "leaf" data
-	static const sregex rdata;
-
-	// regex: fields
-	static const sregex rfield_label;
-	static const sregex rfield;
-	static const sregex rfields;
-
-	// regex: objects
-	static const sregex robject_data;
-	static const sregex robject;
-	static const sregex robjects;
+	std::string str() const {
+		if (!matched()) return std::string("<no match>");
+		return match[0].str();
+	}
 };
 
+// regex: string
+extern const sregex rstring;
+
+// regex: base64 encoding
+extern const sregex rbase64;
+
+// regex: raw alphabet
+extern const sregex rchars;
+
+// regex: integer
+extern const sregex rint;
+
+// regex: binary label
+extern const sregex rlabel;
+
+// regex: dot separated identifier
+extern const sregex rid;
+
+// regex: "leaf" data
+extern const sregex rdata;
+
+// regex: fields
+extern const sregex rfield_label;
+extern const sregex rfield;
+extern const sregex rfields;
+
+// regex: objects
+extern const sregex robject_data;
+extern const sregex robject_id;
+extern const sregex robject;
+extern const sregex robjects;
+
+}}}
+
 #endif /* STRINGFORMAT_H_ */
