BOSS 6.6.4.p03
BESIII Offline Software System
Loading...
Searching...
No Matches
bes::String Namespace Reference

Functions

void lowerCh (char &c)
 
void upperCh (char &c)
 
void transformToLower (std::string &str)
 
void transformToUpper (std::string &str)
 
std::string toLower (const std::string &str)
 
std::string toUpper (const std::string &str)
 
int compare_nocase (const std::string &s, const std::string &s2)
 
int compare_nocase (const std::string &s, const char *s2)
 
int find_nocase (const std::string &s, const std::string &s2)
 
int find_nocase (const std::string &s, const char *s2)
 
unsigned int rwHash (const std::string &str)
 

Function Documentation

◆ compare_nocase() [1/2]

int bes::String::compare_nocase ( const std::string &  s,
const char *  s2 
)
inline

Definition at line 56 of file String.h.

56 {
57 return strcasecmp(s.c_str(), s2);
58 }
XmlRpcServer s
Definition: HelloServer.cpp:11

◆ compare_nocase() [2/2]

int bes::String::compare_nocase ( const std::string &  s,
const std::string &  s2 
)

Definition at line 27 of file String.cxx.

27 {
28 std::string::const_iterator p = s.begin();
29 std::string::const_iterator p2 = s2.begin();
30
31 while (p != s.end() && p2 != s2.end() ) {
32 if (toupper(*p) != toupper(*p2))
33 return (toupper(*p) < toupper(*p2)) ? -1 : 1;
34 ++p;
35 ++p2;
36 }
37 return (s2.size() == s.size()) ? 0 : (s.size() < s2.size()) ? -1 : 1;
38}

◆ find_nocase() [1/2]

int bes::String::find_nocase ( const std::string &  s,
const char *  s2 
)
inline

Definition at line 63 of file String.h.

63 {
64 return find_nocase(s,std::string(s2));
65 }
int find_nocase(const std::string &s, const std::string &s2)
Definition: String.cxx:41

◆ find_nocase() [2/2]

int bes::String::find_nocase ( const std::string &  s,
const std::string &  s2 
)

Definition at line 41 of file String.cxx.

41 {
42 std::string str1 = s;
43 transformToUpper(str1);
44 std::string str2 = s2;
45 transformToUpper(str2);
46 return str1.find(str2);
47}
void transformToUpper(std::string &str)
Definition: String.h:41

Referenced by find_nocase().

◆ lowerCh()

void bes::String::lowerCh ( char &  c)
inline

Definition at line 35 of file String.h.

35{ c = tolower(c); }

Referenced by transformToLower().

◆ rwHash()

unsigned int bes::String::rwHash ( const std::string &  str)

Definition at line 64 of file String.cxx.

64 {
65 const char* data = str.c_str();
66 int length = str.size(), total=0;
67 for ( int i=0; i<length; i++ ) total += data[i];
68 return total;
69}
TTree * data

◆ toLower()

std::string bes::String::toLower ( const std::string &  str)

Definition at line 50 of file String.cxx.

50 {
51 std::string result(str);
52 transformToLower(result);
53 return result;
54}
void transformToLower(std::string &str)
Definition: String.h:38

◆ toUpper()

std::string bes::String::toUpper ( const std::string &  str)

Definition at line 57 of file String.cxx.

57 {
58 std::string result(str);
59 transformToUpper(result);
60 return result;
61}

◆ transformToLower()

void bes::String::transformToLower ( std::string &  str)
inline

Definition at line 38 of file String.h.

38 {
39 std::for_each(str.begin(), str.end(), lowerCh);
40 }

Referenced by toLower().

◆ transformToUpper()

void bes::String::transformToUpper ( std::string &  str)
inline

Definition at line 41 of file String.h.

41 {
42 std::for_each(str.begin(), str.end(), upperCh);
43 }

Referenced by find_nocase(), and toUpper().

◆ upperCh()

void bes::String::upperCh ( char &  c)
inline

Definition at line 36 of file String.h.

36{ c = toupper(c); }

Referenced by transformToUpper().