4#ifndef ROOT_TSchemaRuleProcessor
5#define ROOT_TSchemaRuleProcessor
28 std::list<std::string>& result,
33 std::string::size_type curr;
34 std::string::size_type last = 0;
35 std::string::size_type size;
40 while( last != source.size() ) {
41 curr = source.find( delimiter, last );
43 if( curr == std::string::npos ) {
44 curr = source.size()-1;
47 else size = curr-last;
49 elem =
Trim( source.substr( last, size ) );
51 result.push_back( elem );
58 std::list<std::pair<ROOT::Internal::TSchemaType,std::string> >& result)
64 std::string::size_type curr;
65 std::string::size_type last = 0;
66 std::string::size_type size;
73 while( last != source.size() ) {
75 curr = source.find(
';', last );
77 if( curr == std::string::npos ) {
78 curr = source.size()-1;
81 else size = curr-last;
84 elem =
Trim( source.substr( last, size ) );
86 unsigned int level = 0;
90 for(std::string::size_type j=elem.size(); j>0; --j) {
91 std::string::size_type i = j-1;
92 if (elem[i]==
'<') { ++level; }
93 else if (elem[i]==
'>') {
if (level==0) {
continue; } ; --level; }
94 else if (level == 0 && isspace(elem[i])) {
95 type = elem.substr( 0, i );
97 while( elem[i]==
'*' || elem[i]==
'&' || isspace(elem[i]) ) {
99 if (strcmp(
"const",elem.c_str()+i)==0 && (i+5)>elem.size()
100 && ( elem[i+5]==
'*' || elem[i+5]==
'&' || isspace(elem[i+5])) ) {
103 }
else if (elem[i]==
'*' || elem[i]==
'&') {
107 std::string::size_type endvar = i;
108 while( endvar!=elem.size() && elem[endvar] !=
'[' ) {
111 if (endvar != elem.size() ) {
112 dims =
Trim( elem.substr(endvar, elem.size()-endvar) );
114 elem =
Trim( elem.substr(i, endvar-i) );
125 static std::string
Trim(
const std::string& source )
130 std::string::size_type start, end;
131 for( start = 0; start < source.size(); ++start) {
132 if ( isspace(source[start]) ) {
134 }
else if ( source[start] ==
'\\' && (start+1)<source.size() && (source[start+1]==
'\n' || source[start+1]==
'\r') ) {
142 if( start == source.size() )
144 for( end = source.size()-1; end > start; --end ) {
145 if ( (source[end]==
'\n' || source[end]==
'\r') && end > (start+1) && source[end-1] ==
'\\' ) {
148 }
else if ( isspace(source[end]) ) {
155 return source.substr( start, end-start+1 );
160 std::pair<Int_t, Int_t>& result )
171 std::string::size_type hyphenI;
175 std::string version =
Trim( source );
177 if( version.empty() )
183 if( version ==
"*" ) {
185 result.second = 50000;
193 hyphenI = version.find(
'-' );
194 if( hyphenI == std::string::npos &&
IsANumber( version ) ) {
195 result.first = result.second = atoi( version.c_str() );
206 result.second = atoi(
second.c_str() );
214 if( hyphenI == version.size()-1 ) {
215 first =
Trim( version.substr( 0, version.size()-1 ) );
217 result.first = atoi(
first.c_str() );
218 result.second = 50000;
226 first =
Trim( version.substr( 0, hyphenI ) );
227 second =
Trim( version.substr( hyphenI+1, version.size()-hyphenI-1 ) );
229 result.first = atoi(
first.c_str() );
230 result.second = atoi(
second.c_str() );
239 static bool IsANumber(
const std::string& source,
bool acceptHex =
false )
244 if( acceptHex && source.size() > 2 && source[0] ==
'0' && source[1] ==
'x'
245 && std::all_of(source.begin()+2, source.end(), [](
unsigned char c){return std::isxdigit(c);}) )
248 return std::all_of(source.begin(), source.end(), [](
unsigned char c){return std::isdigit(c);});
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=',')
Namespace for new ROOT classes and functions.
static constexpr double second