Hall A ROOT/C++ Analyzer (podd)
Loading...
Searching...
No Matches
THaString.cxx
Go to the documentation of this file.
1
2//
3// THaString.cxx (implementation)
4//
6
7#include "THaString.h"
8#include "Textvars.h" // For Podd::vsplit
9#include "Helper.h"
10#include <algorithm>
11#include <cctype>
12#include <sstream>
13
14using namespace std;
15
16namespace THaString {
17
18//_____________________________________________________________________________
19int CmpNoCase( const string& r, const string& s )
20{
21 // Case insensitive compare. Returns -1 if "less", 0 if equal, 1 if
22 // "greater".
23
24 string::const_iterator p = r.begin();
25 string::const_iterator p2 = s.begin();
26
27 while (p != r.end() && p2 != s.end()) {
28 if (toupper(*p) != toupper(*p2))
29 return (toupper(*p) < toupper(*p2)) ? -1 : 1;
30 ++p;
31 ++p2;
32 }
33
34 return (r.size() == s.size()) ? 0 : (r.size() < s.size()) ? -1 : 1;
35}
36
37//_____________________________________________________________________________
38string::size_type FindNoCase( string data, string chunk )
39{
40 // Find position of "chunk" in "data". Case insensitive.
41
42 Lower(data);
43 Lower(chunk);
44 return data.find(chunk);
45}
46
47//_____________________________________________________________________________
48vector<string> Split( const string& s )
49{
50 // Split on whitespace.
51 return Podd::vsplit(s);
52}
53
54//_____________________________________________________________________________
55unsigned int Hex( const string& s )
56{
57 // Conversion to unsigned interpreting as hex.
58 istringstream ist(s);
59 unsigned int in = 0;
60 ist >> hex >> in;
61 return in;
62}
63
64//_____________________________________________________________________________
65string ToLower( const string& s )
66{
67 // Return copy of this string converted to lower case.
68
69 string result(s);
70 // The bizarre cast here is needed for newer gccs
71 transform( ALL(s), result.begin(), (int(*)(int))tolower );
72 return result;
73}
74
75//_____________________________________________________________________________
76string ToUpper( const string& s )
77{
78 // Return copy of this string converted to upper case.
79 string result(s);
80 transform( ALL(s), result.begin(), (int(*)(int))toupper );
81 return result;
82}
83
84//_____________________________________________________________________________
85void Lower( string& s )
86{
87 // Convert this string to lower case
88
89 transform( ALL(s), s.begin(), (int(*)(int))tolower );
90}
91
92//_____________________________________________________________________________
93void Upper( string& s )
94{
95 // Convert this string to upper case
96 transform( ALL(s), s.begin(), (int(*)(int))toupper );
97}
98
99//_____________________________________________________________________________
100
101}
ROOT::R::TRInterface & r
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
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
std::vector< std::string > Split(std::string_view str, std::string_view delims, bool skipEmpty)
string::size_type FindNoCase(string data, string chunk)
Definition THaString.cxx:38
unsigned int Hex(const string &s)
Definition THaString.cxx:55
void Upper(string &s)
Definition THaString.cxx:93
string ToUpper(const string &s)
Definition THaString.cxx:76
void Lower(string &s)
Definition THaString.cxx:85
string ToLower(const string &s)
Definition THaString.cxx:65
int CmpNoCase(const string &r, const string &s)
Definition THaString.cxx:19
STL namespace.