BOSS 8.0.0
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#include "MdcRecoUtil/String.h"
21
22#include <iostream>
23#include <string>
24
25int bes::String::compare_nocase( const std::string& s, const std::string& s2 ) {
26 std::string::const_iterator p = s.begin();
27 std::string::const_iterator p2 = s2.begin();
28
29 while ( p != s.end() && p2 != s2.end() )
30 {
31 if ( toupper( *p ) != toupper( *p2 ) ) return ( toupper( *p ) < toupper( *p2 ) ) ? -1 : 1;
32 ++p;
33 ++p2;
34 }
35 return ( s2.size() == s.size() ) ? 0 : ( s.size() < s2.size() ) ? -1 : 1;
36}
37
38int bes::String::find_nocase( const std::string& s, const std::string& s2 ) {
39 std::string str1 = s;
40 transformToUpper( str1 );
41 std::string str2 = s2;
42 transformToUpper( str2 );
43 return str1.find( str2 );
44}
45
46std::string bes::String::toLower( const std::string& str ) {
47 std::string result( str );
48 transformToLower( result );
49 return result;
50}
51
52std::string bes::String::toUpper( const std::string& str ) {
53 std::string result( str );
54 transformToUpper( result );
55 return result;
56}
57
58unsigned int bes::String::rwHash( const std::string& str ) {
59 const char* data = str.c_str();
60 int length = str.size(), total = 0;
61 for ( int i = 0; i < length; i++ ) total += data[i];
62 return total;
63}
double p2[4]
TTree * data
XmlRpcServer s
unsigned int rwHash(const std::string &str)
Definition String.cxx:58
std::string toUpper(const std::string &str)
Definition String.cxx:52
int find_nocase(const std::string &s, const std::string &s2)
Definition String.cxx:38
int compare_nocase(const std::string &s, const std::string &s2)
Definition String.cxx:25
std::string toLower(const std::string &str)
Definition String.cxx:46