10 #include <TObjArray.h>
11 #include <TObjString.h>
30 static struct IsLonger{
32 bool operator()(TString s1, TString s2){
return ( s1.Length() > s2.Length() ); }
35 static struct IsShorter{
37 bool operator()(TString s1, TString s2){
return ( s1.Length() < s2.Length() ); }
41 inline vector<TString> Tokenize(TString line,TString delim){
44 if(line.IsNull() || line.IsWhitespace())
return list;
46 const char *delimiters = delim.Data();
48 TObjArray* Strings = line.Tokenize(delimiters);
50 if(Strings->GetEntriesFast()) {
51 TIter iString(Strings);
54 while ((os=(TObjString*)iString())) {
59 list.push_back(os->GetString());
72 inline vector<TString> GetPath2(TString path_full){
74 std::vector<TString> list;
77 int slash_pos = path_full.Last(
'/');
79 TString path_to = path_full(0,slash_pos);
81 TString name = path_full(slash_pos+1,path_full.Length()-slash_pos-1);
83 list.push_back(path_to);
89 inline TString GetPath(TString path_full, TString* path_to, TString *name) {
91 int slash_pos = path_full.Last(
'/');
93 *path_to = path_full(0,slash_pos);
95 *name = path_full(slash_pos+1,path_full.Length()-slash_pos-1);
100 inline vector<string> TokenizeStr(
string line,
string delim){
103 std::vector<TString> TS = Tokenize(TString(line),TString(delim));
105 std::vector<string> list;
107 for(
int i=0; i< TS.size(); ++i){
109 list.push_back(
string(TS[i]) );
117 inline int Duplicates( std::vector<TString> list){
121 for(
int i1=0; i1< list.size()-1; ++i1){
122 for(
int i2=i1+1; i2< list.size();++i2){
123 if(list.at(i1)==list.at(i2)) N++;
131 inline bool StringIsPresent(std::vector<TString> &list, TString &s){
133 for(
int i=0;i<list.size();++i){
134 if( list.at(i)==s )
return 1;
141 template <
typename T>
142 string ToString ( T Number )
144 std::ostringstream ss;
151 template <
typename N>
152 N ToNumber (
const string &Text )
154 std::istringstream ss(Text);
156 return ss >> result ? result : 0;
162 inline TString Name(TString str1,TString sep,TString str2=
"") {
166 name+=sep; name+=str2;
172 inline TString Name(TString str1,TString sep1,TString str2,TString sep2, TString str3) {
174 TString name=Name(str1,sep1,str2);
176 name+=sep2; name+=str3;
182 inline TString Name(TString str1,TString sep1,TString str2,TString sep2, TString str3, TString sep3, TString str4) {
184 TString name=Name(str1,sep1,str2,sep2,str3);
186 name+=sep3; name+=str4;
193 inline TString SplitLineLabel(TString top, TString bottom){
197 if(bottom.IsWhitespace())
return top;
199 label = Name(
"#splitline{",top,
"}{",bottom,
"}");
204 inline TString Title(TString tit1,TString sep,TString tit2) {
208 title+=sep; title+=tit2;
214 inline TString TitleXYZ(TString tit,TString titx,TString tity=
"",TString titz=
"") {
219 title+=
";"; title+=titx;
221 if(!tity.IsWhitespace() ){
222 title+=
";"; title+=tity;
225 if(!titz.IsWhitespace() ){
226 title+=
";"; title+=titz;
250 std::vector<TString> vec=STR_UTILS::Tokenize(tit,
";");
254 if(n==0)
return tit2;
257 str=STR_UTILS::Name(vec.at(0),sep,tit2);
262 str=STR_UTILS::TitleXYZ(str,vec.at(1));
266 str=STR_UTILS::TitleXYZ(str,vec.at(2));
270 str=STR_UTILS::TitleXYZ(str,vec.at(3));
293 std::vector<TString> vec=STR_UTILS::Tokenize(tit,
";");
297 if(n==0)
return tit2;
300 str=STR_UTILS::Name(tit2,sep,vec.at(0));
305 str=STR_UTILS::TitleXYZ(str,vec.at(1));
309 str=STR_UTILS::TitleXYZ(str,vec.at(2));
313 str=STR_UTILS::TitleXYZ(str,vec.at(3));
324 namespace StringUtils = STR_UTILS;
TString PrependToTitleXYZ(TString tit, TString sep, TString tit2)
Definition: StringUtils.h:247
TString AppendToTitleXYZ(TString tit, TString sep, TString tit2)
Definition: StringUtils.h:205