G4String Class Reference

#include <G4String.hh>


Public Types

 exact
 ignoreCase
 leading
 trailing
 both
enum  caseCompare { exact, ignoreCase }
enum  stripType { leading, trailing, both }

Public Member Functions

 G4String ()
 G4String (char)
 G4String (const char *)
 G4String (const char *, str_size)
 G4String (const G4String &)
 G4String (const G4SubString &)
 G4String (const std::string &)
 ~G4String ()
G4Stringoperator= (const G4String &)
G4Stringoperator= (const std::string &)
G4Stringoperator= (const char *)
char operator() (str_size) const
char & operator() (str_size)
G4Stringoperator+= (const G4SubString &)
G4Stringoperator+= (const char *)
G4Stringoperator+= (const std::string &)
G4Stringoperator+= (const char &)
G4bool operator== (const G4String &) const
G4bool operator== (const char *) const
G4bool operator!= (const G4String &) const
G4bool operator!= (const char *) const
 operator const char * () const
G4SubString operator() (str_size, str_size)
G4int compareTo (const char *, caseCompare mode=exact) const
G4int compareTo (const G4String &, caseCompare mode=exact) const
G4Stringprepend (const char *)
G4Stringappend (const G4String &)
std::istream & readLine (std::istream &, G4bool skipWhite=true)
G4Stringreplace (unsigned int, unsigned int, const char *, unsigned int)
G4Stringreplace (str_size, str_size, const char *)
G4Stringremove (str_size)
G4Stringremove (str_size, str_size)
G4int first (char) const
G4int last (char) const
G4bool contains (const std::string &) const
G4bool contains (char) const
G4String strip (G4int strip_Type=trailing, char c=' ')
void toLower ()
void toUpper ()
G4bool isNull () const
str_size index (const char *, G4int pos=0) const
str_size index (char, G4int pos=0) const
str_size index (const G4String &, str_size, str_size, caseCompare) const
const char * data () const
G4int strcasecompare (const char *, const char *) const
unsigned int hash (caseCompare cmp=exact) const
unsigned int stlhash () const


Detailed Description

Definition at line 104 of file G4String.hh.


Member Enumeration Documentation

enum G4String::caseCompare

Enumerator:
exact 
ignoreCase 

Definition at line 111 of file G4String.hh.

00111 { exact, ignoreCase };

enum G4String::stripType

Enumerator:
leading 
trailing 
both 

Definition at line 112 of file G4String.hh.

00112 { leading, trailing, both };


Constructor & Destructor Documentation

G4String::G4String (  )  [inline]

Definition at line 133 of file G4String.icc.

00133 {}

G4String::G4String ( char   )  [inline]

Definition at line 141 of file G4String.icc.

00142 {
00143   char str[2];
00144   str[0]=ch;
00145   str[1]='\0';
00146   std_string::operator=(str);
00147 }

G4String::G4String ( const char *   )  [inline]

Definition at line 135 of file G4String.icc.

00136  : std_string ( astring ) {}

G4String::G4String ( const char *  ,
str_size   
) [inline]

Definition at line 138 of file G4String.icc.

00139  : std_string ( astring, len ) {} 

G4String::G4String ( const G4String  )  [inline]

Definition at line 149 of file G4String.icc.

00150  : std_string(str) {}

G4String::G4String ( const G4SubString  )  [inline]

Definition at line 152 of file G4String.icc.

00153  : std_string(*(str.mystring),str.mystart,str.extent) {}

G4String::G4String ( const std::string &   )  [inline]

Definition at line 155 of file G4String.icc.

00156  : std_string(str) {}

G4String::~G4String (  )  [inline]

Definition at line 121 of file G4String.hh.

00121 {}


Member Function Documentation

G4String & G4String::append ( const G4String  )  [inline]

Definition at line 275 of file G4String.icc.

Referenced by G4UIcommandTree::AddNewCommand(), G4UImessenger::CreateDirectory(), G4CascadeParamMessenger::CreateDirectory(), G4UIcommand::DoIt(), G4UIcommandTree::FindCommandTree(), G4UIcommandTree::FindPath(), G4XmlAnalysisManager::FinishNtuple(), G4CloneDaughters(), G4CreateCloneVTE(), G4CreateCloneVTEWithDivision(), G4UIGainServer::GetCommand(), G4UIGAG::GetCommand(), G4UItcsh::GetCommandLineString(), G4UIcsh::GetCommandLineString(), G4UImanager::GetCurrentStringValue(), G4VAnalysisManager::GetFullFileName(), G4tgrFileIn::GetWordsInLine(), G4VUIshell::MakePrompt(), G4UItcsh::MakePrompt(), G4XmlAnalysisManager::OpenFile(), G4RootAnalysisManager::OpenFile(), G4CsvAnalysisManager::OpenFile(), G4UIcommandTree::RemoveCommand(), G4GDMLEvaluator::SolveBrackets(), G4XmlAnalysisManager::Write(), and G4VAnalysisManager::WriteAscii().

