BOSS 7.0.1
BESIII Offline Software System
Loading...
Searching...
No Matches
Reconstruction/MdcPatRec/MdcRecoUtil/MdcRecoUtil-00-01-08/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 <string>
26#include <cctype>
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
49 // case-insensitive comparisons
50 //
51 // It returns an integer less than, equal to, or greater than
52 // zero if s is found, respectively, to be less than, to match, or
53 // be greater than s2.
54 //
55 int compare_nocase(const std::string& s, const std::string& s2);
56 inline int compare_nocase(const std::string& s, const char* s2) {
57 return strcasecmp(s.c_str(), s2);
58 }
59
60
61 // case-insensitive search
62 int find_nocase(const std::string& s, const std::string& s2);
63 inline int find_nocase(const std::string& s, const char* s2) {
64 return find_nocase(s,std::string(s2));
65 }
66
67
68 // Provides a hash function for strings
69 unsigned int rwHash(const std::string& str);
70
71 }
72}
73
74#endif
75
76
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