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;
559 std::streampos initialPos(file.tellg());
560 const unsigned int lineCharsSize=1000;
561 char lineChars[lineCharsSize];
562 file.getline(lineChars,lineCharsSize);
563 std::string lineStr(lineChars);
565 while (lineStr ==
"" ||
566 std::count(lineStr.begin(),lineStr.end(),
' ') == (
int)lineStr.size()){
567 file.getline(lineChars,lineCharsSize);
571 size_t dataBeginPos = lineStr.find(
"<![CDATA[");
572 if (dataBeginPos==std::string::npos){
573 file.seekg(initialPos);
578 lineStr = lineStr.substr(dataBeginPos+9);
582 std::string codeAttrVal;
587 size_t dataEndPos = lineStr.find(
"]]>");
588 if (dataEndPos!=std::string::npos) {
590 codeAttrVal+=lineStr.substr(0,dataEndPos);
593 codeAttrVal+=lineStr;
595 file.getline(lineChars,lineCharsSize);
598 attrs.emplace_back(
"code", codeAttrVal);
694 bsrChild = vsr.get();
705 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);
720 bsrChild = fsr.get();
731 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);
783 attrs.emplace_back(
"fromTypedef",
"true");
824 std::string iAttrName;
825 std::string iAttrValue;
831 std::map<std::string,std::string> pragmaArgs;
832 for (
int i = 0,
n = attrs.size(); i <
n; ++i) {
833 pragmaArgs[attrs[i].fName]=attrs[i].fValue;
836 std::stringstream pragmaLineStream;
837 const std::string attrs[11] ={
"sourceClass",
849 for (
unsigned int i=0;i<11;++i) {
850 const std::string& attr = attrs[i];
851 if ( pragmaArgs.count(attr) == 1){
852 value = pragmaArgs[attr];
853 if (attr ==
"code") value=
"{"+value+
"}";
854 pragmaLineStream <<
" " << attr <<
"=\""<< value <<
"\"";
871 if (!tagStr.empty() && tagKind !=
kVersion) {
889 else if (tagKind ==
kClass) {
919 std::string iAttrName;
920 std::string iAttrValue;
921 for (
int i = 0,
n = attrs.size(); i <
n; ++i) {
922 iAttrName=attrs[i].fName;
923 iAttrValue=attrs[i].fValue;
927 "ClassVersion" == iAttrName){
939 std::string preExistingValue;
941 if (preExistingValue!=iAttrValue){
943 "Line %s: assigning new value %s to attribue %s (it was %s)\n",
944 lineNumCharp,iAttrValue.c_str(),iAttrName.c_str(),preExistingValue.c_str());
950 if ((iAttrName ==
"file_name" || iAttrName ==
"file_pattern") && tagKind ==
kClass){
957 std::string preExistingValue;
959 if (preExistingValue!=iAttrValue){
961 "Line %s: assigning new value %s to attribue %s (it was %s)\n",
962 lineNumCharp,iAttrValue.c_str(),iAttrName.c_str(),preExistingValue.c_str());
1005 if (sel && !selEnd) {
1010 if (excl && !exclEnd ) {
VariableSelectionRule EnumSelectionRule
void SetRequestStreamerInfo(bool needStreamerInfo)
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)
static std::map< std::string, ETagNames > fgMapTagNames
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)
bool GetAttributeValue(const std::string &attributeName, std::string &returnValue) const
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)
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
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)
bool HasAttributeWithName(const std::string &attributeName) const
cling::Interpreter & fInterp
bool Parse(const std::string &fileName, SelectionRules &out)