00276 {
00277   std_string::operator+=(str);
00278   return *this;
00279 }

G4int G4String::compareTo ( const G4String ,
caseCompare  mode = exact 
) const [inline]

Definition at line 264 of file G4String.icc.

References compareTo().

00265 {
00266   return compareTo(str.c_str(), mode);
00267 }

G4int G4String::compareTo ( const char *  ,
caseCompare  mode = exact 
) const [inline]

Definition at line 258 of file G4String.icc.

References exact, and strcasecompare().

Referenced by compareTo(), G4VisCommandsViewerSet::SetNewValue(), and G4VisCommandSceneHandlerCreate::SetNewValue().

00259 {
00260   return (mode==exact) ? strcmp(c_str(),str)
00261                        : strcasecompare(c_str(),str);
00262 }

G4bool G4String::contains ( char   )  const [inline]

Definition at line 339 of file G4String.icc.

00340 {
00341   return (std_string::find(ch) != std_string::npos);
00342 }

G4bool G4String::contains ( const std::string &   )  const [inline]

Definition at line 334 of file G4String.icc.

Referenced by G4GDMLWrite::GenerateName(), and G3VolTableEntry::GetMasterClone().

00335 {
00336   return (std_string::find(str) != std_string::npos);
00337 }

const char * G4String::data (  )  const [inline]

Definition at line 430 of file G4String.icc.

Referenced by G4UImanager::ApplyCommand(), G4HEPEvtInterface::G4HEPEvtInterface(), G4SubString::operator=(), PG4gsdetu(), PG4gsmixt(), and G4AnalysisMessenger::SetNewValue().

00431 {
00432   return c_str();
00433 }

G4int G4String::first ( char   )  const [inline]

Definition at line 324 of file G4String.icc.

Referenced by G4SDStructure::Activate(), G4UIcommandTree::AddNewCommand(), G4NeutronHPThermalScatteringData::BuildPhysicsTable(), G4HadronicProcess::CheckEnergyMomentumConservation(), G4GDMLReadStructure::DivisionvolRead(), G4UIcommandTree::FindCommandTree(), G4UIcommandTree::FindPath(), G4SDStructure::FindSensitiveDetector(), G3VolTableEntry::GetMasterClone(), G4AttDefStore::GetStoreKey(), G4AttValueFilterT< T, ConversionErrorPolicy >::GetValidElement(), operator<<(), G4GDMLReadStructure::PhysvolRead(), G4UIcommandTree::RemoveCommand(), and G4GDMLReadStructure::ReplicaRead().

00325 {
00326   return find(ch);
00327 }

unsigned int G4String::hash ( caseCompare  cmp = exact  )  const [inline]

Definition at line 435 of file G4String.icc.

00436 {
00437   const char* str=c_str();
00438   unsigned long h = 0;
00439   for ( ; *str; ++str)
00440     { h = 5*h + *str; }
00441 
00442   return str_size(h);
00443 }

str_size G4String::index ( const G4String ,
str_size  ,
str_size  ,
caseCompare   
) const [inline]

Definition at line 409 of file G4String.icc.

00411 {
00412   return std_string::find( str.c_str(), st, ln );
00413 }

str_size G4String::index ( char  ,
G4int  pos = 0 
) const [inline]

Definition at line 420 of file G4String.icc.

00421 {
00422   return std_string::find(ch,pos);
00423 }

str_size G4String::index ( const char *  ,
G4int  pos = 0 
) const [inline]

Definition at line 415 of file G4String.icc.

