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)) {
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) {
87 TSchemaRule::TSchemaRule(): fVersionVect( 0 ), fChecksumVect( 0 ),
88 fTargetVect( 0 ), fSourceVect( 0 ),
89 fIncludeVect( 0 ), fEmbed(
kTRUE ),
90 fReadFuncPtr( 0 ), fReadRawFuncPtr( 0 ),
111 fVersionVect( 0 ), fChecksumVect( 0 ),
112 fTargetVect( 0 ), fSourceVect( 0 ),
113 fIncludeVect( 0 ), fEmbed(
kTRUE ),
114 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";
204 std::cout <<
"code=\"{" <<
fCode <<
"}\" "
234 else { out +=
"-- "; end =
"-->"; }
246 out +=
"targetClass=\"" + fTargetClass +
"\" ";
250 if (shortform && fTarget ==
fSource) {
253 if (!shortform || (
fVersion !=
"[1-]")) {
257 if (!shortform || fTarget !=
fSource) {
258 out +=
"source=\"" +
fSource +
"\" ";
259 out +=
"target=\"" + fTarget +
"\" ";
268 out +=
"\n<![CDATA[ { " +
fCode +
" ]]>\n ";
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 )
472 fTargetClass = classname;
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.
TString fCode
Includes vector.
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 IsAliasRule() const
Return kTRUE if the rule is a strict renaming of one of the data member of the class.
Bool_t TestVersion(Int_t version) const
Check if given version number is defined in this rule.
const char * GetVersion() const
Get the version string.
void SetReadRawFunctionPointer(ReadRawFuncPtr_t ptr)
Set the pointer to the function to be run for the rule (if it is a raw read rule).
Bool_t GetEmbed() const
Return true if this rule should be saved in the ROOT File.
Collectable string class.
virtual void Clear(Option_t *option="")
Remove all objects from the array.
ReadRawFuncPtr_t fReadRawFuncPtr
Conversion function pointer for read rule.
void AsString(TString &out, const char *options="") const
Add to the string 'out' the string representation of the rule.
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
Bool_t HasSource(const TString &source) const
Return true if one of the rule's data member source is 'source'.
static bool IsANumber(const std::string &source)
void ToLower()
Change string to lower-case.
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.
const char * Data() const
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)
Parse the schema rule as specified in the LinkDef file.
void Clear()
Clear string without changing its capacity.
std::vector< std::pair< Int_t, Int_t > > * fVersionVect
TObject * Next()
Return next object in array. Returns 0 when no more objects in array.
void Clear(Option_t *="")
Zero out this rule object.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
void SetSource(const TString &source)
Set the list of source members.
Int_t GetClassVersion() const
Bool_t ProcessChecksum(const TString &checksum) const
Check if specified checksum string is correct and build checksum vector.
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...
ReadRawFuncPtr_t GetReadRawFunctionPointer() const
Get the pointer to the function to be run for the rule (if it is a raw read rule).
RuleType_t GetRuleType() const
Return the type of the rule.
std::map< std::string, std::string > MembersMap_t
Bool_t TestChecksum(UInt_t checksum) const
Check if given checksum is defined in this rule.
TString GetString() const
Bool_t HasTarget(const TString &target) const
Return true if one of the rule's data member target is 'target'.
static void SplitList(const std::string &source, std::list< std::string > &result, char delimiter=',')
std::vector< UInt_t > * fChecksumVect
void SetTarget(const TString &target)
Set the target member of this rule (i.e. the in memory data member).
void SetCode(const TString &code)
Set the source code of this rule.
void ls(Option_t *option="") const
The ls function lists the contents of a class on stdout.
virtual const char * GetName() const
Returns name of 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...
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)
TString fSource
Target data member vector (for searching purposes)
const char * GetSourceClass() const
Get the source class of this rule (i.e. the onfile class).
const char * GetTargetClass() const
Get the targte class of this rule (i.e. the in memory class).
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 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 *)
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 * GetAttributes() const
Get the attributes code of this rule.
void SetReadFunctionPointer(ReadFuncPtr_t ptr)
Set the pointer to the function to be run for the rule (if it is a read rule).
const TObjArray * GetTarget() const
Get the target data members of this rule (i.e. the in memory data member).
Bool_t IsValid() const
Return kTRUE if this rule is valid.
void SetEmbed(Bool_t embed)
Set whether this rule should be save in the ROOT file (if true)
Bool_t IsRenameRule() const
Return kTRUE if the rule is a strict renaming of the class to a new name.
Mother of all ROOT objects.
static Int_t IncreaseDirLevel()
Increase the indentation level for ls().
TString fChecksum
Source version vector (for searching purposes)
const char * GetCode() const
Get the source code of this rule.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
ReadFuncPtr_t GetReadFunctionPointer() const
Get the pointer to the function to be run for the rule (if it is a read rule).
Bool_t Conflicts(const TSchemaRule *rule) const
Check if this rule conflicts with the given one.
const char * GetTargetString() const
Get the target data members of this rule as a simple string (i.e. the in memory data member)...
ClassImp(TSchemaRule) using namespace ROOT
Bool_t ProcessVersion(const TString &version) const
Check if specified version string is correct and build version vector.
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
void SetRuleType(RuleType_t type)
Set the type of the rule.
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 operator==(const TSchemaRule &rhs) const
Return true if the rule have the same effects.
static bool ProcessVersion(const std::string &source, std::pair< Int_t, Int_t > &result)