28 static Bool_t IsIrrelevantCharacter(
char c)
30 return (
c ==
' ' ||
c ==
'\n' ||
c ==
'\t');
33 static void AdvanceOverIrrelevantCharacter(
const char*& str)
35 while (IsIrrelevantCharacter(*str)) {
47 const char null =
'\0';
48 const char* left = lhs.
Data();
49 const char* right = rhs.
Data();
52 AdvanceOverIrrelevantCharacter(left);
53 AdvanceOverIrrelevantCharacter(right);
55 while (*left !=
null || *right !=
null) {
57 if (!literal && IsIrrelevantCharacter(*left) && IsIrrelevantCharacter(*right)) {
58 AdvanceOverIrrelevantCharacter(left);
59 AdvanceOverIrrelevantCharacter(right);
63 if (*left ==
null || *right ==
null) {
64 AdvanceOverIrrelevantCharacter(left);
65 AdvanceOverIrrelevantCharacter(right);
66 result = (*left ==
null && *right ==
null);
70 if (*left != *right) {
90TSchemaRule::TSchemaRule(): fVersionVect( 0 ), fChecksumVect( 0 ),
91 fTargetVect( 0 ), fSourceVect( 0 ),
92 fIncludeVect( 0 ), fEmbed(
kTRUE ),
93 fReadFuncPtr( 0 ), fReadRawFuncPtr( 0 ),
114 fVersionVect( 0 ), fChecksumVect( 0 ),
115 fTargetVect( 0 ), fSourceVect( 0 ),
116 fIncludeVect( 0 ), fEmbed(
kTRUE ),
117 fReadFuncPtr( 0 ), fReadRawFuncPtr( 0 ),
181 std::cout <<
"Schema Evolution Rule: ";
190 if (targetname && targetname[0]) std::cout <<
"targetClass=\"" << targetname <<
"\" ";
191 else std::cout <<
"targetClass\"" <<
fTargetClass <<
"\" ";
194 std::cout <<
"source=\"" <<
fSource <<
"\" ";
195 std::cout <<
"target=\"" <<
fTarget <<
"\" ";
199 std::cout <<
"include=\"" <<
fInclude <<
"\" " <<
"\n";
203 std::cout <<
"attributes=\"" <<
fAttributes <<
"\"" <<
"\n";
207 std::cout <<
"code=\"{" <<
fCode <<
"}\" "
237 else { out +=
"-- "; end =
"-->"; }
256 if (!shortform || (
fVersion !=
"[1-]")) {
261 out +=
"source=\"" +
fSource +
"\" ";
262 out +=
"target=\"" +
fTarget +
"\" ";
271 out +=
"\n<![CDATA[ { " +
fCode +
" ]]>\n ";
281 out +=
"code=\"{" +
fCode +
"}\" ";
330 std::string error_string;
332 Error(
"SetFromRule",
"The rule (%s) is invalid: %s",rule,error_string.c_str());
335 ROOT::Internal::MembersMap_t::const_iterator it1;
337 it1 = rule_values.find(
"type" );
338 if( it1 != rule_values.end() ) {
339 if (it1->second ==
"read" || it1->second ==
"Read") {
341 }
else if (it1->second ==
"readraw" || it1->second ==
"ReadRaw") {
350 it1 = rule_values.find(
"targetClass" );
352 it1 = rule_values.find(
"sourceClass" );
354 it1 = rule_values.find(
"target" );
355 if( it1 != rule_values.end() )
SetTarget( it1->second );
356 it1 = rule_values.find(
"source" );
357 if( it1 != rule_values.end() )
SetSource( it1->second );
358 it1 = rule_values.find(
"version" );
359 if( it1 != rule_values.end() )
SetVersion( it1->second );
360 it1 = rule_values.find(
"checksum" );
361 if( it1 != rule_values.end() )
SetChecksum( it1->second );
362 it1 = rule_values.find(
"embed" );
363 if( it1 != rule_values.end() )
SetEmbed( it1->second ==
"false" ?
false :
true );
364 it1 = rule_values.find(
"include" );
365 if( it1 != rule_values.end() )
SetInclude( it1->second );
366 it1 = rule_values.find(
"attributes" );
368 it1 = rule_values.find(
"code" );
369 if( it1 != rule_values.end() )
SetCode( it1->second );
415 std::vector<std::pair<Int_t, Int_t> >::iterator it;
417 if( version >= it->first && version <= it->
second )
446 std::vector<UInt_t>::iterator it;
448 if( checksum == *it )
459 std::string normalizedName;
477 std::string normalizedName;
680 while( (obj = it.
Next()) ) {
698 while( (obj = it.
Next()) ) {
794 while( (obj = titer.
Next() ) ) {
797 haveCommonTargets =
kTRUE;
800 if( !haveCommonTargets )
808 std::vector<UInt_t>::iterator it;
820 std::vector<std::pair<Int_t, Int_t> >::iterator it1;
821 std::vector<std::pair<Int_t, Int_t> >::iterator it2;
829 if( it1->first >= it2->first && it1->first <= it2->second )
832 if( it1->first < it2->first && it1->second >= it2->first )
849 if( version[0] !=
'[' || version[version.
Length()-1] !=
']' )
851 std::string ver = version.
Data();
853 std::list<std::string> versions;
856 if( versions.empty() )
864 fVersionVect =
new std::vector<std::pair<Int_t, Int_t> >;
871 std::list<std::string>::iterator it;
872 for( it = versions.begin(); it != versions.end(); ++it ) {
873 std::pair<Int_t, Int_t> verpair;
896 std::string chk = (
const char*)checksum;
897 if( chk[0] !=
'[' || chk[chk.size()-1] !=
']' )
900 std::list<std::string> checksums;
903 if( checksums.empty() ) {
917 for(
const auto& checksumStr : checksums ) {
935 std::istringstream converter(checksum);
937 converter >> std::hex >> chksum;
938 if (converter.fail()) {
941 converter >> std::dec >> chksum;
944 if( converter.fail() ) {
956 std::list<std::string> elems;
957 std::list<std::string>::iterator it;
965 for( it = elems.begin(); it != elems.end(); ++it ) {
977 std::list<std::pair<ROOT::Internal::TSchemaType,std::string> > elems;
978 std::list<std::pair<ROOT::Internal::TSchemaType,std::string> >::iterator it;
986 for( it = elems.begin(); it != elems.end(); ++it ) {
987 TSources *
type =
new TSources( it->second.c_str(), it->first.fType.c_str(), it->first.fDimensions.c_str() ) ;
1001 name.ReplaceAll(
',',
'_');
1002 name.ReplaceAll(
':',
'_');
1003 funcname +=
"_" +
name;
1005 String filename = funcname +
".C";
1010 std::ofstream fileout(filename);
1016 gROOT->LoadMacro(filename);
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=',')
void SetRuleType(RuleType_t type)
Set the type of the rule.
void SetCode(const TString &code)
Set the source code of this rule.
TString fCode
Includes vector.
void SetTarget(const TString &target)
Set the target member of this rule (i.e. the in memory data member).
ReadFuncPtr_t fReadFuncPtr
void SetReadRawFunctionPointer(ReadRawFuncPtr_t ptr)
Set the pointer to the function to be run for the rule (if it is a raw read rule).
void SetInclude(const TString &include)
Set the comma separated list of header files to include to be able to compile this rule.
void AsString(TString &out, const char *options="") const
Add to the string 'out' the string representation of the rule.
const TObjArray * GetSource() const
Get the list of source members as a TObjArray of TNamed object, with the name being the member name a...
void SetReadFunctionPointer(ReadFuncPtr_t ptr)
Set the pointer to the function to be run for the rule (if it is a read rule).
std::vector< UInt_t > * fChecksumVect
void ls(Option_t *option="") const
The ls function lists the contents of a class on stdout.
UInt_t ParseChecksum(const char *checksum) const
Parse the checksum in the given string.
static void ProcessList(TObjArray *array, const TString &list)
Split the list as a comma separated list into a TObjArray of TObjString.
Bool_t operator==(const TSchemaRule &rhs) const
Return true if the rule have the same effects.
Bool_t SetFromRule(const char *rule)
Set the content fot this object from the rule See TClass::AddRule for details on the syntax.
Bool_t TestVersion(Int_t version) const
Check if given version number is defined in this rule.
TString fSource
Target data member vector (for searching purposes)
Bool_t HasSource(const TString &source) const
Return true if one of the rule's data member source is 'source'.
ReadRawFuncPtr_t GetReadRawFunctionPointer() const
Get the pointer to the function to be run for the rule (if it is a raw read rule).
const TObjArray * GetTarget() const
Get the target data members of this rule (i.e. the in memory data member).
Bool_t ProcessChecksum(const TString &checksum) const
Check if specified checksum string is correct and build checksum vector.
void(* ReadFuncPtr_t)(char *, TVirtualObject *)
void SetEmbed(Bool_t embed)
Set whether this rule should be save in the ROOT file (if true)
RuleType_t GetRuleType() const
Return the type of the rule.
Bool_t Conflicts(const TSchemaRule *rule) const
Check if this rule conflicts with the given one.
TSchemaRule & operator=(const TSchemaRule &rhs)
Copy operator.
void SetTargetClass(const TString &classname)
Set the target class of this rule (i.e. the in memory class).
void(* ReadRawFuncPtr_t)(char *, TBuffer &)
const char * GetSourceClass() const
Get the source class of this rule (i.e. the onfile class).
virtual ~TSchemaRule()
Destructor.
Bool_t TestChecksum(UInt_t checksum) const
Check if given checksum is defined in this rule.
Bool_t SetVersion(const TString &version)
Set the version string - returns kFALSE if the format is incorrect.
TString fInclude
Source data member vector (for searching purposes)
TString fChecksum
Source version vector (for searching purposes)
void SetSource(const TString &source)
Set the list of source members.
Bool_t IsRenameRule() const
Return kTRUE if the rule is a strict renaming of the class to a new name.
void SetAttributes(const TString &attributes)
Set the attributes code of this rule.
TString fSourceClass
Source checksum vector (for searching purposes)
Bool_t HasTarget(const TString &target) const
Return true if one of the rule's data member target is 'target'.
const char * GetTargetString() const
Get the target data members of this rule as a simple string (i.e. the in memory data member).
std::vector< std::pair< Int_t, Int_t > > * fVersionVect
ReadRawFuncPtr_t fReadRawFuncPtr
Conversion function pointer for read rule.
RuleType_t fRuleType
Conversion function pointer for readraw rule.
Bool_t IsValid() const
Return kTRUE if this rule is valid.
ReadFuncPtr_t GetReadFunctionPointer() const
Get the pointer to the function to be run for the rule (if it is a read rule).
const char * GetVersion() const
Get the version string.
const char * GetAttributes() const
Get the attributes code of this rule.
Bool_t GetEmbed() const
Return true if this rule should be saved in the ROOT File.
const char * GetCode() const
Get the source code of this rule.
void SetSourceClass(const TString &classname)
Set the source class of this rule (i.e. the onfile class).
TSchemaRule()
Default Constructor.
Bool_t SetChecksum(const TString &checksum)
Set the checksum string - returns kFALSE if the format is incorrect.
void Clear(Option_t *="")
Zero out this rule object.
const TObjArray * GetInclude() const
Return the list of header files to include to be able to compile this rule as a TObjArray of TObjStri...
Bool_t IsAliasRule() const
Return kTRUE if the rule is a strict renaming of one of the data member of the class.
const char * GetTargetClass() const
Get the targte class of this rule (i.e. the in memory class).
static void ProcessDeclaration(TObjArray *array, const TString &list)
Split the list as a declaration into as a TObjArray of TNamed(name,type).
Bool_t ProcessVersion(const TString &version) const
Check if specified version string is correct and build version vector.
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual const char * GetName() const
Returns name of object.
Iterator of object array.
TObject * Next()
Return next object in array. Returns 0 when no more objects in array.
virtual void Clear(Option_t *option="")
Remove all objects from the array.
Collectable string class.
const TString & GetString() const
Mother of all ROOT objects.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
static Int_t IncreaseDirLevel()
Increase the indentation level for ls().
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
static Int_t DecreaseDirLevel()
Decrease the indentation level for ls().
Describe Streamer information for one class version.
Int_t GetClassVersion() const
void ToLower()
Change string to lower-case.
void Clear()
Clear string without changing its capacity.
const char * Data() const
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) 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...
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"].
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"...
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.
static constexpr double second