Referenced by G4UImanager::ApplyCommand(), G4VBasicShell::Complete(), G4UIcommandTree::CompleteCommandPath(), G4UIcommand::DoIt(), G4VBasicShell::FindCommand(), G4UIcommandTree::FindCommandTree(), G4VBasicShell::FindDirectory(), G4UIcommandTree::FindPath(), G4UIArrayString::G4UIArrayString(), G4VUIshell::GetAbsCommandDirPath(), G4HCtable::GetCollectionID(), G4DCtable::GetCollectionID(), G4VUIshell::ListCommand(), G4VBasicShell::ModifyToFullPathCommand(), G4UImanager::ParseMacroSearchPath(), G4RunManager::RestoreRandomNumberStatus(), G4UImanager::SetAlias(), G4UImanager::SolveAlias(), and G4VBasicShell::TerminalHelp().

00416 {
00417   return std_string::find(str,pos);
00418 }

G4bool G4String::isNull (  )  const [inline]

Definition at line 402 of file G4String.icc.

Referenced by G4SDStructure::Activate(), G4UIcommandTree::AddNewCommand(), G4SDStructure::AddNewDetector(), G4UImanager::ApplyCommand(), G4UIparameter::CheckNewValue(), G4UIcommand::CheckNewValue(), G4UIcommand::DoIt(), G4TrajectoryDrawByAttribute::Draw(), G4AttributeFilterT< T >::Evaluate(), G4VisCommandOpen::G4VisCommandOpen(), G4VisCommandSceneHandlerCreate::G4VisCommandSceneHandlerCreate(), G4UImanager::GetCurrentStringValue(), G4MolecularConfiguration::GetName(), G4UIparameter::List(), G4UIcommand::List(), G4VBasicShell::ModifyToFullPathCommand(), G4VisListManager< T >::Print(), G4VisFilterManager< T >::Print(), G4UIcommandTree::RemoveCommand(), G4VisCommandModelCreate< Factory >::SetNewValue(), G4ProcessTableMessenger::SetNewValue(), G4PolarizationMessenger::SetNewValue(), G4VUserPhysicsList::SetPhysicsTableRetrieved(), G4VBasicShell::ShowCurrent(), G4TextPPRetriever::SparseOption(), G4TextPPReporter::SparseOption(), and G4VUserPhysicsList::StorePhysicsTable().

00403 {
00404   return empty ();
00405 }

G4int G4String::last ( char   )  const [inline]

Definition at line 329 of file G4String.icc.

Referenced by G4UItcsh::CompleteCommand(), G4UIcommandTree::CompleteCommandPath(), G4SDStructure::G4SDStructure(), G4VSensitiveDetector::G4VSensitiveDetector(), G4VUIshell::GetAbsCommandDirPath(), and G4UItcsh::ListMatchedCommand().

00330 {
00331   return rfind(ch);
00332 }

G4String::operator const char * (  )  const [inline]

Definition at line 237 of file G4String.icc.

00238 {
00239   return c_str();
00240 }

G4bool G4String::operator!= ( const char *   )  const [inline]

Definition at line 232 of file G4String.icc.

00233 {
00234   return !(*this == str);
00235 }

G4bool G4String::operator!= ( const G4String  )  const [inline]

Definition at line 227 of file G4String.icc.

00228 {
00229   return !(*this == str);
00230 }

G4SubString G4String::operator() ( str_size  ,
str_size   
) [inline]

Definition at line 425 of file G4String.icc.

00426 {
00427   return G4SubString(*this,start,extent);
00428 }

char & G4String::operator() ( str_size   )  [inline]

Definition at line 187 of file G4String.icc.

00188 {
00189   return std_string::operator[](i);
00190 }

char G4String::operator() ( str_size   )  const [inline]

Definition at line 182 of file G4String.icc.

00183 {
00184   return operator[](i);
00185 }

G4String & G4String::operator+= ( const char &   )  [inline]

Definition at line 211 of file G4String.icc.

00212 {
00213   std_string::operator+=(ch);
00214   return *this;
00215 }

G4String & G4String::operator+= ( const std::string &   )  [inline]

Definition at line 205 of file G4String.icc.

00206 {
00207   std_string::operator+=(str);
00208   return *this;
00209 }

G4String & G4String::operator+= ( const char *   )  [inline]

Definition at line 199 of file G4String.icc.

00200 {
00201   std_string::operator+=(str);
00202   return *this;
00203 }

G4String & G4String::operator+= ( const G4SubString  )  [inline]

Definition at line 192 of file G4String.icc.

00193 {
00194   G4String tmp(str);
00195   std_string::operator+=(tmp);
00196   return *this;
00197 }

G4String & G4String::operator= ( const char *   )  [inline]

Definition at line 171 of file G4String.icc.

00172 {
00173   std_string::operator=(str);
00174   return *this;
00175 }

