// // ******************************************************************** // * 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. * // ******************************************************************** // // G4String // // Class description: // // Definition of a Geant4 string. // Derived from the Rogue Wave implementation of RWCString; // it uses intrinsically STL std::string. // Author: G.Cosmo, 11 November 1999 //--------------------------------------------------------------------- #ifndef G4String_hh #define G4String_hh 1 #include #include #include #include #include "G4Types.hh" #ifdef WIN32 # define strcasecmp _stricmp #endif using str_size = std::string::size_type; class G4String : public std::string { using std_string = std::string; public: enum caseCompare { exact, ignoreCase }; enum stripType { leading, trailing, both }; inline G4String(); inline G4String(char); inline G4String(const char*); inline G4String(const char*, str_size); inline G4String(const G4String&); inline G4String(const std::string&); inline G4String(G4String&&) = default; ~G4String() {} inline G4String& operator=(const G4String&); inline G4String& operator=(const std::string&); inline G4String& operator=(const char*); inline G4String& operator=(G4String&&) = default; inline char operator()(str_size) const; inline char& operator()(str_size); inline G4String& operator+=(const char*); inline G4String& operator+=(const std::string&); inline G4String& operator+=(const char&); inline G4bool operator==(const G4String&) const; inline G4bool operator==(const char*) const; inline G4bool operator!=(const G4String&) const; inline G4bool operator!=(const char*) const; inline operator const char*() const; inline G4String operator()(str_size, str_size); inline G4int compareTo(const char*, caseCompare mode = exact) const; inline G4int compareTo(const G4String&, caseCompare mode = exact) const; inline G4String& prepend(const char*); inline G4String& append(const G4String&); inline std::istream& readLine(std::istream&, G4bool skipWhite = true); inline G4String& replace(unsigned int, unsigned int, const char*, unsigned int); inline G4String& replace(str_size, str_size, const char*); inline G4String& remove(str_size); inline G4String& remove(str_size, str_size); inline std::size_t first(char) const; inline std::size_t last(char) const; inline G4bool contains(const std::string&) const; inline G4bool contains(char) const; // stripType = 0 beginning // stripType = 1 end // stripType = 2 both // inline G4String strip(G4int strip_Type = trailing, char c = ' '); inline void toLower(); inline void toUpper(); inline G4bool isNull() const; inline str_size index(const char*, G4int pos = 0) const; inline str_size index(char, G4int pos = 0) const; inline str_size index(const G4String&, str_size, str_size, caseCompare) const; inline const char* data() const; inline G4int strcasecompare(const char*, const char*) const; inline unsigned int hash(caseCompare cmp = exact) const; inline unsigned int stlhash() const; }; #include "G4String.icc" #endif