// // ******************************************************************** // * License and Disclaimer * // * * // * The Geant4 software is copyright of the Copyright Holders of * // * the Geant4 Collaboration. It is provided under the terms and * // * conditions of the Geant4 Software License, included in the file * // * LICENSE and available at http://cern.ch/geant4/license . These * // * include a list of copyright holders. * // * * // * Neither the authors of this software system, nor their employing * // * institutes,nor the agencies providing financial support for this * // * work make any representation or warranty, express or implied, * // * regarding this software system or assume any liability for its * // * use. Please see the license in the file LICENSE and URL above * // * for the full disclaimer and the limitation of liability. * // * * // * This code implementation is the result of the scientific and * // * technical work of the GEANT4 collaboration. * // * By using, copying, modifying or distributing the software (or * // * any work based on the software) you agree to acknowledge its * // * use in resulting scientific publications, and indicate your * // * acceptance of all terms of the Geant4 Software license. * // ******************************************************************** // // // $Id: G4String.icc 102049 2016-12-19 09:04:20Z gcosmo $ // // //--------------------------------------------------------------- // GEANT 4 class implementation file // // G4String //--------------------------------------------------------------- inline G4String::G4String () {} inline G4String::G4String ( const char * astring ) : std_string ( astring ) {} inline G4String::G4String ( const char * astring, str_size len ) : std_string ( astring, len ) {} inline G4String::G4String ( char ch ) { char str[2]; str[0]=ch; str[1]='\0'; std_string::operator=(str); } inline G4String::G4String ( const G4String& str ) : std_string(str) {} inline G4String::G4String ( const std::string& str ) : std_string(str) {} inline G4String& G4String::operator=(const G4String& str) { if (&str == this) { return *this; } std_string::operator=(str); return *this; } inline G4String& G4String::operator=(const std::string& str) { std_string::operator=(str); return *this; } inline G4String& G4String::operator=(const char* str) { std_string::operator=(str); return *this; } // "cmp" optional parameter is NOT implemented ! // N.B.: The hash value returned is generally DIFFERENT from the // one returned by the original RW function. // Users should not rely on the specific return value. // inline char G4String::operator () (str_size i) const { return operator[](i); } inline char& G4String::operator () (str_size i) { return std_string::operator[](i); } inline G4String G4String::operator()(str_size start, str_size extent) { return G4String(substr(start,extent)); } inline G4String& G4String::operator+=(const char* str) { std_string::operator+=(str); return *this; } inline G4String& G4String::operator+=(const std::string& str) { std_string::operator+=(str); return *this; } inline G4String& G4String::operator+=(const char& ch) { std_string::operator+=(ch); return *this; } inline G4bool G4String::operator==(const G4String& str) const { if (length() != str.length()) return false; return (std_string::compare(str) == 0); } inline G4bool G4String::operator==(const char* str) const { return (std_string::compare(str) == 0); } inline G4bool G4String::operator!=(const G4String& str) const { return !(*this == str); } inline G4bool G4String::operator!=(const char* str) const { return !(*this == str); } inline G4String::operator const char*() const { return c_str(); } inline G4int G4String::strcasecompare(const char* s1, const char* s2) const { char* buf1 = new char[strlen(s1)+1]; char* buf2 = new char[strlen(s2)+1]; for (str_size i=0; i<=strlen(s1); i++) { buf1[i] = tolower(char(s1[i])); } for (str_size j=0; j<=strlen(s2); j++) { buf2[j] = tolower(char(s2[j])); } G4int res = strcmp(buf1, buf2); delete [] buf1; delete [] buf2; return res; } inline G4int G4String::compareTo(const char* str, caseCompare mode) const { return (mode==exact) ? strcmp(c_str(),str) : strcasecompare(c_str(),str); } inline G4int G4String::compareTo(const G4String& str, caseCompare mode) const { return compareTo(str.c_str(), mode); } inline G4String& G4String::prepend (const char* str) { insert(0,str); return *this; } inline G4String& G4String::append(const G4String& str) { std_string::operator+=(str); return *this; } inline std::istream& G4String::readLine (std::istream& strm, G4bool skipWhite) { char tmp[1024]; if ( skipWhite ) { strm >> std::ws; strm.getline(tmp,1024); *this=tmp; } else { strm.getline(tmp,1024); *this=tmp; } return strm; } inline G4String& G4String::replace (unsigned int start, unsigned int nbytes, const char* buff, unsigned int n2 ) { std_string::replace ( start, nbytes, buff, n2 ); return *this; } inline G4String& G4String::replace(str_size pos, str_size n, const char* str) { std_string::replace(pos,n,str); return *this; } inline G4String& G4String::remove(str_size n) { if(n=0;j--) { if (std_string::operator[](j) != ch) { break; } } retVal = substr(0,j+1); } break; case both: { for(i=0;i=0;k--) { if (tmp.std_string::operator[](k) != ch) { break; } } retVal = tmp.substr(0,k+1); } break; default: break; } return retVal; } inline void G4String::toLower () { for (str_size i=0; i