/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Reconstruction/MdcPatRec/MdcRecoUtil/MdcRecoUtil-00-01-08/MdcRecoUtil/String.h

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 // File and Version Information:
00003 //
00004 // $Id: String.h,v 1.1.1.1 2005/04/21 01:15:12 zhangy Exp $
00005 //
00006 // Description:
00007 //      The functions, within this namespace, are needed by BaBar to replace
00008 //      those lost in the rw to STL string migration.
00009 //
00010 // Environment:
00011 //      Software developed for the BaBar Detector at the SLAC B-Factory.
00012 //
00013 // Author List:
00014 //       A. De Silva
00015 //       A. Ryd
00016 //
00017 // Copyright Information:
00018 //
00019 //------------------------------------------------------------------------
00020 
00021 #ifndef BES_STRING_H
00022 #define BES_STRING_H
00023 
00024 #include <algorithm>
00025 #include <string>
00026 #include <cctype>
00027 #include <strings.h>
00028 
00029 namespace bes {
00030   namespace String {
00031     
00032     // transformations from lower toupper case or vice-versa
00033     
00034     // needed because for_each is a non-modifying sequence algorithm
00035     inline void lowerCh(char& c) { c = tolower(c); }
00036     inline void upperCh(char& c) { c = toupper(c); }
00037            
00038     inline void transformToLower(std::string& str) {
00039       std::for_each(str.begin(), str.end(), lowerCh);
00040     }  
00041     inline void transformToUpper(std::string& str) {
00042       std::for_each(str.begin(), str.end(), upperCh);
00043     }
00044 
00045     std::string toLower(const std::string& str);
00046     std::string toUpper(const std::string& str);
00047     
00048 
00049     // case-insensitive comparisons
00050     //
00051     //    It returns an integer less  than, equal  to,  or  greater  than
00052     //    zero if s is found, respectively, to be less than, to match, or
00053     //    be greater than  s2.
00054     //
00055     int compare_nocase(const std::string& s, const std::string& s2);
00056     inline int compare_nocase(const std::string& s, const char* s2) {
00057       return strcasecmp(s.c_str(), s2);
00058     }
00059     
00060 
00061     // case-insensitive search
00062     int find_nocase(const std::string& s, const std::string& s2);
00063     inline int find_nocase(const std::string& s, const char* s2) {
00064       return find_nocase(s,std::string(s2));
00065     }
00066 
00067 
00068     // Provides a hash function for strings
00069     unsigned int rwHash(const std::string& str);
00070     
00071   }
00072 }
00073 
00074 #endif
00075 
00076 

Generated on Tue Nov 29 23:13:32 2016 for BOSS_7.0.2 by  doxygen 1.4.7