Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4String.hh
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// G4String
27//
28// Class description:
29//
30// Definition of a Geant4 string.
31// Derived from the Rogue Wave implementation of RWCString;
32// it uses intrinsically STL std::string.
33
34// Author: G.Cosmo, 11 November 1999
35//---------------------------------------------------------------------
36#ifndef G4String_hh
37#define G4String_hh 1
38
39#include <cstring>
40#include <iostream>
41#include <stdio.h>
42#include <string>
43
44#include "G4Types.hh"
45
46#ifdef WIN32
47# define strcasecmp _stricmp
48#endif
49
50using str_size = std::string::size_type;
51
52class G4String : public std::string
53{
54 using std_string = std::string;
55
56 public:
58 {
61 };
63 {
66 both
67 };
68
69 inline G4String();
70 inline G4String(char);
71 inline G4String(const char*);
72 inline G4String(const char*, str_size);
73 inline G4String(const G4String&);
74 inline G4String(const std::string&);
75 inline G4String(G4String&&) = default;
77
78 inline G4String& operator=(const G4String&);
79 inline G4String& operator=(const std::string&);
80 inline G4String& operator=(const char*);
81 inline G4String& operator=(G4String&&) = default;
82
83 inline char operator()(str_size) const;
84 inline char& operator()(str_size);
85
86 inline G4String& operator+=(const char*);
87 inline G4String& operator+=(const std::string&);
88 inline G4String& operator+=(const char&);
89 inline G4bool operator==(const G4String&) const;
90 inline G4bool operator==(const char*) const;
91 inline G4bool operator!=(const G4String&) const;
92 inline G4bool operator!=(const char*) const;
93
94 inline operator const char*() const;
96
97 inline G4int compareTo(const char*, caseCompare mode = exact) const;
98 inline G4int compareTo(const G4String&, caseCompare mode = exact) const;
99
100 inline G4String& prepend(const char*);
101 inline G4String& append(const G4String&);
102
103 inline std::istream& readLine(std::istream&, G4bool skipWhite = true);
104
105 inline G4String& replace(unsigned int, unsigned int, const char*,
106 unsigned int);
107 inline G4String& replace(str_size, str_size, const char*);
108
111
112 inline std::size_t first(char) const;
113 inline std::size_t last(char) const;
114
115 inline G4bool contains(const std::string&) const;
116 inline G4bool contains(char) const;
117
118 // stripType = 0 beginning
119 // stripType = 1 end
120 // stripType = 2 both
121 //
122 inline G4String strip(G4int strip_Type = trailing, char c = ' ');
123
124 inline void toLower();
125 inline void toUpper();
126
127 inline G4bool isNull() const;
128
129 inline str_size index(const char*, G4int pos = 0) const;
130 inline str_size index(char, G4int pos = 0) const;
132
133 inline const char* data() const;
134
135 inline G4int strcasecompare(const char*, const char*) const;
136
137 inline unsigned int hash(caseCompare cmp = exact) const;
138 inline unsigned int stlhash() const;
139};
140
141#include "G4String.icc"
142
143#endif
std::string::size_type str_size
Definition: G4String.hh:50
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
G4bool operator!=(const char *) const
G4String & replace(str_size, str_size, const char *)
@ ignoreCase
Definition: G4String.hh:60
@ trailing
Definition: G4String.hh:65
@ leading
Definition: G4String.hh:64
unsigned int stlhash() const
G4String & operator=(G4String &&)=default
G4String & remove(str_size)
G4String & append(const G4String &)
str_size index(const G4String &, str_size, str_size, caseCompare) const
G4String & prepend(const char *)
G4bool contains(char) const
G4String & remove(str_size, str_size)
str_size index(const char *, G4int pos=0) const
G4bool isNull() const
G4String & operator=(const G4String &)
char & operator()(str_size)
std::size_t last(char) const
G4String & operator=(const std::string &)
G4String operator()(str_size, str_size)
G4String(const char *, str_size)
G4bool contains(const std::string &) const
std::size_t first(char) const
G4String & replace(unsigned int, unsigned int, const char *, unsigned int)
G4bool operator==(const char *) const
void toUpper()
unsigned int hash(caseCompare cmp=exact) const
G4bool operator==(const G4String &) const
G4String & operator+=(const char *)
G4String(G4String &&)=default
G4String(const G4String &)
G4String(char)
G4int compareTo(const G4String &, caseCompare mode=exact) const
~G4String()
Definition: G4String.hh:76
G4String strip(G4int strip_Type=trailing, char c=' ')
void toLower()
char operator()(str_size) const
G4String & operator+=(const std::string &)
G4int strcasecompare(const char *, const char *) const
G4String & operator=(const char *)
const char * data() const
G4String & operator+=(const char &)
str_size index(char, G4int pos=0) const
std::istream & readLine(std::istream &, G4bool skipWhite=true)
G4String(const std::string &)
G4int compareTo(const char *, caseCompare mode=exact) const
G4String(const char *)
G4bool operator!=(const G4String &) const