BOSS 7.0.3
BESIII Offline Software System
Loading...
Searching...
No Matches
String.cxx
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2// File and Version Information:
3//
4// $Id: String.cxx,v 1.1.1.1 2005/04/21 01:15:12 zhangy Exp $
5//
6// Description:
7// The functions, within this namespace, are needed by BaBar to replace
8// those lost in the rw to STL string migration.
9//
10// Environment:
11// Software developed for the BaBar Detector at the SLAC B-Factory.
12//
13// Author List:
14// A. De Silva
15//
16// Copyright Information:
17//
18//------------------------------------------------------------------------
19
20
21#include "MdcRecoUtil/String.h"
22
23#include <string>
24#include <iostream>
25
26int
27bes::String::compare_nocase(const std::string& s, const std::string& s2) {
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}
39
40int
41bes::String::find_nocase(const std::string& s, const std::string& s2) {
42 std::string str1 = s;
43 transformToUpper(str1);
44 std::string str2 = s2;
45 transformToUpper(str2);
46 return str1.find(str2);
47}
48
49std::string
50bes::String::toLower(const std::string& str) {
51 std::string result(str);
52 transformToLower(result);
53 return result;
54}
55
56std::string
57bes::String::toUpper(const std::string& str) {
58 std::string result(str);
59 transformToUpper(result);
60 return result;
61}
62
63unsigned int
64bes::String::rwHash(const std::string& str){
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}
70
71
TTree * data
XmlRpcServer s
Definition: HelloServer.cpp:11
unsigned int rwHash(const std::string &str)
Definition: String.cxx:64
std::string toUpper(const std::string &str)
Definition: String.cxx:57
int find_nocase(const std::string &s, const std::string &s2)
Definition: String.cxx:41
int compare_nocase(const std::string &s, const std::string &s2)
Definition: String.cxx:27
std::string toLower(const std::string &str)
Definition: String.cxx:50