BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Reconstruction/MdcPatRec/MdcRecoUtil/include/MdcRecoUtil/String.h
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2// File and Version Information:
3//
4// $Id: String.h,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// A. Ryd
16//
17// Copyright Information:
18//
19//------------------------------------------------------------------------
20
21#ifndef BES_STRING_H
22#define BES_STRING_H
23
24#include <algorithm>
25#include <cctype>
26#include <string>
27#include <strings.h>
28
29namespace bes {
30 namespace String {
31
32 // transformations from lower toupper case or vice-versa
33
34 // needed because for_each is a non-modifying sequence algorithm
35 inline void lowerCh( char& c ) { c = tolower( c ); }
36 inline void upperCh( char& c ) { c = toupper( c ); }
37
38 inline void transformToLower( std::string& str ) {
39 std::for_each( str.begin(), str.end(), lowerCh );
40 }
41 inline void transformToUpper( std::string& str ) {
42 std::for_each( str.begin(), str.end(), upperCh );
43 }
44
45 std::string toLower( const std::string& str );
46 std::string toUpper( const std::string& str );
47
48 // case-insensitive comparisons
49 //
50 // It returns an integer less than, equal to, or greater than
51 // zero if s is found, respectively, to be less than, to match, or
52 // be greater than s2.
53 //
54 int compare_nocase( const std::string& s, const std::string& s2 );
55 inline int compare_nocase( const std::string& s, const char* s2 ) {
56 return strcasecmp( s.c_str(), s2 );
57 }
58
59 // case-insensitive search
60 int find_nocase( const std::string& s, const std::string& s2 );
61 inline int find_nocase( const std::string& s, const char* s2 ) {
62 return find_nocase( s, std::string( s2 ) );
63 }
64
65 // Provides a hash function for strings
66 unsigned int rwHash( const std::string& str );
67
68 } // namespace String
69} // namespace bes
70
71#endif
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