31 const std::vector<std::pair<std::string, std::string>>
subPairs { {
"\\",
"\"},
51 typedef std::list<std::pair<ROOT::Internal::TSchemaType,std::string> >
SourceTypeList_t;
66 if (
command.length() == 0)
return std::string::npos;
67 std::string::size_type
cursor;
68 unsigned int level = 0;
75 case '=':
if (level==0) {
88 case '<': ++level;
break;
89 case '>':
if (level==0) {
return std::string::npos; }
107 std::string::size_type
l=0;
164 std::string::size_type pos =
command.find(
'=' );
170 if( pos == std::string::npos ) {
187 error_string =
"Parsing error, wrond or no value specified for key: " + key;
197 if( key ==
"code" ) {
213 error_string =
"Parsing error while processing key: code\n";
214 error_string +=
"Expected \"{ at the beginning of the value.";
218 if(
l == std::string::npos ) {
219 error_string =
"Parsing error while processing key: \"" + key +
"\"\n";
220 error_string +=
"Expected }\" at the end of the value.";
235 if (
l == std::string::npos ) {
236 error_string =
"\nParsing error while processing key: \"" + key +
"\"\n";
243 if (
l == std::string::npos)
l =
command.size();
256 std::map<std::string, std::string>::const_iterator
it1;
259 std::map<std::string, std::string>::const_iterator
it2;
266 result[
"version"] =
"[1-]";
280 [](
char c){ return c ==
';';},
297 std::map<std::string, std::string>::const_iterator
it1,
it2;
298 std::list<std::string>
lst;
300 it1 =
rule.find(
"targetClass" );
302 error_string =
"You always have to specify the targetClass ";
308 std::string warning =
"IO rule for class " + className;
314 it1 =
rule.find(
"sourceClass" );
317 error_string = warning +
" - sourceClass parameter is missing";
328 error_string = warning +
" - you need to specify either version or ";
338 if(
it2->second.size() < 2 ||
it2->second[0] !=
'[' ||
339 it2->second[
it2->second.size()-1] !=
']' ) {
340 error_string = warning +
" - a comma separated list of ints";
341 error_string +=
" enclosed in square brackets expected";
349 error_string += warning +
" - the list of checksums is empty\n";
352 for(
const auto&
chk :
lst ) {
355 error_string +=
" of checksum parameter - an integer (decimal/hex) expected";
365 std::pair<Int_t, Int_t>
ver;
367 if(
it1->second.size() < 2 ||
it1->second[0] !=
'[' ||
368 it1->second[
it1->second.size()-1] !=
']' ) {
369 error_string = warning +
" - a comma separated list of version specifiers ";
378 error_string = warning +
" - the list of versions is empty";
400 std::string keys[] = {
"target",
"source"};
401 for(
int i = 0; i < 2; ++i ) {
404 error_string = warning +
" - required parameter is missing: ";
418 SourceTypeList_t::const_iterator it;
420 if ( ( it->first.fType ==
"" && it->second !=
"") ) {
421 error_string = warning +
" - type required when listing a rule's source: ";
437 error_string = warning +
" - true or false expected as a value ";
449 if(
it1->second.empty() ) {
450 error_string = warning +
" - the include list is empty";
465 std::list<std::string>
mem;
466 std::list<std::string>::iterator it;
478 +
" data member: " + *it +
" was specified as a "
479 "target in the rule but doesn't seem to appear in "
493 std::string& className, std::string&
mappedName,
498 SourceTypeList_t::const_iterator it;
506 output <<
"#if 0" << std::endl;
509 output <<
"static Int_t id_" << it->second <<
" = oldObj->GetId(";
510 output <<
"\"" << it->second <<
"\");" << std::endl;
512 if( it->first.fType !=
"" )
515 output <<
"#endif" << std::endl;
532 if( it->first.fType.size() ) {
533 if ( it->first.fDimensions.size() ) {
534 output <<
" typedef " << it->first.fType;
535 output <<
" onfile_" << it->second <<
"_t" << it->first.fDimensions <<
";\n";
537 output <<
"onfile_" << it->second <<
"_t &" << it->second <<
";\n";
541 output << it->first.fType <<
" &" << it->second <<
";\n";
552 if( it->first.fType.size() == 0)
560 if (it->first.fDimensions.size() == 0) {
561 output << it->first.fType <<
" &onfile_" << it->second;
563 output <<
" onfile_" << it->second <<
"_t" <<
" &onfile_" << it->second;
573 if( it->first.fType ==
"" )
581 output << it->second <<
"(onfile_" << it->second <<
")";
593 output <<
"_" << it->second <<
" = oldObj->GetClass()->GetDataMemberOffset(\"";
594 output << it->second <<
"\");\n";
596 output <<
" " <<
"char *onfile_add = (char*)oldObj->GetObject();\n";
600 if( it->first.fType ==
"" )
611 if (it->first.fDimensions.size() == 0) {
612 output << it->first.fType;
616 output <<
"*)(onfile_add+offset_Onfile_";
628 output <<
" static TClassRef cls(\"";
629 output << className <<
"\");" << std::endl;
631 std::list<std::string>::const_iterator it;
634 output <<
" static Long_t offset_" << *it <<
" = ";
635 output <<
"cls->GetDataMemberOffset(\"" << *it <<
"\");";
637 if (
memData.fDimensions.size()) {
638 output <<
" typedef " <<
memData.fType <<
" " << *it <<
"_t" <<
memData.fDimensions <<
";" << std::endl;
639 output <<
" " << *it <<
"_t& " << *it <<
" = ";
640 output <<
"*(" << *it <<
"_t *)(target+offset_" << *it;
641 output <<
");" << std::endl;
644 output <<
"*(" <<
memData.fType <<
"*)(target+offset_" << *it;
645 output <<
");" << std::endl;
659 std::string className =
rule[
"targetClass"];
665 std::ostringstream func;
667 rule[
"funcname"] = func.str();
673 output <<
" static void " << func.str();
674 output <<
"( char* target, TVirtualObject *oldObj )" << std::endl;
675 output <<
" {" << std::endl;
676 output <<
" //--- Automatically generated variables ---" << std::endl;
682 std::list<std::pair<ROOT::Internal::TSchemaType,std::string> >
source;
683 std::list<std::string>
target;
688 output <<
" " << className <<
"* newObj = (" << className;
689 output <<
"*)target;" << std::endl;
690 output <<
" // Supress warning message.\n";
691 output <<
" " <<
"(void)oldObj;\n\n";
692 output <<
" " <<
"(void)newObj;\n\n";
698 output <<
" //--- User's code ---" << std::endl;
700 output <<
" }" << std::endl;
712 std::string className =
rule[
"targetClass"];
718 std::ostringstream func;
720 rule[
"funcname"] = func.str();
726 output <<
" static void " << func.str();
727 output <<
"( char* target, TBuffer &b )" << std::endl;
728 output <<
" {" << std::endl;
729 output <<
"#if 0" << std::endl;
730 output <<
" //--- Automatically generated variables ---" << std::endl;
736 std::list<std::pair<ROOT::Internal::TSchemaType,std::string> >
source;
737 std::list<std::string>
target;
741 output <<
" " << className <<
"* newObj = (" << className;
742 output <<
"*)target;" << std::endl << std::endl;
748 output <<
" //--- User's code ---" << std::endl;
750 output <<
"#endif" << std::endl;
751 output <<
" }" << std::endl;
758 const std::string&
tr )
760 std::string::size_type it = 0;
761 std::string::size_type s =
pat.size();
762 std::string::size_type
tr_len=
tr.size();
768 if( it == std::string::npos )
771 proc.replace( it, s,
tr );
782 std::list<SchemaRuleMap_t>::iterator it;
791 output <<
"];" << std::endl;
797 output <<
" rule->fSourceClass = \"" << (*it)[
"sourceClass"];
798 output <<
"\";" << std::endl;
800 if( it->find(
"target" ) != it->end() ) {
801 output <<
" rule->fTarget = \"" << (*it)[
"target"];
802 output <<
"\";" << std::endl;
805 if( it->find(
"source" ) != it->end() ) {
806 output <<
" rule->fSource = \"" << (*it)[
"source"];
807 output <<
"\";" << std::endl;
814 if( it->find(
"funcname" ) != it->end() ) {
815 std::string code = (*it)[
"code"];
819 output <<
" rule->fFunctionPtr = (void *)TFunc2void( ";
820 output << (*it)[
"funcname"] <<
");" << std::endl;
821 output <<
" rule->fCode = \"" << code;
822 output <<
"\";" << std::endl;
825 if( it->find(
"version" ) != it->end() ) {
826 output <<
" rule->fVersion = \"" << (*it)[
"version"];
827 output <<
"\";" << std::endl;
830 if( it->find(
"checksum" ) != it->end() ) {
831 output <<
" rule->fChecksum = \"" << (*it)[
"checksum"];
832 output <<
"\";" << std::endl;
835 if( it->find(
"embed" ) != it->end() ) {
836 output <<
" rule->fEmbed = " << (*it)[
"embed"];
837 output <<
";" << std::endl;
840 if( it->find(
"include" ) != it->end() ) {
841 output <<
" rule->fInclude = \"" << (*it)[
"include"];
842 output <<
"\";" << std::endl;
845 if( it->find(
"attributes" ) != it->end() ) {
846 output <<
" rule->fAttributes = \"" << (*it)[
"attributes"];
847 output <<
"\";" << std::endl;
857 std::list<std::string> tmp;
858 std::list<SchemaRuleMap_t>::iterator
rule;
859 SchemaRuleMap_t::iterator
attr;
860 SchemaRuleClassMap_t::iterator it;
867 for(
rule = it->second.begin();
rule != it->second.end(); ++
rule ) {
871 result.splice(
result.begin(), tmp, tmp.begin(), tmp.end() );
880 for(
rule = it->second.begin();
rule != it->second.end(); ++
rule ) {
884 result.splice(
result.begin(), tmp, tmp.begin(), tmp.end() );
905 std::map<std::string, std::string>
rule;
907 error_string +=
"\nThe following rule has been omitted:\n read ";
917 SchemaRuleClassMap_t::iterator it;
924 std::list<SchemaRuleMap_t>
lst;
929 it->second.push_back(
rule );
941 std::map<std::string, std::string>
rule;
943 error_string +=
"\nThe following rule has been omitted:\n readraw ";
953 SchemaRuleClassMap_t::iterator it;
959 std::list<SchemaRuleMap_t>
lst;
964 it->second.push_back(
rule );
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t cursor
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t target
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t attr
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=',')
const_iterator begin() const
const_iterator end() const
std::map< std::string, std::string > MembersMap_t
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
std::list< std::pair< ROOT::Internal::TSchemaType, std::string > > SourceTypeList_t
std::map< std::string, std::list< SchemaRuleMap_t > > SchemaRuleClassMap_t
static void WriteAutoVariables(const std::list< std::string > &target, const SourceTypeList_t &source, MembersTypeMap_t &members, std::string &className, std::string &mappedName, std::ostream &output)
Write down the sources.
static std::string::size_type FindEndSymbol(std::string &command)
static void StrReplace(std::string &proc, const std::string &pat, const std::string &tr)
Replace all accurances of given string with other string.
void ProcessReadPragma(const char *args, std::string &error_string)
I am being called when a read pragma is encountered.
void WriteSchemaList(std::list< SchemaRuleMap_t > &rules, const std::string &listName, std::ostream &output)
Write schema rules.
std::map< std::string, ROOT::Internal::TSchemaType > MembersTypeMap_t
void WriteReadRuleFunc(SchemaRuleMap_t &rule, int index, std::string &mappedName, MembersTypeMap_t &members, std::ostream &output)
Write the conversion function for Read rule, the function name is being written to rule["funcname"].
static Bool_t ValidateRule(const std::map< std::string, std::string > &rule, std::string &error_string)
Validate if the user specified rules are correct.
R__EXTERN SchemaRuleClassMap_t gReadRules
std::map< std::string, std::string > SchemaRuleMap_t
bool HasValidDataMembers(SchemaRuleMap_t &rule, MembersTypeMap_t &members, std::string &error_string)
Check if given rule contains references to valid data members.
void GetRuleIncludes(std::list< std::string > &result)
Get the list of includes specified in the shema rules.
void WriteReadRawRuleFunc(SchemaRuleMap_t &rule, int index, std::string &mappedName, MembersTypeMap_t &members, std::ostream &output)
Write the conversion function for ReadRaw rule, the function name is being written to rule["funcname"...
void ProcessReadRawPragma(const char *args, std::string &error_string)
I am being called then a readraw pragma is encountered.
R__EXTERN SchemaRuleClassMap_t gReadRawRules
bool ParseRule(std::string rule, ROOT::Internal::MembersMap_t &result, std::string &error_string)
Parse the schema rule as specified in the LinkDef file.
void GetNormalizedName(std::string &norm_name, std::string_view name)
Return the normalized name.