G4String & G4String::operator= ( const std::string &   )  [inline]

Definition at line 165 of file G4String.icc.

00166 {
00167   std_string::operator=(str);
00168   return *this;
00169 }

G4String & G4String::operator= ( const G4String  )  [inline]

Definition at line 158 of file G4String.icc.

00159 {
00160   if (&str == this) { return *this; }
00161   std_string::operator=(str);
00162   return *this;
00163 }

G4bool G4String::operator== ( const char *   )  const [inline]

Definition at line 222 of file G4String.icc.

00223 {
00224   return (std_string::compare(str) == 0);
00225 }

G4bool G4String::operator== ( const G4String  )  const [inline]

Definition at line 217 of file G4String.icc.

00218 {
00219   return (std_string::compare(str) == 0);
00220 }

G4String & G4String::prepend ( const char *   )  [inline]

Definition at line 269 of file G4String.icc.

Referenced by G4SDManager::Activate(), G4SDManager::AddNewDetector(), G4CascadeParamMessenger::CreateDirectory(), G4SDManager::FindSensitiveDetector(), and G4VSensitiveDetector::G4VSensitiveDetector().

00270 {
00271   insert(0,str);
00272   return *this;
00273 }

std::istream & G4String::readLine ( std::istream &  ,
G4bool  skipWhite = true 
) [inline]

Definition at line 282 of file G4String.icc.

Referenced by G3CLRead(), G4UIGainServer::GetCommand(), G4UIGAG::GetCommand(), and G4UIcsh::GetCommandLineString().

00283 {
00284   char tmp[1024];
00285   if ( skipWhite )
00286   {
00287     strm >> std::ws;
00288     strm.getline(tmp,1024);
00289     *this=tmp;
00290   }
00291   else
00292   {
00293     strm.getline(tmp,1024);    
00294     *this=tmp;
00295   } 
00296   return strm;
00297 }

G4String & G4String::remove ( str_size  ,
str_size   
) [inline]

Definition at line 318 of file G4String.icc.

00319 {
00320   erase(pos,N+pos);
00321   return *this;
00322 }

G4String & G4String::remove ( str_size   )  [inline]

Definition at line 312 of file G4String.icc.

Referenced by G4SDStructure::Activate(), G4UIcommandTree::AddNewCommand(), G4SDStructure::AddNewDetector(), G4UImanager::ApplyCommand(), G4UItcsh::CompleteCommand(), G4UIcommandTree::CompleteCommandPath(), G4UIcommandTree::FindCommandTree(), G4UIcommandTree::FindPath(), G4SDStructure::FindSensitiveDetector(), G4SDStructure::G4SDStructure(), G4VSensitiveDetector::G4VSensitiveDetector(), G4VUIshell::GetAbsCommandDirPath(), G4UIGainServer::GetCommand(), G4UIGAG::GetCommand(), G4UItcsh::GetCommandLineString(), G4UIcsh::GetCommandLineString(), G4UItcsh::ListMatchedCommand(), G4AdjointSimManager::RegisterAtEndOfAdjointTrack(), G4UIcommandTree::RemoveCommand(), G4GDMLRead::Strip(), and G4GDMLRead::StripName().

00313 {
00314   if(n<size()) { erase(n,size()-n); }
00315   return *this;
00316 }

G4String & G4String::replace ( str_size  ,
str_size  ,
const char *   
) [inline]

Definition at line 306 of file G4String.icc.

00307 {
00308   std_string::replace(pos,n,str);
00309   return *this;
00310 }

G4String & G4String::replace ( unsigned  int,
unsigned  int,
const char *  ,
unsigned  int 
) [inline]

Definition at line 299 of file G4String.icc.

Referenced by G4SubString::operator=().

00301 {
00302   std_string::replace ( start, nbytes, buff, n2 ); 
00303   return *this;                                                              
00304 }                                                                          

unsigned int G4String::stlhash (  )  const [inline]

Definition at line 445 of file G4String.icc.

00446 {
00447   const char* str=c_str();
00448   unsigned long h = 0;
00449   for ( ; *str; ++str)
00450     { h = 5*h + *str; }
00451 
00452   return str_size(h);
00453 }

G4int G4String::strcasecompare ( const char *  ,
const char *   
) const [inline]

Definition at line 242 of file G4String.icc.

Referenced by compareTo().

