4#ifndef ROOT_TSchemaRuleProcessor
5#define ROOT_TSchemaRuleProcessor
27 std::list<std::string>& result,
32 std::string::size_type curr;
33 std::string::size_type last = 0;
34 std::string::size_type
size;
39 while( last != source.size() ) {
40 curr = source.find( delimiter, last );
42 if( curr == std::string::npos ) {
43 curr = source.size()-1;
46 else size = curr-last;
48 elem =
Trim( source.substr( last,
size ) );
50 result.push_back( elem );
57 std::list<std::pair<ROOT::Internal::TSchemaType,std::string> >& result)
63 std::string::size_type curr;
64 std::string::size_type last = 0;
65 std::string::size_type
size;
72 while( last != source.size() ) {
74 curr = source.find(
';', last );
76 if( curr == std::string::npos ) {
77 curr = source.size()-1;
80 else size = curr-last;
83 elem =
Trim( source.substr( last,
size ) );
85 unsigned int level = 0;
89 for(std::string::size_type j=elem.size(); j>0; --j) {
90 std::string::size_type i = j-1;
91 if (elem[i]==
'<') { ++level; }
92 else if (elem[i]==
'>') {
if (level==0) {
continue; } ; --level; }
93 else if (level == 0 && isspace(elem[i])) {
94 type = elem.substr( 0, i );
96 while( elem[i]==
'*' || elem[i]==
'&' || isspace(elem[i]) ) {
98 if (strcmp(
"const",elem.c_str()+i)==0 && (i+5)>elem.size()
99 && ( elem[i+5]==
'*' || elem[i+5]==
'&' || isspace(elem[i+5])) ) {
102 }
else if (elem[i]==
'*' || elem[i]==
'&') {
106 std::string::size_type endvar = i;
107 while( endvar!=elem.size() && elem[endvar] !=
'[' ) {
110 if (endvar != elem.size() ) {
111 dims =
Trim( elem.substr(endvar, elem.size()-endvar) );
113 elem =
Trim( elem.substr(i, endvar-i) );
124 static std::string
Trim(
const std::string& source )
129 std::string::size_type start, end;
130 for( start = 0; start < source.size(); ++start) {
131 if ( isspace(source[start]) ) {
133 }
else if ( source[start] ==
'\\' && (start+1)<source.size() && (source[start+1]==
'\n' || source[start+1]==
'\r') ) {
141 if( start == source.size() )
143 for( end = source.size()-1; end > start; --end ) {
144 if ( (source[end]==
'\n' || source[end]==
'\r') && end > (start+1) && source[end-1] ==
'\\' ) {
147 }
else if ( isspace(source[end]) ) {
154 return source.substr( start, end-start+1 );
159 std::pair<Int_t, Int_t>& result )
170 std::string::size_type hyphenI;
174 std::string version =
Trim( source );
176 if( version.empty() )
182 if( version ==
"*" ) {
184 result.second = 50000;
192 hyphenI = version.find(
'-' );
193 if( hyphenI == std::string::npos &&
IsANumber( version ) ) {
194 result.first = result.second = atoi( version.c_str() );
202 second =
Trim( version.substr( 1 ) );
205 result.second = atoi( second.c_str() );
213 if( hyphenI == version.size()-1 ) {
214 first =
Trim( version.substr( 0, version.size()-1 ) );
216 result.first = atoi(
first.c_str() );
217 result.second = 50000;
225 first =
Trim( version.substr( 0, hyphenI ) );
226 second =
Trim( version.substr( hyphenI+1, version.size()-hyphenI-1 ) );
228 result.first = atoi(
first.c_str() );
229 result.second = atoi( second.c_str() );
238 static bool IsANumber(
const std::string& source,
bool acceptHex =
false )
243 if( acceptHex && source.size() > 2 && source[0] ==
'0' && source[1] ==
'x'
244 && std::all_of(source.begin()+2, source.end(), [](
unsigned char c){return std::isxdigit(c);}) )
247 return std::all_of(source.begin(), source.end(), [](
unsigned char c){return std::isdigit(c);});
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
static bool IsANumber(const std::string &source, bool acceptHex=false)
Check if given string consists of digits.
static std::string Trim(const std::string &source)
static void SplitDeclaration(const std::string &source, std::list< std::pair< ROOT::Internal::TSchemaType, std::string > > &result)
static bool ProcessVersion(const std::string &source, std::pair< Int_t, Int_t > &result)
static void SplitList(const std::string &source, std::list< std::string > &result, char delimiter=',')
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...