Import Geant4 11.0.0 source tree
This commit is contained in:
committed by
Ben Morgan
parent
6399a014b6
commit
80e2389dd8
@@ -16,6 +16,37 @@ committal in the CVS repository !
|
||||
* Reverse chronological order (last date on top), please *
|
||||
----------------------------------------------------------
|
||||
|
||||
26 October, 2021 M. Asai (intercoms-V10-07-14)
|
||||
- G4UIcommandTree, G4UIdirectory, G4GenericMessenger
|
||||
- Improve output HTML file layout (L.Garnier)
|
||||
- Add option to sort command/directory names in alphabetic order (J.Allison)
|
||||
|
||||
25 October, 2021 B.Morgan (intercoms-V10-07-13)
|
||||
- Use G4StrUtil functions replacing deprecated G4String member functions
|
||||
|
||||
18 October, 2021 B.Morgan (intercoms-V10-07-12)
|
||||
- Use std::string member functions from G4String in place of synonyms
|
||||
|
||||
1 October, 2021 B. Morgan (intercoms-V10-07-11)
|
||||
- Use new std::string compliant G4String interfaces
|
||||
|
||||
30 August, 2021 J. Allison (intercoms-V10-07-10)
|
||||
- G4UIparameter::CandidateCheck :
|
||||
When candidate not found, print list of candidates.
|
||||
|
||||
11 July, 2021 M. Asai (intercoms-V10-07-08, -09)
|
||||
- G4GenericMessenger :
|
||||
Adding G4ThreeVector type without unit to DeclareProperty().
|
||||
Removing unnecessary duplications of G4UIdirectory objects.
|
||||
.
|
||||
06 July, 2021 M. Asai (intercoms-V10-07-07)
|
||||
- G4UImanager : adding access methods to individual UI command.
|
||||
G4UIcommand : adding command-type identiifier.
|
||||
|
||||
30 June, 2021 M. Asai (intercoms-V10-07-06)
|
||||
- G4UIcontrolMessenger : protect some control commands not to be
|
||||
broadcasted to worker threads.
|
||||
|
||||
06 May, 2021 G. Cosmo (intercoms-V10-07-05)
|
||||
- Fixed shadowing compilation warning in G4UImanager reported with gcc-11.
|
||||
|
||||
|
||||
@@ -128,6 +128,8 @@ class G4GenericMessenger : public G4UImessenger
|
||||
return SetUnit(u, UnitDefault);
|
||||
}
|
||||
Command& SetParameterName(const G4String&, G4bool, G4bool = false);
|
||||
Command& SetParameterName(const G4String&, const G4String&, const G4String&,
|
||||
G4bool, G4bool = false);
|
||||
Command& SetDefaultValue(const G4String&);
|
||||
Command& SetCandidates(const G4String&);
|
||||
Command& SetToBeBroadcasted(G4bool s0)
|
||||
@@ -189,6 +191,8 @@ class G4GenericMessenger : public G4UImessenger
|
||||
const G4String& doc = "");
|
||||
void SetDirectory(const G4String& dir) { directory = dir; }
|
||||
void SetGuidance(const G4String& s);
|
||||
void Sort(G4bool val = true)
|
||||
{ if(dircmd) dircmd->Sort(val); }
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -194,6 +194,20 @@ class G4UIcommand
|
||||
failureDescription = "";
|
||||
}
|
||||
|
||||
public:
|
||||
enum CommandType
|
||||
{ BaseClassCmd, WithoutParameterCmd,
|
||||
WithABoolCmd, WithAnIntegerCmd, WithALongIntCmd,
|
||||
WithADoubleCmd, WithADoubleAndUnitCmd, With3VectorCmd, With3VectorAndUnitCmd,
|
||||
WithAStringCmd, CmdDirectory = -1 };
|
||||
|
||||
inline CommandType GetCommandType() const
|
||||
{ return commandType; }
|
||||
void SetCommandType(CommandType);
|
||||
|
||||
inline void SetDefaultSortFlag(G4bool val)
|
||||
{ ifSort = val; }
|
||||
|
||||
protected:
|
||||
|
||||
// --- the following is used by CheckNewValue() --------
|
||||
@@ -209,6 +223,8 @@ class G4UIcommand
|
||||
G4int commandFailureCode = 0;
|
||||
G4String failureDescription = "";
|
||||
|
||||
G4bool ifSort = false;
|
||||
|
||||
private:
|
||||
|
||||
void G4UIcommandCommonConstructorCode(const char* theCommandPath);
|
||||
@@ -246,6 +262,8 @@ class G4UIcommand
|
||||
|
||||
// Data -----------------------------------------------------------
|
||||
|
||||
private:
|
||||
CommandType commandType = BaseClassCmd;
|
||||
G4UImessenger* messenger = nullptr;
|
||||
G4String commandPath;
|
||||
G4String commandName;
|
||||
|
||||
@@ -66,7 +66,7 @@ class G4UIcommandTree
|
||||
void List() const;
|
||||
void ListCurrent() const;
|
||||
void ListCurrentWithNum() const;
|
||||
void CreateHTML();
|
||||
void CreateHTML(G4String = "");
|
||||
|
||||
inline const G4UIcommand* GetGuidance() const { return guidance; }
|
||||
inline const G4String& GetPathName() const { return pathName; }
|
||||
@@ -91,6 +91,8 @@ class G4UIcommandTree
|
||||
G4UIcommand* guidance = nullptr;
|
||||
G4String pathName;
|
||||
G4bool broadcastCommands = true;
|
||||
G4bool ifSort = false;
|
||||
G4int createHTMLTreeLevel = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -47,6 +47,12 @@ class G4UIdirectory : public G4UIcommand
|
||||
G4bool commandsToBeBroadcasted = true);
|
||||
// Constructors. The argument is a full path directory which
|
||||
// starts and ends with "/".
|
||||
|
||||
void Sort(G4bool val = true)
|
||||
{ ifSort = val; }
|
||||
G4bool IfSort() const
|
||||
{ return ifSort; }
|
||||
// N.B. ifSort is defined in the base class G4UIcommand
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -107,6 +107,13 @@ class G4UImanager : public G4VStateDependent
|
||||
// x00 : G4CommandStatus.hh enumeration
|
||||
// yy : the problematic parameter (first found)
|
||||
|
||||
G4UIcommand* FindCommand(const char* aCommand);
|
||||
G4UIcommand* FindCommand(const G4String& aCommand);
|
||||
// Find the G4UIcommand object. Null pointer is returned if command
|
||||
// is not found.
|
||||
// Please note that each thread returns different objects if this
|
||||
// method is used in multi-threaded mode.
|
||||
|
||||
void StoreHistory(const char* fileName = "G4history.macro");
|
||||
void StoreHistory(G4bool historySwitch,
|
||||
const char* fileName = "G4history.macro");
|
||||
|
||||
@@ -110,10 +110,10 @@ template <typename T>
|
||||
T* G4UImessenger::CreateCommand(const G4String& cname, const G4String& dsc)
|
||||
{
|
||||
G4String path;
|
||||
if(cname(0) != '/')
|
||||
if(cname[0] != '/')
|
||||
{
|
||||
path = baseDirName + cname;
|
||||
if(path(0) != '/')
|
||||
if(path[0] != '/')
|
||||
path = "/" + path;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,17 @@
|
||||
//
|
||||
// G4GenericMessenger
|
||||
//
|
||||
// Author: P.Mato, CERN - 27 September 2012
|
||||
// Author:
|
||||
// P.Mato, CERN - 27 September 2012
|
||||
// Updates:
|
||||
// M.Asai, SLAC - 26 November 2013
|
||||
// Adding methods with unit declaration and making thread-safe for
|
||||
// version 10.
|
||||
// M.Asai, SLAC - 04 May 2014
|
||||
// Fix core dump when GetCurrentValue() method is invoked for
|
||||
// a command defined by DeclareMethod().
|
||||
// M.Asai, SLAC - 11 July 2021
|
||||
// Adding G4ThreeVector type without unit
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4GenericMessenger.hh"
|
||||
@@ -32,6 +42,7 @@
|
||||
#include "G4UImessenger.hh"
|
||||
#include "G4UIcommand.hh"
|
||||
#include "G4UIcmdWithADoubleAndUnit.hh"
|
||||
#include "G4UIcmdWith3Vector.hh"
|
||||
#include "G4UIcmdWith3VectorAndUnit.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4Threading.hh"
|
||||
@@ -54,18 +65,6 @@ G4GenericMessenger::G4GenericMessenger(void* obj, const G4String& dir,
|
||||
: directory(dir)
|
||||
, object(obj)
|
||||
{
|
||||
// Check if parent commnand is already existing.
|
||||
// In fact there is no way to check this. UImanager->GetTree()->FindPath()
|
||||
// will always rerurn NULL is a dicrectory is given
|
||||
std::size_t pos = dir.find_last_of('/', dir.size() - 2);
|
||||
while(pos != 0 && pos != std::string::npos)
|
||||
{
|
||||
G4UIdirectory* d = new G4UIdirectory(dir.substr(0, pos + 1).c_str());
|
||||
G4String guidance = "Commands for ";
|
||||
guidance += dir.substr(1, pos - 1);
|
||||
d->SetGuidance(guidance);
|
||||
pos = dir.find_last_of('/', pos - 1);
|
||||
}
|
||||
dircmd = new G4UIdirectory(dir);
|
||||
dircmd->SetGuidance(doc);
|
||||
}
|
||||
@@ -83,23 +82,33 @@ G4GenericMessenger::Command& G4GenericMessenger::DeclareProperty(
|
||||
const G4String& name, const G4AnyType& var, const G4String& doc)
|
||||
{
|
||||
G4String fullpath = directory + name;
|
||||
G4UIcommand* cmd = new G4UIcommand(fullpath.c_str(), this);
|
||||
if(doc != "")
|
||||
cmd->SetGuidance(doc);
|
||||
char ptype;
|
||||
if(var.TypeInfo() == typeid(int) || var.TypeInfo() == typeid(long) ||
|
||||
var.TypeInfo() == typeid(unsigned int) ||
|
||||
var.TypeInfo() == typeid(unsigned long))
|
||||
ptype = 'i';
|
||||
else if(var.TypeInfo() == typeid(float) || var.TypeInfo() == typeid(double))
|
||||
ptype = 'd';
|
||||
else if(var.TypeInfo() == typeid(bool))
|
||||
ptype = 'b';
|
||||
else if(var.TypeInfo() == typeid(G4String))
|
||||
ptype = 's';
|
||||
G4UIcommand* cmd = nullptr;
|
||||
if(var.TypeInfo() == typeid(G4ThreeVector))
|
||||
{
|
||||
cmd = new G4UIcmdWith3Vector(fullpath.c_str(), this);
|
||||
(static_cast<G4UIcmdWith3Vector*>(cmd))
|
||||
->SetParameterName("valueX", "valueY", "valueZ", false, false);
|
||||
}
|
||||
else
|
||||
ptype = 's';
|
||||
cmd->SetParameter(new G4UIparameter("value", ptype, false));
|
||||
{
|
||||
cmd = new G4UIcommand(fullpath.c_str(), this);
|
||||
char ptype;
|
||||
if(var.TypeInfo() == typeid(int) || var.TypeInfo() == typeid(long) ||
|
||||
var.TypeInfo() == typeid(unsigned int) ||
|
||||
var.TypeInfo() == typeid(unsigned long))
|
||||
{ ptype = 'i'; }
|
||||
else if(var.TypeInfo() == typeid(float) || var.TypeInfo() == typeid(double))
|
||||
{ ptype = 'd'; }
|
||||
else if(var.TypeInfo() == typeid(bool))
|
||||
{ ptype = 'b'; }
|
||||
else if(var.TypeInfo() == typeid(G4String))
|
||||
{ ptype = 's'; }
|
||||
else
|
||||
{ ptype = 's'; }
|
||||
cmd->SetParameter(new G4UIparameter("value", ptype, false));
|
||||
}
|
||||
if(doc != "")
|
||||
{ cmd->SetGuidance(doc); }
|
||||
return properties[name] = Property(var, cmd);
|
||||
}
|
||||
|
||||
@@ -322,6 +331,31 @@ G4GenericMessenger::Command& G4GenericMessenger::Command::SetParameterName(
|
||||
return *this;
|
||||
}
|
||||
|
||||
G4GenericMessenger::Command& G4GenericMessenger::Command::SetParameterName(
|
||||
const G4String& namex, const G4String& namey, const G4String& namez,
|
||||
G4bool omittable, G4bool currentAsDefault)
|
||||
{
|
||||
if(*type != typeid(G4ThreeVector))
|
||||
{
|
||||
G4cerr << "This SetParameterName method is for G4ThreeVector!! "
|
||||
<< "Method ignored." << G4endl;
|
||||
return *this;
|
||||
}
|
||||
G4UIparameter* theParam = command->GetParameter(0);
|
||||
theParam->SetParameterName(namex);
|
||||
theParam->SetOmittable(omittable);
|
||||
theParam->SetCurrentAsDefault(currentAsDefault);
|
||||
theParam = command->GetParameter(1);
|
||||
theParam->SetParameterName(namey);
|
||||
theParam->SetOmittable(omittable);
|
||||
theParam->SetCurrentAsDefault(currentAsDefault);
|
||||
theParam = command->GetParameter(2);
|
||||
theParam->SetParameterName(namez);
|
||||
theParam->SetOmittable(omittable);
|
||||
theParam->SetCurrentAsDefault(currentAsDefault);
|
||||
return *this;
|
||||
}
|
||||
|
||||
G4GenericMessenger::Command& G4GenericMessenger::Command::SetCandidates(
|
||||
const G4String& candList)
|
||||
{
|
||||
|
||||
@@ -111,15 +111,15 @@ G4String G4UIbatch::ReadCommand()
|
||||
G4String cmdline(linebuf);
|
||||
|
||||
// TAB-> ' ' conversion
|
||||
str_size nb = 0;
|
||||
G4String::size_type nb = 0;
|
||||
while((nb = cmdline.find('\t', nb)) != G4String::npos)
|
||||
{
|
||||
cmdline.replace(nb, 1, " ");
|
||||
}
|
||||
|
||||
// strip
|
||||
cmdline = cmdline.strip(G4String::both);
|
||||
cmdline = cmdline.strip(G4String::trailing, ctrM);
|
||||
G4StrUtil::strip(cmdline);
|
||||
G4StrUtil::rstrip(cmdline, ctrM);
|
||||
|
||||
// skip null line if single line
|
||||
if(!qcontinued && cmdline.size() == 0)
|
||||
@@ -139,7 +139,7 @@ G4String G4UIbatch::ReadCommand()
|
||||
if(tokens[i][(std::size_t) 0] == '#')
|
||||
break;
|
||||
// '\' or '_' is treated as continued line.
|
||||
if(tokens[i] == '\\' || tokens[i] == '_')
|
||||
if(tokens[i] == "\\" || tokens[i] == "_")
|
||||
{
|
||||
qcontinued = true;
|
||||
// check nothing after line continuation character
|
||||
@@ -164,7 +164,7 @@ G4String G4UIbatch::ReadCommand()
|
||||
}
|
||||
|
||||
// strip again
|
||||
cmdtotal = cmdtotal.strip(G4String::both);
|
||||
G4StrUtil::strip(cmdtotal);
|
||||
|
||||
// finally,
|
||||
if(macroStream.eof() && cmdtotal.size() == 0)
|
||||
|
||||
@@ -35,7 +35,7 @@ G4UIbridge::G4UIbridge(G4UImanager* localUI, G4String dir)
|
||||
: localUImanager(localUI)
|
||||
{
|
||||
// make sure dirName starts and ends with '/'
|
||||
if(dir(0, 1) == "/")
|
||||
if(dir[0] == '/')
|
||||
{
|
||||
dirName = dir;
|
||||
}
|
||||
@@ -43,7 +43,7 @@ G4UIbridge::G4UIbridge(G4UImanager* localUI, G4String dir)
|
||||
{
|
||||
dirName = "/" + dir;
|
||||
}
|
||||
if(dirName(dirName.length() - 1, 1) != "/")
|
||||
if(dirName.back() != '/')
|
||||
{
|
||||
dirName += "/";
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ G4UIcmdWith3Vector::G4UIcmdWith3Vector(const char* theCommandPath,
|
||||
SetParameter(dblParamY);
|
||||
G4UIparameter* dblParamZ = new G4UIparameter('d');
|
||||
SetParameter(dblParamZ);
|
||||
SetCommandType(With3VectorCmd);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
@@ -46,8 +46,9 @@ G4UIcmdWith3VectorAndUnit::G4UIcmdWith3VectorAndUnit(
|
||||
G4UIparameter* dblParamZ = new G4UIparameter('d');
|
||||
SetParameter(dblParamZ);
|
||||
G4UIparameter* untParam = new G4UIparameter('s');
|
||||
SetParameter(untParam);
|
||||
untParam->SetParameterName("Unit");
|
||||
SetParameter(untParam);
|
||||
SetCommandType(With3VectorAndUnitCmd);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
@@ -37,6 +37,7 @@ G4UIcmdWithABool::G4UIcmdWithABool(const char* theCommandPath,
|
||||
{
|
||||
G4UIparameter* blParam = new G4UIparameter('b');
|
||||
SetParameter(blParam);
|
||||
SetCommandType(WithABoolCmd);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
@@ -37,6 +37,7 @@ G4UIcmdWithADouble::G4UIcmdWithADouble(const char* theCommandPath,
|
||||
{
|
||||
G4UIparameter* dblParam = new G4UIparameter('d');
|
||||
SetParameter(dblParam);
|
||||
SetCommandType(WithADoubleCmd);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
@@ -43,8 +43,9 @@ G4UIcmdWithADoubleAndUnit::G4UIcmdWithADoubleAndUnit(
|
||||
G4UIparameter* dblParam = new G4UIparameter('d');
|
||||
SetParameter(dblParam);
|
||||
G4UIparameter* untParam = new G4UIparameter('s');
|
||||
SetParameter(untParam);
|
||||
untParam->SetParameterName("Unit");
|
||||
SetParameter(untParam);
|
||||
SetCommandType(WithADoubleAndUnitCmd);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
@@ -37,6 +37,7 @@ G4UIcmdWithALongInt::G4UIcmdWithALongInt(const char* theCommandPath,
|
||||
{
|
||||
G4UIparameter* longParam = new G4UIparameter('l');
|
||||
SetParameter(longParam);
|
||||
SetCommandType(WithALongIntCmd);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
@@ -37,6 +37,7 @@ G4UIcmdWithAString::G4UIcmdWithAString(const char* theCommandPath,
|
||||
{
|
||||
G4UIparameter* strParam = new G4UIparameter('s');
|
||||
SetParameter(strParam);
|
||||
SetCommandType(WithAStringCmd);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
@@ -37,6 +37,7 @@ G4UIcmdWithAnInteger::G4UIcmdWithAnInteger(const char* theCommandPath,
|
||||
{
|
||||
G4UIparameter* intParam = new G4UIparameter('i');
|
||||
SetParameter(intParam);
|
||||
SetCommandType(WithAnIntegerCmd);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
@@ -35,4 +35,5 @@ G4UIcmdWithoutParameter::G4UIcmdWithoutParameter(const char* theCommandPath,
|
||||
G4UImessenger* theMessenger)
|
||||
: G4UIcommand(theCommandPath, theMessenger)
|
||||
{
|
||||
SetCommandType(WithoutParameterCmd);
|
||||
}
|
||||
|
||||
@@ -57,18 +57,7 @@ G4UIcommand::G4UIcommand(const char* theCommandPath,
|
||||
, messenger(theMessenger)
|
||||
{
|
||||
G4String comStr = theCommandPath;
|
||||
if(!theMessenger)
|
||||
{ // this must be a directory
|
||||
if(comStr(comStr.length() - 1) != '/')
|
||||
{
|
||||
G4cerr << "G4UIcommand Warning : " << G4endl;
|
||||
G4cerr << " <" << theCommandPath << "> must be a directory." << G4endl;
|
||||
G4cerr << " '/' is appended." << G4endl;
|
||||
comStr += "/";
|
||||
}
|
||||
}
|
||||
G4UIcommandCommonConstructorCode(comStr);
|
||||
G4String nullString;
|
||||
availabelStateList.clear();
|
||||
availabelStateList.push_back(G4State_PreInit);
|
||||
availabelStateList.push_back(G4State_Init);
|
||||
@@ -83,8 +72,8 @@ void G4UIcommand::G4UIcommandCommonConstructorCode(const char* theCommandPath)
|
||||
{
|
||||
commandPath = theCommandPath;
|
||||
commandName = theCommandPath;
|
||||
G4int commandNameIndex = commandName.last('/');
|
||||
commandName.remove(0, commandNameIndex + 1);
|
||||
G4int commandNameIndex = commandName.rfind('/');
|
||||
commandName.erase(0, commandNameIndex + 1);
|
||||
#ifdef G4MULTITHREADED
|
||||
if(messenger && messenger->CommandsShouldBeInMaster() &&
|
||||
G4Threading::IsWorkerThread())
|
||||
@@ -101,6 +90,33 @@ void G4UIcommand::G4UIcommandCommonConstructorCode(const char* theCommandPath)
|
||||
#endif
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
void G4UIcommand::SetCommandType(CommandType typ)
|
||||
{
|
||||
if(messenger==nullptr)
|
||||
{ // this must be a directory
|
||||
if(typ != CmdDirectory)
|
||||
{
|
||||
G4ExceptionDescription ed;
|
||||
ed << "A UI command <" << commandPath
|
||||
<< "> is defined without vaild messenger.";
|
||||
G4Exception("G4UIcommand::SetCommandType","UI2031",
|
||||
FatalException,ed);
|
||||
}
|
||||
else if(commandPath.back() != '/')
|
||||
{
|
||||
G4ExceptionDescription ed;
|
||||
ed << "G4UIcommand Warning : \n"
|
||||
<< " <" << commandPath << "> must be a directory."
|
||||
<< " '/' is appended.";
|
||||
G4Exception("G4UIcommand::SetCommandType","UI2032",
|
||||
JustWarning,ed);
|
||||
commandPath += "/";
|
||||
}
|
||||
}
|
||||
commandType = typ;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4UIcommand::~G4UIcommand()
|
||||
{
|
||||
@@ -149,13 +165,13 @@ G4int G4UIcommand::DoIt(G4String parameterList)
|
||||
correctParameters.append(" ");
|
||||
}
|
||||
aToken = parameterToken();
|
||||
if(aToken.length() > 0 && aToken(0) == '"')
|
||||
if(aToken.length() > 0 && aToken[0] == '"')
|
||||
{
|
||||
while(aToken(aToken.length() - 1) != '"' ||
|
||||
(aToken.length() == 1 && aToken(0) == '"'))
|
||||
while(aToken.back() != '"' ||
|
||||
(aToken.length() == 1 && aToken[0] == '"'))
|
||||
{
|
||||
G4String additionalToken = parameterToken();
|
||||
if(additionalToken.isNull())
|
||||
if(additionalToken.empty())
|
||||
{
|
||||
return fParameterUnreadable + i_thParameter;
|
||||
}
|
||||
@@ -167,9 +183,9 @@ G4int G4UIcommand::DoIt(G4String parameterList)
|
||||
parameter[i_thParameter]->GetParameterType() == 's')
|
||||
{
|
||||
G4String anotherToken;
|
||||
while(!((anotherToken = parameterToken()).isNull()))
|
||||
while(!((anotherToken = parameterToken()).empty()))
|
||||
{
|
||||
G4int idxs = anotherToken.index("#");
|
||||
G4int idxs = anotherToken.find("#");
|
||||
if(idxs == G4int(std::string::npos))
|
||||
{
|
||||
aToken += " ";
|
||||
@@ -178,7 +194,7 @@ G4int G4UIcommand::DoIt(G4String parameterList)
|
||||
else if(idxs > 0)
|
||||
{
|
||||
aToken += " ";
|
||||
aToken += anotherToken(0, idxs);
|
||||
aToken += anotherToken.substr(0, idxs);
|
||||
break;
|
||||
}
|
||||
else
|
||||
@@ -188,7 +204,7 @@ G4int G4UIcommand::DoIt(G4String parameterList)
|
||||
}
|
||||
}
|
||||
|
||||
if(aToken.isNull() || aToken == "!")
|
||||
if(aToken.empty() || aToken == "!")
|
||||
{
|
||||
if(parameter[i_thParameter]->IsOmittable())
|
||||
{
|
||||
@@ -199,12 +215,12 @@ G4int G4UIcommand::DoIt(G4String parameterList)
|
||||
for(G4int ii = 0; ii < i_thParameter; ++ii)
|
||||
{
|
||||
parVal = cvSt();
|
||||
if(parVal(0) == '"')
|
||||
if(parVal[0] == '"')
|
||||
{
|
||||
while(parVal(parVal.length() - 1) != '"')
|
||||
while(parVal.back() != '"')
|
||||
{
|
||||
G4String additionalToken = cvSt();
|
||||
if(additionalToken.isNull())
|
||||
if(additionalToken.empty())
|
||||
{
|
||||
return fParameterUnreadable + i_thParameter;
|
||||
}
|
||||
@@ -214,19 +230,18 @@ G4int G4UIcommand::DoIt(G4String parameterList)
|
||||
}
|
||||
}
|
||||
G4String aCVToken = cvSt();
|
||||
if(aCVToken(0) == '"')
|
||||
if(aCVToken[0] == '"')
|
||||
{
|
||||
while(aCVToken(aCVToken.length() - 1) != '"')
|
||||
while(aCVToken.back() != '"')
|
||||
{
|
||||
G4String additionalToken = cvSt();
|
||||
if(additionalToken.isNull())
|
||||
if(additionalToken.empty())
|
||||
{
|
||||
return fParameterUnreadable + i_thParameter;
|
||||
}
|
||||
aCVToken += " ";
|
||||
aCVToken += additionalToken;
|
||||
}
|
||||
// aCVToken.strip(G4String::both,'"');
|
||||
}
|
||||
correctParameters.append(aCVToken);
|
||||
}
|
||||
@@ -396,7 +411,7 @@ void G4UIcommand::List()
|
||||
{
|
||||
G4cout << G4endl;
|
||||
G4cout << G4endl;
|
||||
if(commandPath(commandPath.length() - 1) != '/')
|
||||
if(commandPath.back() != '/')
|
||||
{
|
||||
G4cout << "Command " << commandPath << G4endl;
|
||||
}
|
||||
@@ -410,7 +425,7 @@ void G4UIcommand::List()
|
||||
{
|
||||
G4cout << commandGuidance[i_thGuidance] << G4endl;
|
||||
}
|
||||
if(!rangeString.isNull())
|
||||
if(!rangeString.empty())
|
||||
{
|
||||
G4cout << " Range of parameters : " << rangeString << G4endl;
|
||||
}
|
||||
@@ -529,8 +544,7 @@ G4String G4UIcommand::ConvertToString(G4ThreeVector vec, const char* unitName)
|
||||
// --------------------------------------------------------------------
|
||||
G4bool G4UIcommand::ConvertToBool(const char* st)
|
||||
{
|
||||
G4String v = st;
|
||||
v.toUpper();
|
||||
G4String v = G4StrUtil::to_upper_copy(st);
|
||||
G4bool vl = false;
|
||||
if(v == "Y" || v == "YES" || v == "1" || v == "T" || v == "TRUE")
|
||||
{
|
||||
@@ -612,7 +626,7 @@ G4int G4UIcommand::CheckNewValue(const char* newValue)
|
||||
{
|
||||
yystype result;
|
||||
// if( TypeCheck(newValue) == 0 ) return 1;
|
||||
if(!rangeString.isNull())
|
||||
if(!rangeString.empty())
|
||||
{
|
||||
if(RangeCheck(newValue) == 0)
|
||||
return fParameterOutOfRange;
|
||||
@@ -656,7 +670,7 @@ G4int G4UIcommand::TypeCheck(const char* t)
|
||||
case 'S':
|
||||
break;
|
||||
case 'B':
|
||||
aNewValue.toUpper();
|
||||
G4StrUtil::to_upper(aNewValue);
|
||||
if(aNewValue == "Y" || aNewValue == "N" || aNewValue == "YES" ||
|
||||
aNewValue == "NO" || aNewValue == "1" || aNewValue == "0" ||
|
||||
aNewValue == "T" || aNewValue == "F" || aNewValue == "TRUE" ||
|
||||
@@ -1503,7 +1517,7 @@ tokenNum G4UIcommand::Yylex() // reads input and returns token number, KR486
|
||||
{ // I or D
|
||||
do
|
||||
{
|
||||
buf += G4String((unsigned char) c);
|
||||
buf += (unsigned char)c;
|
||||
c = G4UIpGetc();
|
||||
} while(c == '.' || isdigit(c) || c == 'e' || c == 'E' || c == '+' ||
|
||||
c == '-');
|
||||
@@ -1530,7 +1544,7 @@ tokenNum G4UIcommand::Yylex() // reads input and returns token number, KR486
|
||||
{ // IDENTIFIER
|
||||
do
|
||||
{
|
||||
buf += G4String((unsigned char) c);
|
||||
buf += (unsigned char) c;
|
||||
} while((c = G4UIpGetc()) != EOF && (isalnum(c) || c == '_'));
|
||||
G4UIpUngetc(c);
|
||||
if(IsParameter(buf))
|
||||
@@ -1579,7 +1593,7 @@ G4int G4UIcommand::G4UIpGetc()
|
||||
{ // emulation of getc()
|
||||
G4int length = rangeString.length();
|
||||
if(bp < length)
|
||||
return rangeString(bp++);
|
||||
return rangeString[bp++];
|
||||
else
|
||||
return EOF;
|
||||
}
|
||||
@@ -1589,14 +1603,14 @@ G4int G4UIcommand::G4UIpUngetc(G4int c)
|
||||
{ // emulation of ungetc()
|
||||
if(c < 0)
|
||||
return -1;
|
||||
if(bp > 0 && c == rangeString(bp - 1))
|
||||
if(bp > 0 && c == rangeString[bp - 1])
|
||||
{
|
||||
--bp;
|
||||
}
|
||||
else
|
||||
{
|
||||
G4cerr << "G4UIpUngetc() failed." << G4endl;
|
||||
G4cerr << "bp=" << bp << " c=" << c << " pR(bp-1)=" << rangeString(bp - 1)
|
||||
G4cerr << "bp=" << bp << " c=" << c << " pR(bp-1)=" << rangeString[bp - 1]
|
||||
<< G4endl;
|
||||
paramERR = 1;
|
||||
return -1;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
@@ -26,10 +25,15 @@
|
||||
// G4UIcommandTree
|
||||
//
|
||||
// Author: Makoto Asai (SLAC), 1998
|
||||
// Midified: Makoto Asai (SLAC), 2021
|
||||
// Improve output HTML file layout and add option to sort
|
||||
// command/directory names in alphabetic order
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4UIcommandTree.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4StateManager.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include <fstream>
|
||||
#include "G4ios.hh"
|
||||
|
||||
@@ -73,43 +77,68 @@ void G4UIcommandTree::AddNewCommand(G4UIcommand* newCommand,
|
||||
{
|
||||
G4String commandPath = newCommand->GetCommandPath();
|
||||
G4String remainingPath = commandPath;
|
||||
remainingPath.remove(0, pathName.length());
|
||||
if(remainingPath.isNull())
|
||||
remainingPath.erase(0, pathName.length());
|
||||
if(remainingPath.empty())
|
||||
{
|
||||
if(!guidance)
|
||||
{
|
||||
guidance = newCommand;
|
||||
if(!(newCommand->ToBeBroadcasted()))
|
||||
broadcastCommands = false;
|
||||
{ broadcastCommands = false; }
|
||||
if(workerThreadOnly)
|
||||
newCommand->SetWorkerThreadOnly();
|
||||
{ newCommand->SetWorkerThreadOnly(); }
|
||||
}
|
||||
return;
|
||||
}
|
||||
G4int i = remainingPath.first('/');
|
||||
|
||||
if(guidance)
|
||||
{
|
||||
G4UIdirectory* dir = static_cast<G4UIdirectory*>(guidance);
|
||||
ifSort = dir->IfSort();
|
||||
}
|
||||
G4int i = remainingPath.find('/');
|
||||
if(i == G4int(std::string::npos))
|
||||
{
|
||||
// Find command
|
||||
// Adding a new command to this directory
|
||||
G4int n_commandEntry = command.size();
|
||||
for(G4int i_thCommand = 0; i_thCommand < n_commandEntry; ++i_thCommand)
|
||||
{
|
||||
if(remainingPath == command[i_thCommand]->GetCommandName())
|
||||
{
|
||||
// a command of same name has already defined. do nothing and return.
|
||||
if(G4UImanager::GetUIpointer()->GetVerboseLevel() > 8)
|
||||
{
|
||||
G4ExceptionDescription ed;
|
||||
ed << "Command <" << commandPath << "> already exist. New command is not added.";
|
||||
G4Exception("G4UIcommandTree::AddNewCommand","UI_ComTree_001",
|
||||
//FatalException,
|
||||
JustWarning,
|
||||
ed);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(!broadcastCommands)
|
||||
newCommand->SetToBeBroadcasted(false);
|
||||
{ newCommand->SetToBeBroadcasted(false); }
|
||||
if(workerThreadOnly)
|
||||
newCommand->SetWorkerThreadOnly();
|
||||
command.push_back(newCommand);
|
||||
{ newCommand->SetWorkerThreadOnly(); }
|
||||
if(ifSort)
|
||||
{
|
||||
auto j = command.begin();
|
||||
for(; j != command.end(); ++j) {
|
||||
if (newCommand->GetCommandPath() < (*j)->GetCommandPath()) { break; }
|
||||
}
|
||||
command.insert(j,newCommand);
|
||||
}
|
||||
else
|
||||
{ command.push_back(newCommand); }
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Find path
|
||||
// Adding a new command to a sub-directory
|
||||
G4String nextPath = pathName;
|
||||
nextPath.append(remainingPath(0, i + 1));
|
||||
nextPath.append(remainingPath.substr(0, i + 1));
|
||||
G4int n_treeEntry = tree.size();
|
||||
for(G4int i_thTree = 0; i_thTree < n_treeEntry; ++i_thTree)
|
||||
{
|
||||
@@ -121,10 +150,23 @@ void G4UIcommandTree::AddNewCommand(G4UIcommand* newCommand,
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Creating a new sub-directory
|
||||
G4UIcommandTree* newTree = new G4UIcommandTree(nextPath);
|
||||
tree.push_back(newTree);
|
||||
if(ifSort)
|
||||
{
|
||||
auto j = tree.begin();
|
||||
for(; j != tree.end(); ++j) {
|
||||
if (newTree->GetPathName() < (*j)->GetPathName()) { break; }
|
||||
}
|
||||
tree.insert(j,newTree);
|
||||
}
|
||||
else
|
||||
{ tree.push_back(newTree); }
|
||||
if(!broadcastCommands)
|
||||
newCommand->SetToBeBroadcasted(false);
|
||||
{ newCommand->SetToBeBroadcasted(false); }
|
||||
// In case a new sub-directry is created with a new G4UIdirectory
|
||||
// (most-likely this is the case), inherit the sort flag
|
||||
newCommand->SetDefaultSortFlag(ifSort);
|
||||
newTree->AddNewCommand(newCommand, workerThreadOnly);
|
||||
return;
|
||||
}
|
||||
@@ -138,14 +180,14 @@ void G4UIcommandTree::RemoveCommand(G4UIcommand* aCommand,
|
||||
return;
|
||||
G4String commandPath = aCommand->GetCommandPath();
|
||||
G4String remainingPath = commandPath;
|
||||
remainingPath.remove(0, pathName.length());
|
||||
if(remainingPath.isNull())
|
||||
remainingPath.erase(0, pathName.length());
|
||||
if(remainingPath.empty())
|
||||
{
|
||||
guidance = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
G4int i = remainingPath.first('/');
|
||||
G4int i = remainingPath.find('/');
|
||||
if(i == G4int(std::string::npos))
|
||||
{
|
||||
// Find command
|
||||
@@ -163,7 +205,7 @@ void G4UIcommandTree::RemoveCommand(G4UIcommand* aCommand,
|
||||
{
|
||||
// Find path
|
||||
G4String nextPath = pathName;
|
||||
nextPath.append(remainingPath(0, i + 1));
|
||||
nextPath.append(remainingPath.substr(0, i + 1));
|
||||
G4int n_treeEntry = tree.size();
|
||||
for(G4int i_thTree = 0; i_thTree < n_treeEntry; ++i_thTree)
|
||||
{
|
||||
@@ -191,12 +233,12 @@ G4UIcommand* G4UIcommandTree::FindPath(const char* commandPath) const
|
||||
// This function tries to match a command name
|
||||
|
||||
G4String remainingPath = commandPath;
|
||||
if(remainingPath.index(pathName) == std::string::npos)
|
||||
if(remainingPath.find(pathName) == std::string::npos)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
remainingPath.remove(0, pathName.length());
|
||||
G4int i = remainingPath.first('/');
|
||||
remainingPath.erase(0, pathName.length());
|
||||
G4int i = remainingPath.find('/');
|
||||
if(i == G4int(std::string::npos))
|
||||
{
|
||||
// Find command
|
||||
@@ -213,7 +255,7 @@ G4UIcommand* G4UIcommandTree::FindPath(const char* commandPath) const
|
||||
{
|
||||
// Find path
|
||||
G4String nextPath = pathName;
|
||||
nextPath.append(remainingPath(0, i + 1));
|
||||
nextPath.append(remainingPath.substr(0, i + 1));
|
||||
G4int n_treeEntry = tree.size();
|
||||
for(G4int i_thTree = 0; i_thTree < n_treeEntry; ++i_thTree)
|
||||
{
|
||||
@@ -234,17 +276,17 @@ G4UIcommandTree* G4UIcommandTree::FindCommandTree(const char* commandPath)
|
||||
// @return the commandTree found or nullptr if not
|
||||
|
||||
G4String remainingPath = commandPath;
|
||||
if(remainingPath.index(pathName) == std::string::npos)
|
||||
if(remainingPath.find(pathName) == std::string::npos)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
remainingPath.remove(0, pathName.length());
|
||||
G4int i = remainingPath.first('/');
|
||||
remainingPath.erase(0, pathName.length());
|
||||
G4int i = remainingPath.find('/');
|
||||
if(i != G4int(std::string::npos))
|
||||
{
|
||||
// Find path
|
||||
G4String nextPath = pathName;
|
||||
nextPath.append(remainingPath(0, i + 1));
|
||||
nextPath.append(remainingPath.substr(0, i + 1));
|
||||
G4int n_treeEntry = tree.size();
|
||||
for(G4int i_thTree = 0; i_thTree < n_treeEntry; ++i_thTree)
|
||||
{
|
||||
@@ -274,9 +316,9 @@ G4String G4UIcommandTree::CompleteCommandPath(const G4String& aCommandPath)
|
||||
G4String matchingPath = empty;
|
||||
|
||||
// find the tree
|
||||
G4int jpre = pName.last('/');
|
||||
if(jpre != G4int(G4String::npos))
|
||||
pName.remove(jpre + 1);
|
||||
auto jpre = pName.rfind('/');
|
||||
if(jpre != G4String::npos)
|
||||
pName.erase(jpre + 1);
|
||||
G4UIcommandTree* aTree = FindCommandTree(pName);
|
||||
|
||||
if(!aTree)
|
||||
@@ -284,7 +326,7 @@ G4String G4UIcommandTree::CompleteCommandPath(const G4String& aCommandPath)
|
||||
return empty;
|
||||
}
|
||||
|
||||
if(pName.index(pName) == std::string::npos)
|
||||
if(pName.find(pName) == std::string::npos)
|
||||
return empty;
|
||||
|
||||
std::vector<G4String> paths;
|
||||
@@ -301,7 +343,7 @@ G4String G4UIcommandTree::CompleteCommandPath(const G4String& aCommandPath)
|
||||
{
|
||||
G4String fpdir = aTree->GetTree(idir)->GetPathName();
|
||||
// matching test
|
||||
if(fpdir.index(remainingPath, 0) == 0)
|
||||
if(fpdir.find(remainingPath, 0) == 0)
|
||||
{
|
||||
if(nMatch == 0)
|
||||
{
|
||||
@@ -333,7 +375,7 @@ G4String G4UIcommandTree::CompleteCommandPath(const G4String& aCommandPath)
|
||||
G4String fpcmd =
|
||||
aTree->GetPathName() + aTree->GetCommand(icmd)->GetCommandName();
|
||||
// matching test
|
||||
if(fpcmd.index(remainingPath, 0) == 0)
|
||||
if(fpcmd.find(remainingPath, 0) == 0)
|
||||
{
|
||||
if(nMatch == 0)
|
||||
{
|
||||
@@ -472,9 +514,9 @@ G4String G4UIcommandTree::CreateFileName(const char* pName)
|
||||
{
|
||||
G4String fn = pName;
|
||||
G4int idxs;
|
||||
while((idxs = fn.index("/")) != G4int(std::string::npos))
|
||||
while((idxs = fn.find("/")) != G4int(std::string::npos))
|
||||
{
|
||||
fn(idxs) = '_';
|
||||
fn[idxs] = '_';
|
||||
}
|
||||
fn += ".html";
|
||||
return fn;
|
||||
@@ -487,7 +529,7 @@ G4String G4UIcommandTree::ModStr(const char* strS)
|
||||
G4String str = strS;
|
||||
for(G4int i = 0; i < G4int(str.length()); ++i)
|
||||
{
|
||||
char c = str(i);
|
||||
char c = str[i];
|
||||
switch(c)
|
||||
{
|
||||
case '<':
|
||||
@@ -507,15 +549,91 @@ G4String G4UIcommandTree::ModStr(const char* strS)
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
void G4UIcommandTree::CreateHTML()
|
||||
void G4UIcommandTree::CreateHTML(G4String sideBar)
|
||||
{
|
||||
G4String ofileName = CreateFileName(pathName);
|
||||
std::ofstream oF(ofileName, std::ios::out);
|
||||
|
||||
oF << "<html><head><title>Commands in " << ModStr(pathName)
|
||||
<< "</title></head>" << G4endl;
|
||||
oF << "<body bgcolor=\"#ffffff\"><h2>" << ModStr(pathName) << "</h2><p>"
|
||||
<< G4endl;
|
||||
oF << "<style> \
|
||||
table,table td,table th { \
|
||||
border:1px solid #eee \
|
||||
} \
|
||||
table td,table th { \
|
||||
padding:5px 20px; \
|
||||
line-height:1.3; \
|
||||
text-align:inherit \
|
||||
} \
|
||||
a { \
|
||||
color:#17a81a; \
|
||||
text-decoration:none; \
|
||||
transition-duration:0.3s \
|
||||
} \
|
||||
a:hover { \
|
||||
color:#17a81a \
|
||||
} \
|
||||
table { \
|
||||
border-collapse:collapse; \
|
||||
border-spacing:0; \
|
||||
margin-bottom:5px; \
|
||||
} \
|
||||
h1 { \
|
||||
font-size:2.25em; \
|
||||
font-weight:300; \
|
||||
letter-spacing:-1px; \
|
||||
line-height:1.15em; \
|
||||
margin-bottom:0.5em; \
|
||||
word-wrap:break-word \
|
||||
} \
|
||||
h2 { \
|
||||
font-size:1.5em; \
|
||||
font-weight:300; \
|
||||
letter-spacing:-1px; \
|
||||
line-height:1.15em; \
|
||||
margin-bottom:0.5em; \
|
||||
word-wrap:break-word \
|
||||
} \
|
||||
h3 { \
|
||||
color:#26282a; \
|
||||
font-weight:300; \
|
||||
font-size:1.3em; \
|
||||
padding:15px 0 15px 0; \
|
||||
border-bottom:2px #eee solid; \
|
||||
word-wrap:break-word \
|
||||
} \
|
||||
.sidebar { \
|
||||
display:block; \
|
||||
position:relative; \
|
||||
position:sticky; \
|
||||
float:left; \
|
||||
-webkit-box-sizing:border-box; \
|
||||
-moz-box-sizing:border-box; \
|
||||
-ms-box-sizing:border-box; \
|
||||
box-sizing:border-box; \
|
||||
width:20%; \
|
||||
padding-right:20px \
|
||||
} \
|
||||
.context { \
|
||||
width:80%; \
|
||||
display:inline-block; \
|
||||
background-color:#fff; \
|
||||
padding: 25px 35px 20px 30px; \
|
||||
-webkit-box-sizing:border-box; \
|
||||
-moz-box-sizing:border-box; \
|
||||
-ms-box-sizing:border-box; \
|
||||
box-sizing:border-box \
|
||||
} \
|
||||
</style>"<< G4endl;
|
||||
oF << "<body bgcolor=\"#ffffff\">" << G4endl;
|
||||
|
||||
// Left Panel
|
||||
if (createHTMLTreeLevel == 0 ) {
|
||||
oF << "<div class=\"sidebar\">" << sideBar << "</div>" << G4endl;
|
||||
}
|
||||
// Right Panel
|
||||
oF << "<div class=\"context\">";
|
||||
oF << "<h1>" << ModStr(pathName) << "</h1>" << G4endl;
|
||||
|
||||
if(guidance != nullptr)
|
||||
{
|
||||
@@ -524,100 +642,127 @@ void G4UIcommandTree::CreateHTML()
|
||||
oF << ModStr(guidance->GetGuidanceLine(i)) << "<br>" << G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
oF << "<p><hr><p>" << G4endl;
|
||||
|
||||
oF << "<h2>Sub-directories : </h2><dl>" << G4endl;
|
||||
for(std::size_t i_thTree = 0; i_thTree < tree.size(); ++i_thTree)
|
||||
{
|
||||
oF << "<p><br><p><dt><a href=\""
|
||||
<< CreateFileName(tree[i_thTree]->GetPathName()) << "\">"
|
||||
<< ModStr(tree[i_thTree]->GetPathName()) << "</a>" << G4endl;
|
||||
oF << "<p><dd>" << ModStr(tree[i_thTree]->GetTitle()) << G4endl;
|
||||
tree[i_thTree]->CreateHTML();
|
||||
if (tree.size() >0 ){
|
||||
G4String menu = "";
|
||||
G4String newSideBar = "";
|
||||
menu += "<h2>Sub-directories </h2><table>";
|
||||
newSideBar += "<h2><a href=\"" + ofileName + "\">Top level </a></h2><table>";
|
||||
// Build menu short version
|
||||
for(std::size_t i_thTree = 0; i_thTree < tree.size(); ++i_thTree)
|
||||
{
|
||||
newSideBar += "<tr><td><a href=\""
|
||||
+ CreateFileName(tree[i_thTree]->GetPathName()) + "\">"
|
||||
+ ModStr(tree[i_thTree]->GetPathName()) + "</a>";
|
||||
}
|
||||
// Build menu
|
||||
for(std::size_t i_thTree = 0; i_thTree < tree.size(); ++i_thTree)
|
||||
{
|
||||
menu += "<tr><td><a href=\""
|
||||
+ CreateFileName(tree[i_thTree]->GetPathName()) + "\">"
|
||||
+ ModStr(tree[i_thTree]->GetPathName()) + "</a>";
|
||||
menu += "</td><td>" + ModStr(tree[i_thTree]->GetTitle()) + "</tr>";
|
||||
}
|
||||
menu += "</table>";
|
||||
newSideBar += "</table>";
|
||||
for(std::size_t i_thTree = 0; i_thTree < tree.size(); ++i_thTree)
|
||||
{
|
||||
createHTMLTreeLevel ++;
|
||||
tree[i_thTree]->CreateHTML(newSideBar);
|
||||
createHTMLTreeLevel --;
|
||||
}
|
||||
oF << menu << G4endl;
|
||||
}
|
||||
|
||||
oF << "</dl><p><hr><p>" << G4endl;
|
||||
|
||||
oF << "<h2>Commands : </h2><dl>" << G4endl;
|
||||
for(std::size_t i_thCommand = 0; i_thCommand < command.size(); ++i_thCommand)
|
||||
{
|
||||
G4UIcommand* cmd = command[i_thCommand];
|
||||
oF << "<p><br><p><dt><b>" << ModStr(cmd->GetCommandName());
|
||||
if(cmd->GetParameterEntries() > 0)
|
||||
if (command.size() >0 ){
|
||||
oF << "<h2>Commands </h2>" << G4endl;
|
||||
|
||||
// resume
|
||||
oF << "<table>" << G4endl;
|
||||
for(std::size_t i_thCommand = 0; i_thCommand < command.size(); ++i_thCommand)
|
||||
{
|
||||
for(std::size_t i_thParam = 0; i_thParam < cmd->GetParameterEntries();
|
||||
++i_thParam)
|
||||
G4UIcommand* cmd = command[i_thCommand];
|
||||
oF << "<tr><td><a href=\"#c"<< i_thCommand << "\">"<< ModStr(cmd->GetCommandName());
|
||||
oF << "</a></td></tr>" << G4endl;
|
||||
}
|
||||
oF << "</table>" << G4endl;
|
||||
for(std::size_t i_thCommand = 0; i_thCommand < command.size(); ++i_thCommand)
|
||||
{
|
||||
G4UIcommand* cmd = command[i_thCommand];
|
||||
oF << "<h3 id=\"c" << i_thCommand << "\">" << ModStr(cmd->GetCommandName());
|
||||
if(cmd->GetParameterEntries() > 0)
|
||||
{
|
||||
oF << " [<i>"
|
||||
<< ModStr(cmd->GetParameter(i_thParam)->GetParameterName())
|
||||
<< "</i>]";
|
||||
}
|
||||
}
|
||||
oF << "</b>" << G4endl;
|
||||
oF << "<p><dd>" << G4endl;
|
||||
for(std::size_t i = 0; i < cmd->GetGuidanceEntries(); ++i)
|
||||
{
|
||||
oF << ModStr(cmd->GetGuidanceLine(i)) << "<br>" << G4endl;
|
||||
}
|
||||
if(!(cmd->GetRange()).isNull())
|
||||
{
|
||||
oF << "<p><dd>Range : " << ModStr(cmd->GetRange()) << G4endl;
|
||||
}
|
||||
std::vector<G4ApplicationState>* availabelStateList = cmd->GetStateList();
|
||||
if(availabelStateList->size() == 6)
|
||||
{
|
||||
oF << "<p><dd>Available at all Geant4 states." << G4endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
oF << "<p><dd>Available Geant4 state(s) : ";
|
||||
for(std::size_t ias = 0; ias < availabelStateList->size(); ++ias)
|
||||
{
|
||||
oF << G4StateManager::GetStateManager()->GetStateString(
|
||||
(*availabelStateList)[ias])
|
||||
<< " " << G4endl;
|
||||
}
|
||||
}
|
||||
if(cmd->GetParameterEntries() > 0)
|
||||
{
|
||||
oF << "<p><dd>Parameters<table border=1>" << G4endl;
|
||||
for(std::size_t i_thParam = 0; i_thParam < cmd->GetParameterEntries();
|
||||
++i_thParam)
|
||||
{
|
||||
G4UIparameter* prm = cmd->GetParameter(i_thParam);
|
||||
oF << "<tr><td>" << ModStr(prm->GetParameterName()) << G4endl;
|
||||
oF << "<td>type " << prm->GetParameterType() << G4endl;
|
||||
oF << "<td>";
|
||||
if(prm->IsOmittable())
|
||||
for(std::size_t i_thParam = 0; i_thParam < cmd->GetParameterEntries();
|
||||
++i_thParam)
|
||||
{
|
||||
oF << "Omittable : ";
|
||||
if(prm->GetCurrentAsDefault())
|
||||
oF << " [<i>"
|
||||
<< ModStr(cmd->GetParameter(i_thParam)->GetParameterName())
|
||||
<< "</i>]";
|
||||
}
|
||||
}
|
||||
oF << "</h3>" << G4endl;
|
||||
oF << "<p>" << G4endl;
|
||||
for(std::size_t i = 0; i < cmd->GetGuidanceEntries(); ++i)
|
||||
{
|
||||
oF << ModStr(cmd->GetGuidanceLine(i)) << "<br>" << G4endl;
|
||||
}
|
||||
if(!(cmd->GetRange()).empty())
|
||||
{
|
||||
oF << "<p>Range : " << ModStr(cmd->GetRange()) << G4endl;
|
||||
}
|
||||
std::vector<G4ApplicationState>* availabelStateList = cmd->GetStateList();
|
||||
if(availabelStateList->size() == 6)
|
||||
{
|
||||
oF << "<p>Available at all Geant4 states." << G4endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
oF << "<p>Available Geant4 state(s) : ";
|
||||
for(std::size_t ias = 0; ias < availabelStateList->size(); ++ias)
|
||||
{
|
||||
oF << G4StateManager::GetStateManager()->GetStateString(
|
||||
(*availabelStateList)[ias])
|
||||
<< " " << G4endl;
|
||||
}
|
||||
}
|
||||
if(cmd->GetParameterEntries() > 0)
|
||||
{
|
||||
oF << "<p>Parameters<table border=1>" << G4endl;
|
||||
for(std::size_t i_thParam = 0; i_thParam < cmd->GetParameterEntries();
|
||||
++i_thParam)
|
||||
{
|
||||
G4UIparameter* prm = cmd->GetParameter(i_thParam);
|
||||
oF << "<tr><td>" << ModStr(prm->GetParameterName()) << G4endl;
|
||||
oF << "<td>type " << prm->GetParameterType() << G4endl;
|
||||
oF << "<td>";
|
||||
if(prm->IsOmittable())
|
||||
{
|
||||
oF << "current value is used as the default value." << G4endl;
|
||||
oF << "Omittable : ";
|
||||
if(prm->GetCurrentAsDefault())
|
||||
{
|
||||
oF << "current value is used as the default value." << G4endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
oF << "default value = " << prm->GetDefaultValue() << G4endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
oF << "<td>";
|
||||
if(!(prm->GetParameterRange()).empty())
|
||||
{
|
||||
oF << "default value = " << prm->GetDefaultValue() << G4endl;
|
||||
oF << "Parameter range : " << ModStr(prm->GetParameterRange())
|
||||
<< G4endl;
|
||||
}
|
||||
else if(!(prm->GetParameterCandidates()).empty())
|
||||
{
|
||||
oF << "Parameter candidates : "
|
||||
<< ModStr(prm->GetParameterCandidates()) << G4endl;
|
||||
}
|
||||
}
|
||||
oF << "<td>";
|
||||
if(!(prm->GetParameterRange()).isNull())
|
||||
{
|
||||
oF << "Parameter range : " << ModStr(prm->GetParameterRange())
|
||||
<< G4endl;
|
||||
}
|
||||
else if(!(prm->GetParameterCandidates()).isNull())
|
||||
{
|
||||
oF << "Parameter candidates : "
|
||||
<< ModStr(prm->GetParameterCandidates()) << G4endl;
|
||||
}
|
||||
oF << "</table>" << G4endl;
|
||||
}
|
||||
oF << "</table>" << G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
oF << "</dl></body></html>" << G4endl;
|
||||
oF << "</div></body></html>" << G4endl;
|
||||
oF.close();
|
||||
}
|
||||
|
||||
|
||||
@@ -132,10 +132,12 @@ G4UIcontrolMessenger::G4UIcontrolMessenger()
|
||||
historyCommand->SetGuidance("Defaul file name is G4history.macro.");
|
||||
historyCommand->SetParameterName("fileName", true);
|
||||
historyCommand->SetDefaultValue("G4History.macro");
|
||||
historyCommand->SetToBeBroadcasted(false);
|
||||
|
||||
stopStoreHistoryCommand =
|
||||
new G4UIcmdWithoutParameter("/control/stopSavingHistory", this);
|
||||
stopStoreHistoryCommand->SetGuidance("Stop saving history file.");
|
||||
stopStoreHistoryCommand->SetToBeBroadcasted(false);
|
||||
|
||||
aliasCommand = new G4UIcommand("/control/alias", this);
|
||||
aliasCommand->SetGuidance("Set an alias.");
|
||||
@@ -160,6 +162,7 @@ G4UIcontrolMessenger::G4UIcontrolMessenger()
|
||||
getEnvCmd = new G4UIcmdWithAString("/control/getEnv", this);
|
||||
getEnvCmd->SetGuidance(
|
||||
"Get a shell environment variable and define it as an alias.");
|
||||
getEnvCmd->SetToBeBroadcasted(false);
|
||||
|
||||
getValCmd = new G4UIcommand("/control/getVal", this);
|
||||
getValCmd->SetGuidance(
|
||||
@@ -174,12 +177,15 @@ G4UIcontrolMessenger::G4UIcontrolMessenger()
|
||||
G4UIparameter* iIdxParam = new G4UIparameter("iIdx", 'i', true);
|
||||
iIdxParam->SetDefaultValue(0);
|
||||
getValCmd->SetParameter(iIdxParam);
|
||||
getValCmd->SetToBeBroadcasted(false);
|
||||
|
||||
echoCmd = new G4UIcmdWithAString("/control/echo", this);
|
||||
echoCmd->SetGuidance("Display the aliased value.");
|
||||
echoCmd->SetGuidance("Display the valuerameter string.");
|
||||
echoCmd->SetGuidance("If alias is contained, it is converted to the aliased value.");
|
||||
|
||||
shellCommand = new G4UIcmdWithAString("/control/shell", this);
|
||||
shellCommand->SetGuidance("Execute a (Unix) SHELL command.");
|
||||
shellCommand->SetToBeBroadcasted(false);
|
||||
|
||||
ManualCommand = new G4UIcmdWithAString("/control/manual", this);
|
||||
ManualCommand->SetGuidance("Display all of sub-directories and commands.");
|
||||
@@ -485,11 +491,11 @@ void G4UIcontrolMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
|
||||
G4String aliName = next();
|
||||
G4String com = next();
|
||||
G4String curVal = UI->GetCurrentValues(com);
|
||||
if(!(curVal.isNull()))
|
||||
if(!(curVal.empty()))
|
||||
{
|
||||
G4String theValue = curVal;
|
||||
G4String iIdx = next();
|
||||
if(!(iIdx.isNull()))
|
||||
if(!(iIdx.empty()))
|
||||
{
|
||||
G4int idx = StoI(iIdx);
|
||||
G4Tokenizer nextVal(curVal);
|
||||
@@ -581,21 +587,21 @@ void G4UIcontrolMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
|
||||
|
||||
G4String c1 = next();
|
||||
G4String ca;
|
||||
while(!((ca = next()).isNull()))
|
||||
while(!((ca = next()).empty()))
|
||||
{
|
||||
c1 += " ";
|
||||
c1 += ca;
|
||||
}
|
||||
if(c1(0) == '"')
|
||||
if(c1[0] == '"')
|
||||
{
|
||||
G4String strippedValue;
|
||||
if(c1(c1.length() - 1) == '"')
|
||||
if(c1.back() == '"')
|
||||
{
|
||||
strippedValue = c1(1, c1.length() - 2);
|
||||
strippedValue = c1.substr(1, c1.length() - 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
strippedValue = c1(1, c1.length() - 1);
|
||||
strippedValue = c1.substr(1, c1.length() - 1);
|
||||
}
|
||||
c1 = strippedValue;
|
||||
}
|
||||
@@ -704,21 +710,21 @@ void G4UIcontrolMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
|
||||
|
||||
G4String c1 = next();
|
||||
G4String ca;
|
||||
while(!((ca = next()).isNull()))
|
||||
while(!((ca = next()).empty()))
|
||||
{
|
||||
c1 += " ";
|
||||
c1 += ca;
|
||||
}
|
||||
if(c1(0) == '"')
|
||||
if(c1[0] == '"')
|
||||
{
|
||||
G4String strippedValue;
|
||||
if(c1(c1.length() - 1) == '"')
|
||||
if(c1.back() == '"')
|
||||
{
|
||||
strippedValue = c1(1, c1.length() - 2);
|
||||
strippedValue = c1.substr(1, c1.length() - 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
strippedValue = c1(1, c1.length() - 1);
|
||||
strippedValue = c1.substr(1, c1.length() - 1);
|
||||
}
|
||||
c1 = strippedValue;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ G4UIdirectory::G4UIdirectory(char* theCommandPath,
|
||||
G4bool commandsToBeBroadcasted)
|
||||
: G4UIcommand(theCommandPath, nullptr, commandsToBeBroadcasted)
|
||||
{
|
||||
SetCommandType(CmdDirectory);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -42,4 +43,5 @@ G4UIdirectory::G4UIdirectory(const char* theCommandPath,
|
||||
G4bool commandsToBeBroadcasted)
|
||||
: G4UIcommand(theCommandPath, nullptr, commandsToBeBroadcasted)
|
||||
{
|
||||
SetCommandType(CmdDirectory);
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ G4String G4UImanager::GetCurrentStringValue(const char* aCommand,
|
||||
for(G4int i_thParameter = 0; i_thParameter < parameterNumber; ++i_thParameter)
|
||||
{
|
||||
token = savedToken();
|
||||
if(token.isNull())
|
||||
if(token.empty())
|
||||
return G4String();
|
||||
if(token[(size_t) 0] == '"')
|
||||
{
|
||||
@@ -370,23 +370,23 @@ void G4UImanager::ForeachS(const char* valueList)
|
||||
G4String vn = parameterToken();
|
||||
G4String c1 = parameterToken();
|
||||
G4String ca;
|
||||
while(!((ca = parameterToken()).isNull()))
|
||||
while(!((ca = parameterToken()).empty()))
|
||||
{
|
||||
c1 += " ";
|
||||
c1 += ca;
|
||||
}
|
||||
|
||||
G4String aliasValue = c1;
|
||||
if(aliasValue(0) == '"')
|
||||
if(aliasValue[0] == '"')
|
||||
{
|
||||
G4String strippedValue;
|
||||
if(aliasValue(aliasValue.length() - 1) == '"')
|
||||
if(aliasValue.back() == '"')
|
||||
{
|
||||
strippedValue = aliasValue(1, aliasValue.length() - 2);
|
||||
strippedValue = aliasValue.substr(1, aliasValue.length() - 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
strippedValue = aliasValue(1, aliasValue.length() - 1);
|
||||
strippedValue = aliasValue.substr(1, aliasValue.length() - 1);
|
||||
}
|
||||
aliasValue = strippedValue;
|
||||
}
|
||||
@@ -402,7 +402,7 @@ void G4UImanager::Foreach(const char* macroFile, const char* variableName,
|
||||
G4String candidatesString = candidates;
|
||||
G4Tokenizer parameterToken(candidatesString);
|
||||
G4String cd;
|
||||
while(!((cd = parameterToken()).isNull()))
|
||||
while(!((cd = parameterToken()).empty()))
|
||||
{
|
||||
G4String vl = variableName;
|
||||
vl += " ";
|
||||
@@ -424,15 +424,15 @@ void G4UImanager::Foreach(const char* macroFile, const char* variableName,
|
||||
G4String G4UImanager::SolveAlias(const char* aCmd)
|
||||
{
|
||||
G4String aCommand = aCmd;
|
||||
G4int ia = aCommand.index("{");
|
||||
G4int iz = aCommand.index("#");
|
||||
G4int ia = aCommand.find("{");
|
||||
G4int iz = aCommand.find("#");
|
||||
while((ia != G4int(std::string::npos)) &&
|
||||
((iz == G4int(std::string::npos)) || (ia < iz)))
|
||||
{
|
||||
G4int ibx = -1;
|
||||
while(ibx < 0)
|
||||
{
|
||||
G4int ib = aCommand.index("}");
|
||||
G4int ib = aCommand.find("}");
|
||||
if(ib == G4int(std::string::npos))
|
||||
{
|
||||
G4cerr << aCommand << G4endl;
|
||||
@@ -443,9 +443,9 @@ G4String G4UImanager::SolveAlias(const char* aCmd)
|
||||
G4String nullStr;
|
||||
return nullStr;
|
||||
}
|
||||
G4String ps = aCommand(ia + 1, aCommand.length() - (ia + 1));
|
||||
G4int ic = ps.index("{");
|
||||
G4int id = ps.index("}");
|
||||
G4String ps = aCommand.substr(ia + 1, aCommand.length() - (ia + 1));
|
||||
G4int ic = ps.find("{");
|
||||
G4int id = ps.find("}");
|
||||
if(ic != G4int(std::string::npos) && ic < id)
|
||||
{
|
||||
ia += ic + 1;
|
||||
@@ -459,9 +459,9 @@ G4String G4UImanager::SolveAlias(const char* aCmd)
|
||||
//--- and ibx represents corresponding "}"
|
||||
G4String subs;
|
||||
if(ia > 0)
|
||||
subs = aCommand(0, ia);
|
||||
G4String alis = aCommand(ia + 1, ibx - ia - 1);
|
||||
G4String rems = aCommand(ibx + 1, aCommand.length() - ibx);
|
||||
subs = aCommand.substr(0, ia);
|
||||
G4String alis = aCommand.substr(ia + 1, ibx - ia - 1);
|
||||
G4String rems = aCommand.substr(ibx + 1, aCommand.length() - ibx);
|
||||
G4String* alVal = aliasList->FindAlias(alis);
|
||||
if(!alVal)
|
||||
{
|
||||
@@ -470,7 +470,7 @@ G4String G4UImanager::SolveAlias(const char* aCmd)
|
||||
return nullStr;
|
||||
}
|
||||
aCommand = subs + (*alVal) + rems;
|
||||
ia = aCommand.index("{");
|
||||
ia = aCommand.find("{");
|
||||
}
|
||||
return aCommand;
|
||||
}
|
||||
@@ -485,7 +485,7 @@ G4int G4UImanager::ApplyCommand(const G4String& aCmd)
|
||||
G4int G4UImanager::ApplyCommand(const char* aCmd)
|
||||
{
|
||||
G4String aCommand = SolveAlias(aCmd);
|
||||
if(aCommand.isNull())
|
||||
if(aCommand.empty())
|
||||
return fAliasNotFound;
|
||||
if(verboseLevel) {
|
||||
if (isMaster) fLastCommandOutputTreated = false;
|
||||
@@ -494,11 +494,11 @@ G4int G4UImanager::ApplyCommand(const char* aCmd)
|
||||
G4String commandString;
|
||||
G4String commandParameter;
|
||||
|
||||
std::size_t i = aCommand.index(" ");
|
||||
std::size_t i = aCommand.find(" ");
|
||||
if(i != std::string::npos)
|
||||
{
|
||||
commandString = aCommand(0, i);
|
||||
commandParameter = aCommand(i + 1, aCommand.length() - (i + 1));
|
||||
commandString = aCommand.substr(0, i);
|
||||
commandParameter = aCommand.substr(i + 1, aCommand.length() - (i + 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -512,16 +512,17 @@ G4int G4UImanager::ApplyCommand(const char* aCmd)
|
||||
G4String a2;
|
||||
while(ll < len - 1)
|
||||
{
|
||||
if(commandString(ll, 2) == "//")
|
||||
if(commandString.substr(ll, 2) == "//")
|
||||
{
|
||||
if(ll == 0)
|
||||
{
|
||||
commandString.remove(ll, 1);
|
||||
// Safe because index argument always 0
|
||||
commandString.erase(ll, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
a1 = commandString(0, ll);
|
||||
a2 = commandString(ll + 1, len - ll - 1);
|
||||
a1 = commandString.substr(0, ll);
|
||||
a2 = commandString.substr(ll + 1, len - ll - 1);
|
||||
commandString = a1 + a2;
|
||||
}
|
||||
--len;
|
||||
@@ -537,7 +538,7 @@ G4int G4UImanager::ApplyCommand(const char* aCmd)
|
||||
for(auto itr = bridges->cbegin(); itr != bridges->cend(); ++itr)
|
||||
{
|
||||
G4int leng = (*itr)->DirLength();
|
||||
if(commandString(0, leng) == (*itr)->DirName())
|
||||
if(commandString.substr(0, leng) == (*itr)->DirName())
|
||||
{
|
||||
return (*itr)->LocalUI()->ApplyCommand(commandString + " " +
|
||||
commandParameter);
|
||||
@@ -597,6 +598,31 @@ G4int G4UImanager::ApplyCommand(const char* aCmd)
|
||||
return commandFailureCode;
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4UIcommand* G4UImanager::FindCommand(const G4String& aCmd)
|
||||
{
|
||||
return FindCommand(aCmd.data());
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
G4UIcommand* G4UImanager::FindCommand(const char* aCmd)
|
||||
{
|
||||
G4String aCommand = SolveAlias(aCmd);
|
||||
if(aCommand.empty())
|
||||
{ return nullptr; }
|
||||
|
||||
G4String commandString;
|
||||
|
||||
std::size_t i = aCommand.find(" ");
|
||||
if(i != std::string::npos)
|
||||
{ commandString = aCommand.substr(0, i); }
|
||||
else
|
||||
{ commandString = aCommand; }
|
||||
|
||||
return treeTop->FindPath(commandString);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
void G4UImanager::StoreHistory(const char* fileName)
|
||||
{
|
||||
@@ -648,8 +674,8 @@ void G4UImanager::ListCommands(const char* direct)
|
||||
G4UIcommandTree* G4UImanager::FindDirectory(const char* dirName)
|
||||
{
|
||||
G4String aDirName = dirName;
|
||||
G4String targetDir = aDirName.strip(G4String::both);
|
||||
if(targetDir(targetDir.length() - 1) != '/')
|
||||
G4String targetDir = G4StrUtil::strip_copy(aDirName);
|
||||
if(targetDir.back() != '/')
|
||||
{
|
||||
targetDir += "/";
|
||||
}
|
||||
@@ -661,8 +687,8 @@ G4UIcommandTree* G4UImanager::FindDirectory(const char* dirName)
|
||||
G4int idx = 1;
|
||||
while(idx < G4int(targetDir.length()) - 1)
|
||||
{
|
||||
G4int i = targetDir.index("/", idx);
|
||||
G4String targetDirString = targetDir(0, i + 1);
|
||||
G4int i = targetDir.find("/", idx);
|
||||
G4String targetDirString = targetDir.substr(0, i + 1);
|
||||
comTree = comTree->GetTree(targetDirString);
|
||||
if(comTree == nullptr)
|
||||
{
|
||||
@@ -708,19 +734,19 @@ void G4UImanager::SetCoutDestination(G4UIsession* const value)
|
||||
void G4UImanager::SetAlias(const char* aliasLine)
|
||||
{
|
||||
G4String aLine = aliasLine;
|
||||
G4int i = aLine.index(" ");
|
||||
G4String aliasName = aLine(0, i);
|
||||
G4String aliasValue = aLine(i + 1, aLine.length() - (i + 1));
|
||||
if(aliasValue(0) == '"')
|
||||
G4int i = aLine.find(" ");
|
||||
G4String aliasName = aLine.substr(0, i);
|
||||
G4String aliasValue = aLine.substr(i + 1, aLine.length() - (i + 1));
|
||||
if(aliasValue[0] == '"')
|
||||
{
|
||||
G4String strippedValue;
|
||||
if(aliasValue(aliasValue.length() - 1) == '"')
|
||||
if(aliasValue.back() == '"')
|
||||
{
|
||||
strippedValue = aliasValue(1, aliasValue.length() - 2);
|
||||
strippedValue = aliasValue.substr(1, aliasValue.length() - 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
strippedValue = aliasValue(1, aliasValue.length() - 1);
|
||||
strippedValue = aliasValue.substr(1, aliasValue.length() - 1);
|
||||
}
|
||||
aliasValue = strippedValue;
|
||||
}
|
||||
@@ -732,7 +758,7 @@ void G4UImanager::SetAlias(const char* aliasLine)
|
||||
void G4UImanager::RemoveAlias(const char* aliasName)
|
||||
{
|
||||
G4String aL = aliasName;
|
||||
G4String targetAlias = aL.strip(G4String::both);
|
||||
G4String targetAlias = G4StrUtil::strip_copy(aL);
|
||||
aliasList->RemoveAlias(targetAlias);
|
||||
}
|
||||
|
||||
@@ -764,7 +790,7 @@ void G4UImanager::ParseMacroSearchPath()
|
||||
std::size_t idxfirst = 0;
|
||||
std::size_t idxend = 0;
|
||||
G4String pathstring = "";
|
||||
while((idxend = searchPath.index(':', idxfirst)) != G4String::npos)
|
||||
while((idxend = searchPath.find(':', idxfirst)) != G4String::npos)
|
||||
{
|
||||
pathstring = searchPath.substr(idxfirst, idxend - idxfirst);
|
||||
if(pathstring.size() != 0)
|
||||
|
||||
@@ -136,8 +136,7 @@ G4double G4UImessenger::StoD(G4String str)
|
||||
// --------------------------------------------------------------------
|
||||
G4bool G4UImessenger::StoB(G4String str)
|
||||
{
|
||||
G4String v = str;
|
||||
v.toUpper();
|
||||
G4String v = G4StrUtil::to_upper_copy(str);
|
||||
G4bool vl = false;
|
||||
if(v == "Y" || v == "YES" || v == "1" || v == "T" || v == "TRUE")
|
||||
{
|
||||
@@ -160,7 +159,7 @@ void G4UImessenger::CreateDirectory(const G4String& path, const G4String& dsc,
|
||||
G4UImanager* ui = G4UImanager::GetUIpointer();
|
||||
|
||||
G4String fullpath = path;
|
||||
if(fullpath(fullpath.length() - 1) != '/')
|
||||
if(fullpath.back() != '/')
|
||||
fullpath.append("/");
|
||||
|
||||
G4UIcommandTree* tree = ui->GetTree()->FindCommandTree(fullpath.c_str());
|
||||
|
||||
@@ -80,7 +80,7 @@ G4bool G4UIparameter::operator!=(const G4UIparameter& right) const
|
||||
void G4UIparameter::List()
|
||||
{
|
||||
G4cout << G4endl << "Parameter : " << parameterName << G4endl;
|
||||
if(!parameterGuidance.isNull())
|
||||
if(!parameterGuidance.empty())
|
||||
G4cout << parameterGuidance << G4endl;
|
||||
G4cout << " Parameter type : " << parameterType << G4endl;
|
||||
if(omittable)
|
||||
@@ -95,13 +95,13 @@ void G4UIparameter::List()
|
||||
{
|
||||
G4cout << " Default value : taken from the current value" << G4endl;
|
||||
}
|
||||
else if(!defaultValue.isNull())
|
||||
else if(!defaultValue.empty())
|
||||
{
|
||||
G4cout << " Default value : " << defaultValue << G4endl;
|
||||
}
|
||||
if(!parameterRange.isNull())
|
||||
if(!parameterRange.empty())
|
||||
G4cout << " Parameter range : " << parameterRange << G4endl;
|
||||
if(!parameterCandidate.isNull())
|
||||
if(!parameterCandidate.empty())
|
||||
G4cout << " Candidates : " << parameterCandidate << G4endl;
|
||||
}
|
||||
|
||||
@@ -174,12 +174,12 @@ G4int G4UIparameter::CheckNewValue(const char* newValue)
|
||||
{
|
||||
if(TypeCheck(newValue) == 0)
|
||||
return fParameterUnreadable;
|
||||
if(!parameterRange.isNull())
|
||||
if(!parameterRange.empty())
|
||||
{
|
||||
if(RangeCheck(newValue) == 0)
|
||||
return fParameterOutOfRange;
|
||||
}
|
||||
if(!parameterCandidate.isNull())
|
||||
if(!parameterCandidate.empty())
|
||||
{
|
||||
if(CandidateCheck(newValue) == 0)
|
||||
return fParameterOutOfCandidates;
|
||||
@@ -193,7 +193,7 @@ G4int G4UIparameter::CandidateCheck(const char* newValue)
|
||||
G4Tokenizer candidateTokenizer(parameterCandidate);
|
||||
G4String aToken;
|
||||
G4int iToken = 0;
|
||||
while(!(aToken = candidateTokenizer()).isNull())
|
||||
while(!(aToken = candidateTokenizer()).empty())
|
||||
{
|
||||
++iToken;
|
||||
if(aToken == newValue)
|
||||
@@ -201,6 +201,14 @@ G4int G4UIparameter::CandidateCheck(const char* newValue)
|
||||
}
|
||||
G4cerr << "parameter value (" << newValue
|
||||
<< ") is not listed in the candidate List." << G4endl;
|
||||
G4cerr << " Candidates are:";
|
||||
G4Tokenizer candidateListTokenizer(parameterCandidate);
|
||||
while(!(aToken = candidateListTokenizer()).empty())
|
||||
{
|
||||
G4cerr << ' ' << aToken;
|
||||
}
|
||||
G4cerr << G4endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -269,7 +277,7 @@ G4int G4UIparameter::TypeCheck(const char* newValue)
|
||||
case 'S':
|
||||
break;
|
||||
case 'B':
|
||||
newValueString.toUpper();
|
||||
G4StrUtil::to_upper(newValueString);
|
||||
if(newValueString == "Y" || newValueString == "N" ||
|
||||
newValueString == "YES" || newValueString == "NO" ||
|
||||
newValueString == "1" || newValueString == "0" ||
|
||||
@@ -973,7 +981,7 @@ tokenNum G4UIparameter::Yylex() // reads input and returns token number KR486
|
||||
{ // I or D
|
||||
do
|
||||
{
|
||||
buf += G4String((unsigned char) c);
|
||||
buf += (unsigned char) c;
|
||||
c = G4UIpGetc();
|
||||
} while(c == '.' || isdigit(c) || c == 'e' || c == 'E' || c == '+' ||
|
||||
c == '-');
|
||||
@@ -1000,7 +1008,7 @@ tokenNum G4UIparameter::Yylex() // reads input and returns token number KR486
|
||||
{ // IDENTIFIER
|
||||
do
|
||||
{
|
||||
buf += G4String((unsigned char) c);
|
||||
buf += (unsigned char) c;
|
||||
} while((c = G4UIpGetc()) != EOF && (isalnum(c) || c == '_'));
|
||||
G4UIpUngetc(c);
|
||||
if(buf == parameterName)
|
||||
@@ -1049,7 +1057,7 @@ G4int G4UIparameter::G4UIpGetc()
|
||||
{ // emulation of getc()
|
||||
G4int length = parameterRange.length();
|
||||
if(bp < length)
|
||||
return parameterRange(bp++);
|
||||
return parameterRange[bp++];
|
||||
else
|
||||
return EOF;
|
||||
}
|
||||
@@ -1059,7 +1067,7 @@ G4int G4UIparameter::G4UIpUngetc(G4int c)
|
||||
{ // emulation of ungetc()
|
||||
if(c < 0)
|
||||
return -1;
|
||||
if(bp > 0 && c == parameterRange(bp - 1))
|
||||
if(bp > 0 && c == parameterRange[bp - 1])
|
||||
{
|
||||
--bp;
|
||||
}
|
||||
@@ -1067,7 +1075,7 @@ G4int G4UIparameter::G4UIpUngetc(G4int c)
|
||||
{
|
||||
G4cerr << "G4UIpUngetc() failed." << G4endl;
|
||||
G4cerr << "bp=" << bp << " c=" << c
|
||||
<< " pR(bp-1)=" << parameterRange(bp - 1) << G4endl;
|
||||
<< " pR(bp-1)=" << parameterRange[bp - 1] << G4endl;
|
||||
paramERR = 1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user