00243 {
00244   char* buf1 = new char[strlen(s1)+1];
00245   char* buf2 = new char[strlen(s2)+1];
00246 
00247   for (str_size i=0; i<=strlen(s1); i++)
00248     { buf1[i] = tolower(char(s1[i])); }
00249   for (str_size j=0; j<=strlen(s2); j++)
00250     { buf2[j] = tolower(char(s2[j])); }
00251 
00252   G4int res = strcmp(buf1, buf2);
00253   delete [] buf1;
00254   delete [] buf2;
00255   return res;
00256 }

G4String G4String::strip ( G4int  strip_Type = trailing,
char  c = ' ' 
) [inline]

Definition at line 344 of file G4String.icc.

References both, leading, and trailing.

Referenced by G4VBasicShell::ApplyShellCommand(), G4VBasicShell::ChangeDirectory(), G4VBasicShell::ChangeDirectoryCommand(), G4VBasicShell::Complete(), G4UItcsh::CompleteCommand(), G4ConversionUtils::Convert(), G4VBasicShell::FindCommand(), G4VBasicShell::FindDirectory(), G4gsmate(), G4UIArrayString::G4UIArrayString(), G4UItcsh::G4UItcsh(), G4VisCommandOpen::G4VisCommandOpen(), G4VisCommandSceneHandlerCreate::G4VisCommandSceneHandlerCreate(), G4VViewer::G4VViewer(), G4UIGainServer::GetCommand(), G4UIGAG::GetCommand(), G4UIcsh::GetCommandLineString(), G4VUIshell::GetCommandTree(), G4VUIshell::ListCommand(), G4VBasicShell::ListDirectory(), G4UItcsh::ListMatchedCommand(), G4RadioactiveDecay::LoadDecayTable(), G4VBasicShell::ModifyToFullPathCommand(), G4UImanager::RemoveAlias(), G4VViewer::SetName(), G4VisCommandViewerCreate::SetNewValue(), G4VisCommandViewerClone::SetNewValue(), G4AttCheck::Standard(), G4VBasicShell::TerminalHelp(), and G4VisManager::ViewerShortName().

00345 {
00346   G4String retVal = *this;
00347   if(length()==0) { return retVal; }
00348   str_size i=0;
00349   switch ( strip_Type ) {
00350   case leading: 
00351     {
00352       for(i=0;i<length();i++)
00353         { if (std_string::operator[](i) != ch) { break; } }
00354       retVal = substr(i,length()-i);
00355     }
00356     break;
00357   case trailing:
00358     {
00359       G4int j=0;
00360       for(j=length()-1;j>=0;j--)
00361         { if (std_string::operator[](j) != ch) { break; } }
00362       retVal = substr(0,j+1);
00363     }
00364     break;
00365   case both:
00366     { 
00367       for(i=0;i<length();i++)
00368         { if (std_string::operator[](i) != ch) { break; } }
00369       G4String tmp(substr(i,length()-i));
00370       G4int k=0;
00371       for(k=tmp.length()-1;k>=0;k--)
00372         { if (tmp.std_string::operator[](k) != ch) { break; } }
00373       retVal = tmp.substr(0,k+1);
00374     }
00375     break;
00376   default:
00377     break;
00378   }
00379   return retVal;
00380 }

void G4String::toLower (  )  [inline]

Definition at line 382 of file G4String.icc.

Referenced by G4Colour::AddToMap(), G4UIExecutive::G4UIExecutive(), G4Colour::GetColour(), G4VAnalysisManager::GetFileType(), G4VisManager::GetVerbosityValue(), G4VisFilterManager< T >::SetMode(), and G4INCLXXInterfaceMessenger::SetNewValue().

00383 {
00384   for (str_size i=0; i<size();i++)
00385   {
00386     //GB:HP-UX-aCC,Linux-KCC 
00387     std_string::operator[](i) = tolower(char(std_string::operator[](i)));
00388     //at(i) = tolower(at(i)); 
00389   } 
00390 }

void G4String::toUpper (  )  [inline]

Definition at line 392 of file G4String.icc.

Referenced by G4UIcommand::ConvertToBool(), and G4UImessenger::StoB().

00393 {
00394   for (str_size i=0; i<size();i++)
00395   {
00396     //GB:HP-UX-aCC,Linux-KCC 
00397     std_string::operator[](i) = toupper(char(std_string::operator[](i)));
00398     //at(i) = toupper(at(i)); 
00399   }
00400 }


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:53:27 2013 for Geant4 by  doxygen 1.4.7