Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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//
27// $Id$
28//
29//
30//---------------------------------------------------------------
31// GEANT 4 class header file
32//
33// G4String
34//
35// Class description:
36//
37// Definition of a Geant4 string.
38// Derived from the Rogue Wave implementation of RWCString;
39// it uses intrinsically STL string.
40
41//---------------------------------------------------------------
42
43#ifndef __G4String
44#define __G4String
45
46#include <stdio.h>
47#include <string>
48#include <cstring>
49
50#include "G4Types.hh"
51#include <iostream>
52
53#ifdef WIN32
54 #define strcasecmp _stricmp
55#endif
56
57typedef std::string::size_type str_size;
58
59class G4String;
60
62{
63public:
64
65 inline G4SubString(const G4SubString&);
66
67 inline G4SubString& operator=(const char*);
68
71
72 inline char& operator()(str_size);
73 inline char operator()(str_size) const;
74 inline char& operator[](str_size);
75 inline char operator[](str_size) const;
76
77 inline G4int operator!() const;
78
79 inline G4bool operator==(const G4String&) const;
80 inline G4bool operator==(const char*) const;
81 inline G4bool operator!=(const G4String&) const;
82 inline G4bool operator!=(const char*) const;
83
84 inline str_size length() const;
85 inline str_size start() const;
86
87 // For detecting null substrings
88 //
89 inline G4bool isNull() const;
90
91private:
92
94
95 G4String* mystring;
96 str_size mystart;
97 str_size extent;
98
99 friend class G4String;
100
101};
102
103
104class G4String : public std::string
105{
106
107 typedef std::string std_string;
108
109public:
110
113
114 inline G4String ();
115 inline G4String ( char );
116 inline G4String ( const char * );
117 inline G4String ( const char *, str_size );
118 inline G4String ( const G4String& );
119 inline G4String ( const G4SubString& );
120 inline G4String ( const std::string & );
122
123 inline G4String& operator=(const G4String&);
124 inline G4String& operator=(const std::string &);
125 inline G4String& operator=(const char*);
126
127 inline char operator () (str_size) const;
128 inline char& operator () (str_size);
129
131 inline G4String& operator+=(const char*);
132 inline G4String& operator+=(const std::string &);
133 inline G4String& operator+=(const char&);
134 inline G4bool operator==(const G4String&) const;
135 inline G4bool operator==(const char*) const;
136 inline G4bool operator!=(const G4String&) const;
137 inline G4bool operator!=(const char*) const;
138
139 inline operator const char*() const;
141
142 inline G4int compareTo(const char*, caseCompare mode=exact) const;
143 inline G4int compareTo(const G4String&, caseCompare mode=exact) const;
144
145 inline G4String& prepend (const char*);
146 inline G4String& append (const G4String&);
147
148 inline std::istream& readLine (std::istream&, G4bool skipWhite=true);
149
150 inline G4String& replace (unsigned int, unsigned int,
151 const char*, unsigned int );
152 inline G4String& replace(str_size, str_size, const char*);
153
156
157 inline G4int first(char) const;
158 inline G4int last(char) const;
159
160 inline G4bool contains(const std::string&) const;
161 inline G4bool contains(char) const;
162
163 // stripType = 0 beginning
164 // stripType = 1 end
165 // stripType = 2 both
166 //
167 inline G4String strip (G4int strip_Type=trailing, char c=' ');
168
169 inline void toLower ();
170 inline void toUpper ();
171
172 inline G4bool isNull() const;
173
174 inline str_size index (const char*, G4int pos=0) const;
175 inline str_size index (char, G4int pos=0) const;
177
178 inline const char* data() const;
179
180 inline G4int strcasecompare(const char*, const char*) const;
181
182 inline unsigned int hash( caseCompare cmp = exact ) const;
183 inline unsigned int stlhash() const;
184};
185
186#include "G4String.icc"
187
188#endif
std::string::size_type str_size
Definition: G4String.hh:57
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
G4bool operator!=(const char *) const
G4String & replace(str_size, str_size, const char *)
@ ignoreCase
Definition: G4String.hh:111
@ trailing
Definition: G4String.hh:112
unsigned int stlhash() const
G4String & remove(str_size)
G4SubString operator()(str_size, 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 &)
G4String & operator=(const std::string &)
G4String(const G4SubString &)
G4String(const char *, str_size)
G4bool contains(const std::string &) const
G4String & replace(unsigned int, unsigned int, const char *, unsigned int)
G4bool operator==(const char *) const
void toUpper()
G4String & operator+=(const G4SubString &)
unsigned int hash(caseCompare cmp=exact) const
G4bool operator==(const G4String &) const
G4String & operator+=(const char *)
G4String(const G4String &)
G4String(char)
G4int compareTo(const G4String &, caseCompare mode=exact) const
~G4String()
Definition: G4String.hh:121
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
G4int first(char) const
G4String(const char *)
G4int last(char) const
G4bool operator!=(const G4String &) const
G4bool operator!=(const char *) const
str_size length() const
char & operator()(str_size)
G4bool isNull() const
G4bool operator!=(const G4String &) const
G4bool operator==(const char *) const
G4SubString & operator=(const char *)
G4int operator!() const
G4SubString & operator=(const G4SubString &)
G4bool operator==(const G4String &) const
char operator[](str_size) const
G4SubString & operator=(const G4String &)
char & operator[](str_size)
G4SubString(const G4SubString &)
str_size start() const
char operator()(str_size) const