25 static Bool_t IsIrrelevantCharacter(
char c)
27 return (c ==
' ' || c ==
'\n' || c ==
'\t');
30 static void AdvanceOverIrrelevantCharacter(
const char*& str)
32 while (IsIrrelevantCharacter(*str)) {
39 static Bool_t IsCodeEquivalent(
const TString& lhs,
const TString& rhs)
44 const char null =
'\0';
45 const char* left = lhs.Data();
46 const char* right = rhs.Data();
49 AdvanceOverIrrelevantCharacter(left);
50 AdvanceOverIrrelevantCharacter(right);
52 while (*left != null || *right != null) {
54 if (!literal && IsIrrelevantCharacter(*left) && IsIrrelevantCharacter(*right)) {
55 AdvanceOverIrrelevantCharacter(left);
56 AdvanceOverIrrelevantCharacter(right);
60 if (*left == null || *right == null) {
61 AdvanceOverIrrelevantCharacter(left);
62 AdvanceOverIrrelevantCharacter(right);
63 result = (*left == null && *right ==
null);
67 if (*left != *right) {
88 fTargetVect( 0 ), fSourceVect( 0 ),
89 fIncludeVect( 0 ), fEmbed(
kTRUE ),
90 fReadFuncPtr( 0 ), fReadRawFuncPtr( 0 ),
178 std::cout <<
"Schema Evolution Rule: ";
187 if (targetname && targetname[0]) std::cout <<
"targetClass=\"" << targetname <<
"\" ";
188 else std::cout <<
"targetClass\"" <<
fTargetClass <<
"\" ";
191 std::cout <<
"source=\"" <<
fSource <<
"\" ";
192 std::cout <<
"target=\"" <<
fTarget <<
"\" ";
196 std::cout <<
"include=\"" <<
fInclude <<
"\" " <<
"\n";
200 std::cout <<
"attributes=\"" <<
fAttributes <<
"\"" <<
"\n";
202 if (
fCode.Length()) {
204 std::cout <<
"code=\"{" <<
fCode <<
"}\" " 218 TString opt(options);
220 Bool_t shortform = opt.Contains(
's');
221 Bool_t xmlform = opt.Contains(
'x');
234 else { out +=
"-- "; end =
"-->"; }
253 if (!shortform || (
fVersion !=
"[1-]")) {
258 out +=
"source=\"" +
fSource +
"\" ";
259 out +=
"target=\"" +
fTarget +
"\" ";
267 if (
fCode.Length()) {
268 out +=
"\n<![CDATA[ { " +
fCode +
" ]]>\n ";
277 if (
fCode.Length()) {
278 out +=
"code=\"{" +
fCode +
"}\" ";
327 std::string error_string;
328 if( !
ParseRule( rule, rule_values, error_string) ) {
329 Error(
"SetFromRule",
"The rule (%s) is invalid: %s",rule,error_string.c_str());
332 ROOT::MembersMap_t ::const_iterator it1;
334 it1 = rule_values.find(
"type" );
335 if( it1 != rule_values.end() ) {
336 if (it1->second ==
"read" || it1->second ==
"Read") {
338 }
else if (it1->second ==
"readraw" || it1->second ==
"ReadRaw") {
347 it1 = rule_values.find(
"targetClass" );
349 it1 = rule_values.find(
"sourceClass" );
351 it1 = rule_values.find(
"target" );
352 if( it1 != rule_values.end() )
SetTarget( it1->second );
353 it1 = rule_values.find(
"source" );
354 if( it1 != rule_values.end() )
SetSource( it1->second );
355 it1 = rule_values.find(
"version" );
356 if( it1 != rule_values.end() )
SetVersion( it1->second );
357 it1 = rule_values.find(
"checksum" );
358 if( it1 != rule_values.end() )
SetChecksum( it1->second );
359 it1 = rule_values.find(
"embed" );
360 if( it1 != rule_values.end() )
SetEmbed( it1->second ==
"false" ?
false :
true );
361 it1 = rule_values.find(
"include" );
362 if( it1 != rule_values.end() )
SetInclude( it1->second );
363 it1 = rule_values.find(
"attributes" );
365 it1 = rule_values.find(
"code" );
366 if( it1 != rule_values.end() )
SetCode( it1->second );
412 std::vector<std::pair<Int_t, Int_t> >::iterator it;
414 if( version >= it->first && version <= it->second )
443 std::vector<UInt_t>::iterator it;
445 if( checksum == *it )
673 while( (obj = it.
Next()) ) {
691 while( (obj = it.
Next()) ) {
787 while( (obj = titer.Next() ) ) {
790 haveCommonTargets =
kTRUE;
793 if( !haveCommonTargets )
801 std::vector<UInt_t>::iterator it;
813 std::vector<std::pair<Int_t, Int_t> >::iterator it1;
814 std::vector<std::pair<Int_t, Int_t> >::iterator it2;
822 if( it1->first >= it2->first && it1->first <= it2->second )
825 if( it1->first < it2->first && it1->second >= it2->first )
842 if( version[0] !=
'[' || version[version.Length()-1] !=
']' )
844 std::string ver = version.Data();
846 std::list<std::string> versions;
849 if( versions.empty() )
857 fVersionVect =
new std::vector<std::pair<Int_t, Int_t> >;
864 std::list<std::string>::iterator it;
865 for( it = versions.begin(); it != versions.end(); ++it ) {
866 std::pair<Int_t, Int_t> verpair;
889 std::string chk = (
const char*)checksum;
890 if( chk[0] !=
'[' || chk[chk.size()-1] !=
']' )
893 std::list<std::string> checksums;
896 if( checksums.empty() ) {
910 std::list<std::string>::iterator it;
911 for( it = checksums.begin(); it != checksums.end(); ++it ) {
927 std::list<std::string> elems;
928 std::list<std::string>::iterator it;
936 for( it = elems.begin(); it != elems.end(); ++it ) {
948 std::list<std::pair<ROOT::Internal::TSchemaType,std::string> > elems;
949 std::list<std::pair<ROOT::Internal::TSchemaType,std::string> >::iterator it;
957 for( it = elems.begin(); it != elems.end(); ++it ) {
958 TSources *
type =
new TSources( it->second.c_str(), it->first.fType.c_str(), it->first.fDimensions.c_str() ) ;
972 name.ReplaceAll(
',',
'_');
973 name.ReplaceAll(
':',
'_');
974 funcname +=
"_" +
name;
976 String filename = funcname +
".C";
981 std::ofstream fileout(filename);
987 gROOT->LoadMacro(filename);
Describe Streamer information for one class version.
virtual const char * GetName() const
Returns name of object.
Bool_t IsValid() const
Return kTRUE if this rule is valid.
const TObjArray * GetInclude() const
Return the list of header files to include to be able to compile this rule as a TObjArray of TObjStri...
TString fCode
Includes vector.
const char * GetSourceClass() const
Get the source class of this rule (i.e. the onfile class).
Bool_t HasTarget(const TString &target) const
Return true if one of the rule's data member target is 'target'.
void(* ReadRawFuncPtr_t)(char *, TBuffer &)
static Int_t DecreaseDirLevel()
Decrease the indentation level for ls().
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_t IsRenameRule() const
Return kTRUE if the rule is a strict renaming of the class to a new name.
const char * GetAttributes() const
Get the attributes code of this rule.
void SetReadRawFunctionPointer(ReadRawFuncPtr_t ptr)
Set the pointer to the function to be run for the rule (if it is a raw read rule).
This namespace contains pre-defined functions to be used in conjuction with TExecutor::Map and TExecu...
Bool_t TestChecksum(UInt_t checksum) const
Check if given checksum is defined in this rule.
Collectable string class.
virtual void Clear(Option_t *option="")
Remove all objects from the array.
ReadRawFuncPtr_t fReadRawFuncPtr
Conversion function pointer for read rule.
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
static bool IsANumber(const std::string &source)
virtual ~TSchemaRule()
Destructor.
Iterator of object array.
TSchemaRule()
Default Constructor.
Bool_t SetVersion(const TString &version)
Set the version string - returns kFALSE if the format is incorrect.
TSchemaRule & operator=(const TSchemaRule &rhs)
Copy operator.
TString fSourceClass
Source checksum vector (for searching purposes)
void SetTargetClass(const TString &classname)
Set the target class of this rule (i.e. the in memory class).
RuleType_t fRuleType
Conversion function pointer for readraw rule.
static void SplitDeclaration(const std::string &source, std::list< std::pair< ROOT::Internal::TSchemaType, std::string > > &result)
void SetAttributes(const TString &attributes)
Set the attributes code of this rule.
bool ParseRule(std::string rule, MembersMap_t &result, std::string &error_string)
Bool_t ProcessChecksum(const TString &checksum) const
Check if specified checksum string is correct and build checksum vector.
std::vector< std::pair< Int_t, Int_t > > * fVersionVect
TObject * Next()
Return next object in array. Returns 0 when no more objects in array.
Bool_t Conflicts(const TSchemaRule *rule) const
Check if this rule conflicts with the given one.
void Clear(Option_t *="")
Zero out this rule object.
void AsString(TString &out, const char *options="") const
Add to the string 'out' the string representation of the rule.
const char * GetVersion() const
Get the version string.
Bool_t operator==(const TSchemaRule &rhs) const
Return true if the rule have the same effects.
void SetSource(const TString &source)
Set the list of source members.
RuleType_t GetRuleType() const
Return the type of the rule.
void SetSourceClass(const TString &classname)
Set the source class of this rule (i.e. the onfile class).
ReadFuncPtr_t fReadFuncPtr
void SetInclude(const TString &include)
Set the comma separated list of header files to include to be able to compile this 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...
const char * GetCode() const
Get the source code of this rule.
static void SplitList(const std::string &source, std::list< std::string > &result, char delimiter=',')
const char * GetTargetClass() const
Get the targte class of this rule (i.e. the in memory class).
std::vector< UInt_t > * fChecksumVect
void SetTarget(const TString &target)
Set the target member of this rule (i.e. the in memory data member).
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
void SetCode(const TString &code)
Set the source code of this rule.
const TObjArray * GetTarget() const
Get the target data members of this rule (i.e. the in memory data member).
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
static void ProcessList(TObjArray *array, const TString &list)
Split the list as a comma separated list into a TObjArray of TObjString.
Bool_t SetChecksum(const TString &checksum)
Set the checksum string - returns kFALSE if the format is incorrect.
TString fInclude
Source data member vector (for searching purposes)
Bool_t ProcessVersion(const TString &version) const
Check if specified version string is correct and build version vector.
TString GetString() const
TString fSource
Target data member vector (for searching purposes)
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"]...
const char * GetTargetString() const
Get the target data members of this rule as a simple string (i.e. the in memory data member)...
static void ProcessDeclaration(TObjArray *array, const TString &list)
Split the list as a declaration into as a TObjArray of TNamed(name,type).
void(* ReadFuncPtr_t)(char *, TVirtualObject *)
void SetReadFunctionPointer(ReadFuncPtr_t ptr)
Set the pointer to the function to be run for the rule (if it is a read rule).
Bool_t GetEmbed() const
Return true if this rule should be saved in the ROOT File.
Bool_t HasSource(const TString &source) const
Return true if one of the rule's data member source is 'source'.
void SetEmbed(Bool_t embed)
Set whether this rule should be save in the ROOT file (if true)
std::map< std::string, std::string > MembersMap_t
Mother of all ROOT objects.
static Int_t IncreaseDirLevel()
Increase the indentation level for ls().
Int_t GetClassVersion() const
void ls(Option_t *option="") const
The ls function lists the contents of a class on stdout.
TString fChecksum
Source version vector (for searching purposes)
Bool_t TestVersion(Int_t version) const
Check if given version number is defined in this rule.
ReadRawFuncPtr_t GetReadRawFunctionPointer() const
Get the pointer to the function to be run for the rule (if it is a raw read rule).
Bool_t IsAliasRule() const
Return kTRUE if the rule is a strict renaming of one of the data member of the class.
void SetRuleType(RuleType_t type)
Set the type of the rule.
ReadFuncPtr_t GetReadFunctionPointer() const
Get the pointer to the function to be run for the rule (if it is a read rule).
Bool_t SetFromRule(const char *rule)
Set the content fot this object from the rule See TClass::AddRule for details on the syntax...
static bool ProcessVersion(const std::string &source, std::pair< Int_t, Int_t > &result)