32 XMLReader::fgMapTagNames[
"class"] =
kClass;
33 XMLReader::fgMapTagNames[
"/class"] =
kEndClass;
34 XMLReader::fgMapTagNames[
"struct"] =
kClass;
35 XMLReader::fgMapTagNames[
"/struct"] =
kEndClass;
36 XMLReader::fgMapTagNames[
"namespace"] =
kClass;
37 XMLReader::fgMapTagNames[
"/namespace"] =
kEndClass;
38 XMLReader::fgMapTagNames[
"function"] =
kFunction;
39 XMLReader::fgMapTagNames[
"variable"] =
kVariable;
40 XMLReader::fgMapTagNames[
"enum"] =
kEnum;
41 XMLReader::fgMapTagNames[
"method"] =
kMethod;
42 XMLReader::fgMapTagNames[
"/method"] =
kEndMethod;
43 XMLReader::fgMapTagNames[
"field"] =
kField;
44 XMLReader::fgMapTagNames[
"/field"] =
kEndField;
45 XMLReader::fgMapTagNames[
"member"] =
kField;
46 XMLReader::fgMapTagNames[
"/member"] =
kEndField;
47 XMLReader::fgMapTagNames[
"lcgdict"] =
kLcgdict;
49 XMLReader::fgMapTagNames[
"rootdict"] =
kLcgdict;
50 XMLReader::fgMapTagNames[
"/rootdict"] =
kEndLcgdict;
51 XMLReader::fgMapTagNames[
"selection"] =
kSelection;
53 XMLReader::fgMapTagNames[
"exclusion"] =
kExclusion;
55 XMLReader::fgMapTagNames[
"properties"] =
kProperties;
56 XMLReader::fgMapTagNames[
"version"] =
kVersion;
58 XMLReader::fgMapTagNames[
"/ioread"] =
kEndIoread;
60 XMLReader::fgMapTagNames[
"/read"] =
kEndIoread;
63 XMLReader::fgMapTagNames[
"typedef"] =
kTypedef;
76 bool angleBraceLevel =
false;
79 bool tagIsComment =
false;
81 bool tagIsXMLDecl =
false;
83 bool isInlineComment =
false ;
94 for (;i<3 && file.good();++i){
97 if (pattern ==
"lt;"){
100 else if (pattern ==
"gt;"){
104 for (;i!=0 && file.good();--i){
118 case '\n': ++lineCount;
120 case '"': quotes = !quotes;
123 if (!quotes) angleBraceLevel = !angleBraceLevel;
124 if (!angleBraceLevel && !comment)
return false;
127 if (!quotes && !comment) angleBraceLevel = !angleBraceLevel;
128 if (!angleBraceLevel && !comment) br =
true;
129 if (!angleBraceLevel && comment && charMinus2==
'-' && charMinus1==
'-') br =
true;
130 if (charMinus2==
'-' && charMinus1==
'-'){
131 if (comment) { tagIsComment=
true; br=
true; }
132 else {
return false; }
134 if (charMinus1==
'?'){
135 if (xmlDecl) {tagIsXMLDecl=
true;br=
true;}
140 if (charMinus3==
'<' && charMinus2==
'!' && charMinus1==
'-') comment = !
comment;
143 if (charMinus1==
'<') xmlDecl=!xmlDecl;
146 if (charMinus1==
'/' && !angleBraceLevel && !comment){
147 isInlineComment=
true;
155 if (isInlineComment){
156 out.erase(out.size()-1,1);
157 while (file.good() && c!=
'\n'){
162 charMinus3=charMinus2;
163 charMinus2=charMinus1;
166 if (comment && !(charMinus3==
'-' && charMinus2==
'-' && charMinus1==
'>')){
177 int startpos = out.find_first_not_of(
" \t\n");
178 int endpos = out.find_last_not_of(
" \t\n");
181 if (((
int) std::string::npos == startpos ) || ((
int) std::string::npos == endpos))
186 out = out.substr( startpos, endpos-startpos+1 );
191 if (tagIsComment || tagIsXMLDecl){
217 if (tag.at(0) !=
'<'){
223 if (isspace(tag.at(1))){
224 ROOT::TMetaUtils::Error(0,
"Malformed tag %s (there should be no white-spaces between < and name-of-tag)!\n", tag.c_str());
230 for (std::string::size_type i = tag.length()-2;
true ; --i) {
237 if (c ==
'/' && countWSp>0) {
238 ROOT::TMetaUtils::Error(0,
"Malformed tag %s (there should be no white-spaces between / and >)!\n", tag.c_str());
251 int pos1 = tag.find(
">");
253 for (std::string::size_type i = pos1+1, e = tag.length(); i < e; ++i) {
277 std::string tagEnd = tag.substr(tag.length()-2, 2);
278 return (tagEnd ==
"/>");
287 std::string tagBegin = tag.substr(0, 2);
288 return (tagBegin ==
"</");
298 for (std::string::size_type i = 0, e = tag.length(); i < e; ++i) {
300 if (isspace(c))
break;
301 if ((c !=
'<') && (c !=
'>'))
305 std::map<std::string, ETagNames>::iterator it;
306 it = XMLReader::fgMapTagNames.find(name);
307 if (it != XMLReader::fgMapTagNames.end())
308 return XMLReader::fgMapTagNames[
name];
330 std::string::size_type cutend = tag.length() - 1 - name.length();
331 if (standalone) --cutend;
332 std::string attrstr = tag.substr(1 + name.length(), cutend);
334 if (attrstr.length() > 4) {
336 int pos = attrstr.find_last_not_of(
" \t\n");
337 attrstr = attrstr.substr(1, pos+1);
346 std::string attrtemp;
347 bool namefound =
false;
348 bool equalfound =
false;
351 bool inString =
false;
352 std::string attr_name;
353 std::string attr_value;
354 char lastsymbol =
'\0';
356 for (std::string::size_type i = 0, e = attrstr.length()-1; i < e; ++i) {
373 else if (isspace(c) && !inString)
continue;
377 if (namefound && equalfound){
383 if (attr_name.length() == 0) {
403 if (attr_name==
"pattern" && attr_value.find(
"*") == std::string::npos){
404 ROOT::TMetaUtils::Warning(0,
"At line %s. A pattern, \"%s\", without wildcards is being used. This selection rule would not have any effect. Transforming it to a rule based on name.\n", lineNum, attr_value.c_str());
407 out.emplace_back(attr_name, attr_value);
422 else if (lastsymbol ==
'=') {
428 else if ((newattr || namefound) && !value){
439 if (namefound && (!equalfound || !value)) {
456 std::ifstream file(fileName);
461 bool exclusion =
false;
462 bool selection =
false;
465 bool exclEnd =
false;
467 bool inIoread =
false;
468 bool inClass =
false;
469 bool inMethod =
false;
470 bool inField =
false;
474 std::unique_ptr<ClassSelectionRule> csr;
475 std::unique_ptr<FunctionSelectionRule> fsr;
476 std::unique_ptr<VariableSelectionRule> vsr;
477 std::unique_ptr<EnumSelectionRule> esr;
482 bool tagOK =
GetNextTag(file, tagStr, lineNum);
484 const char* tagStrCharp = tagStr.c_str();
486 std::ostringstream buf;
488 std::string lineNumStr = buf.str();
489 const char* lineNumCharp = lineNumStr.c_str();
496 if (!tagStr.empty()){
497 std::vector<Attributes> attrs;
558 std::streampos initialPos(file.tellg());
559 const unsigned int lineCharsSize=1000;
560 char lineChars[lineCharsSize];
561 file.getline(lineChars,lineCharsSize);
562 std::string lineStr(lineChars);
564 while (lineStr ==
"" ||
565 std::count(lineStr.begin(),lineStr.end(),
' ') == (
int)lineStr.size()){
566 file.getline(lineChars,lineCharsSize);
570 size_t dataBeginPos = lineStr.find(
"<![CDATA[");
571 if (dataBeginPos==std::string::npos){
572 file.seekg(initialPos);
577 lineStr = lineStr.substr(dataBeginPos+9);
581 std::string codeAttrVal;
586 size_t dataEndPos = lineStr.find(
"]]>");
587 if (dataEndPos!=std::string::npos) {
589 codeAttrVal+=lineStr.substr(0,dataEndPos);
592 codeAttrVal+=lineStr;
594 file.getline(lineChars,lineCharsSize);
597 attrs.emplace_back(
"code", codeAttrVal);
693 bsrChild = vsr.get();
704 ROOT::TMetaUtils::Info(0,
"At line %s. A field is not supposed to have an end-tag (this message will become a warning).\n", lineNumCharp);
719 bsrChild = fsr.get();
730 ROOT::TMetaUtils::Info(0,
"At line %s. A method is not supposed to have an end-tag (this message will become a warning).\n", lineNumCharp);
782 attrs.emplace_back(
"fromTypedef",
"true");
823 std::string iAttrName;
824 std::string iAttrValue;
830 std::map<std::string,std::string> pragmaArgs;
831 for (
int i = 0,
n = attrs.size(); i <
n; ++i) {
832 pragmaArgs[attrs[i].fName]=attrs[i].fValue;
835 std::stringstream pragmaLineStream;
836 const std::string attrs[11] ={
"sourceClass",
848 for (
unsigned int i=0;i<11;++i) {
849 const std::string&
attr = attrs[i];
850 if ( pragmaArgs.count(attr) == 1){
851 value = pragmaArgs[
attr];
852 if (attr ==
"code") value=
"{"+value+
"}";
853 pragmaLineStream <<
" " << attr <<
"=\""<< value <<
"\"";
870 if (!tagStr.empty() && tagKind !=
kVersion) {
888 else if (tagKind ==
kClass) {
918 std::string iAttrName;
919 std::string iAttrValue;
920 for (
int i = 0,
n = attrs.size(); i <
n; ++i) {
921 iAttrName=attrs[i].fName;
922 iAttrValue=attrs[i].fValue;
926 "ClassVersion" == iAttrName){
938 std::string preExistingValue;
940 if (preExistingValue!=iAttrValue){
942 "Line %s: assigning new value %s to attribue %s (it was %s)\n",
943 lineNumCharp,iAttrValue.c_str(),iAttrName.c_str(),preExistingValue.c_str());
949 if ((iAttrName ==
"file_name" || iAttrName ==
"file_pattern") && tagKind ==
kClass){
956 std::string preExistingValue;
958 if (preExistingValue!=iAttrValue){
960 "Line %s: assigning new value %s to attribue %s (it was %s)\n",
961 lineNumCharp,iAttrValue.c_str(),iAttrName.c_str(),preExistingValue.c_str());
1004 if (sel && !selEnd) {
1009 if (excl && !exclEnd ) {
bool GetAttributeValue(const std::string &attributeName, std::string &returnValue) const
VariableSelectionRule EnumSelectionRule
static bool GetAttributes(const std::string &tag, std::vector< Attributes > &out, const char *lineNum)
static bool GetNextTag(std::ifstream &file, std::string &out, int &lineCount)
void SetHasFileNameRule(bool file_rule)
ClassImp(TIterator) Bool_t TIterator return false
Compare two iterator objects.
static std::map< std::string, ETagNames > fgMapTagNames
bool HasAttributeWithName(const std::string &attributeName) const
static bool IsStandaloneTag(const std::string &tag)
void ClearSelectionRules()
void AddFunctionSelectionRule(const FunctionSelectionRule &funcSel)
static void PopulateMap()
The class representing the collection of selection rules.
static bool IsClosingTag(const std::string &tag)
void AddMethodSelectionRule(const FunctionSelectionRule &method)
void AddFieldSelectionRule(const VariableSelectionRule &field)
void SetRequestedVersionNumber(int version)
void AddVariableSelectionRule(const VariableSelectionRule &varSel)
void ProcessReadRawPragma(const char *args)
I am being called then a readraw pragma is encountered.
void ProcessReadPragma(const char *args)
I am being called when a read pragma is encountered.
void SetSelected(ESelect sel)
void AddClassSelectionRule(const ClassSelectionRule &classSel)
void AddEnumSelectionRule(const EnumSelectionRule &enumSel)
VariableSelectionRule FunctionSelectionRule
void SetAttributeValue(const std::string &attributeName, const std::string &attributeValue)
static bool CheckIsTagOK(const std::string &tag)
static ETagNames GetNameOfTag(const std::string &tag, std::string &name)
cling::Interpreter & fInterp
bool Parse(const std::string &fileName, SelectionRules &out)