40 parameterName = nullString;
43 parameterGuidance = nullString;
44 defaultValue = nullString;
45 parameterRange = nullString;
46 currentAsDefaultFlag =
false;
47 parameterCandidate = nullString;
56 parameterName = nullString;
57 parameterType = theType;
59 parameterGuidance = nullString;
60 defaultValue = nullString;
61 parameterRange = nullString;
62 currentAsDefaultFlag =
false;
63 parameterCandidate = nullString;
71 parameterName = theName;
72 parameterType = theType;
73 omittable = theOmittable;
75 parameterGuidance = nullString;
76 defaultValue = nullString;
77 parameterRange = nullString;
78 currentAsDefaultFlag =
false;
79 parameterCandidate = nullString;
90 return (
this == &right );
95 return (
this != &right );
101 if( ! parameterGuidance.
isNull() )
102 G4cout << parameterGuidance << G4endl ;
103 G4cout <<
" Parameter type : " << parameterType <<
G4endl;
108 if( currentAsDefaultFlag )
109 {
G4cout <<
" Default value : taken from the current value" <<
G4endl; }
110 else if( ! defaultValue.
isNull() )
111 {
G4cout <<
" Default value : " << defaultValue <<
G4endl; }
112 if( ! parameterRange.
isNull() )
113 G4cout <<
" Parameter range : " << parameterRange << G4endl;
114 if( ! parameterCandidate.
isNull() )
115 G4cout <<
" Candidates : " << parameterCandidate << G4endl;
120 std::ostringstream os;
121 os << theDefaultValue;
122 defaultValue = os.str();
127 std::ostringstream os;
128 os << theDefaultValue;
129 defaultValue = os.str();
143 if( ! parameterRange.
isNull() )
145 if( ! parameterCandidate.
isNull() )
150 G4int G4UIparameter::
151 CandidateCheck(
const char* newValue) {
152 G4Tokenizer candidateTokenizer(parameterCandidate);
155 while( ! (aToken=candidateTokenizer()).isNull() )
158 if(aToken==newValue)
return iToken;
160 G4cerr <<
"parameter value is not listed in the candidate List." <<
G4endl;
164 G4int G4UIparameter::
165 RangeCheck(
const char* newValue) {
168 std::istringstream is(newValue);
169 char type = toupper( parameterType );
171 case 'D': { is >> newVal.
D; }
break;
172 case 'I': { is >> newVal.
I; }
break;
177 result = Expression();
178 if( paramERR == 1 )
return 0;
180 G4cerr <<
"Illegal Expression in parameter range." <<
G4endl;
183 if ( result.
I )
return 1;
184 G4cerr <<
"parameter out of range: "<< parameterRange <<
G4endl;
189 G4int G4UIparameter::
190 TypeCheck(
const char* newValue)
193 char type = toupper( parameterType );
196 if( IsDouble(newValueString.data())== 0) {
197 G4cerr<<newValue<<
": double value expected."
202 if( IsInt(newValueString.data(),20)== 0) {
203 G4cerr<<newValue<<
": integer expected."
209 newValueString.toUpper();
210 if ( newValueString ==
"Y" || newValueString ==
"N"
211 ||newValueString ==
"YES" || newValueString ==
"NO"
212 ||newValueString ==
"1" || newValueString ==
"0"
213 ||newValueString ==
"T" || newValueString ==
"F"
214 ||newValueString ==
"TRUE" || newValueString ==
"FALSE")
226 G4int G4UIparameter::
227 IsInt(
const char* buf,
short maxDigits)
231 if( *p ==
'+' || *p ==
'-') { ++
p; }
232 if( isdigit( (
G4int)(*p) )) {
233 while( isdigit( (
G4int)(*p) )) { ++
p; ++length; }
235 if( length > maxDigits) {
250 G4int G4UIparameter::
251 ExpectExponent(
const char* str)
254 if( IsInt( str, maxExplength=7 ))
return 1;
258 G4int G4UIparameter::
259 IsDouble(
const char* buf)
263 case '+':
case '-': ++
p;
265 while( isdigit( (
G4int)(*p) )) { ++
p; }
269 return ExpectExponent(++p );
271 if( *p ==
'\0' )
return 1;
272 if( *p ==
'e' || *p ==
'E' )
return ExpectExponent(++p );
274 while( isdigit( (
G4int)(*p) )) { ++
p; }
275 if( *p ==
'\0' )
return 1;
276 if( *p ==
'e' || *p ==
'E')
return ExpectExponent(++p);
277 }
else return 0;
break;
281 if( *p ==
'.' ) { ++
p;
283 while( isdigit( (
G4int)(*p) )) { ++
p; }
284 if( *p ==
'\0' )
return 1;
285 if( *p ==
'e' || *p ==
'E')
return ExpectExponent(++p);
291 while( isdigit( (
G4int)(*p) )) { ++
p; }
292 if( *p ==
'\0' )
return 1;
293 if( *p ==
'e' || *p ==
'E' )
return ExpectExponent(++p);
297 while( isdigit( (
G4int)(*p) )) { ++
p; }
298 if( *p ==
'\0' )
return 1;
299 if( *p ==
'e' || *p ==
'E')
return ExpectExponent(++p);
300 if( *p ==
'.' ) { ++
p;
301 if( *p ==
'\0' )
return 1;
302 if( *p ==
'e' || *p ==
'E')
return ExpectExponent(++p);
304 while( isdigit( (
G4int)(*p) )) { ++
p; }
305 if( *p ==
'\0' )
return 1;
306 if( *p ==
'e' || *p ==
'E')
return ExpectExponent(++p);
324 result = LogicalORExpression();
329 LogicalORExpression(
void)
333 p = LogicalANDExpression();
336 G4cerr <<
"Parameter range: illegal type at '||'" <<
G4endl;
343 p = LogicalANDExpression();
345 G4cerr <<
"Parameter range: illegal type at '||'" <<
G4endl;
353 result.
I += (p.
D != 0.0);
364 LogicalANDExpression(
void)
368 p = EqualityExpression();
371 G4cerr <<
"Parameter range: illegal type at '&&'" <<
G4endl;
378 p = EqualityExpression();
380 G4cerr <<
"Parameter range: illegal type at '&&'" <<
G4endl;
388 result.
I *= (p.
D != 0.0);
400 EqualityExpression(
void)
408 result = RelationalExpression();
409 if( token==
EQ || token==
NE ) {
413 arg2 = RelationalExpression();
414 result.
I = Eval2( arg1, operat, arg2 );
421 G4cerr <<
"Parameter range: error at EqualityExpression"
431 RelationalExpression(
void)
440 arg1 = AdditiveExpression();
441 if( token==
GT || token==
GE || token==
LT || token==
LE ) {
444 arg2 = AdditiveExpression();
445 result.
I = Eval2( arg1, operat, arg2 );
460 AdditiveExpression(
void)
462 result = MultiplicativeExpression();
463 if( token !=
'+' && token !=
'-' )
return result;
464 G4cerr <<
"Parameter range: operator "
466 <<
" is not supported." << G4endl;
472 MultiplicativeExpression(
void)
474 result = UnaryExpression();
475 if( token !=
'*' && token !=
'/' && token !=
'%' )
return result;
476 G4cerr <<
"Parameter range: operator "
478 <<
" is not supported." << G4endl;
484 UnaryExpression(
void)
494 p = UnaryExpression();
505 result = UnaryExpression();
break;
508 G4cerr <<
"Parameter range error: "
509 <<
"operator '!' is not supported (sorry)."
512 result = UnaryExpression();
break;
514 result = PrimaryExpression();
521 PrimaryExpression(
void)
531 token = Yylex();
break;
535 token= Yylex();
break;
539 token = Yylex();
break;
542 result = Expression();
557 G4int G4UIparameter::
562 <<
": meaningless comparison "
566 char type = toupper( parameterType );
571 return CompareInt( newVal.
I, op, arg2.
I );
573 G4cerr <<
"integer operand expected for "
574 << parameterRange <<
'.'
580 return CompareDouble( newVal.
D, op, arg2.
D );
583 return CompareDouble( newVal.
D, op, arg2.
I );
592 return CompareInt( arg1.
I, op, newVal.
I );
594 G4cerr <<
"integer operand expected for "
595 << parameterRange <<
'.'
601 return CompareDouble( arg1.
D, op, newVal.
D );
604 return CompareDouble( arg1.
I, op, newVal.
D );
609 G4cerr <<
"no param name is specified at the param range."<<
G4endl;
613 G4int G4UIparameter::
619 case GT: result = ( arg1 > arg2); opr=
">" ;
break;
620 case GE: result = ( arg1 >= arg2); opr=
">=";
break;
621 case LT: result = ( arg1 < arg2); opr=
"<" ;
break;
622 case LE: result = ( arg1 <= arg2); opr=
"<=";
break;
623 case EQ: result = ( arg1 == arg2); opr=
"==";
break;
624 case NE: result = ( arg1 != arg2); opr=
"!=";
break;
626 G4cerr <<
"Parameter range: error at CompareInt" <<
G4endl;
631 << arg1 <<
" " << opr << arg2
632 <<
" result: " << result
638 G4int G4UIparameter::
644 case GT: result = ( arg1 > arg2); opr=
">";
break;
645 case GE: result = ( arg1 >= arg2); opr=
">=";
break;
646 case LT: result = ( arg1 < arg2); opr=
"<";
break;
647 case LE: result = ( arg1 <= arg2); opr=
"<=";
break;
648 case EQ: result = ( arg1 == arg2); opr=
"==";
break;
649 case NE: result = ( arg1 != arg2); opr=
"!=";
break;
651 G4cerr <<
"Parameter range: error at CompareDouble" <<
G4endl;
655 G4cerr <<
"CompareDouble "
656 << arg1 <<
" " << opr <<
" "<< arg2
657 <<
" result: " << result
671 while(( c= G4UIpGetc())==
' '|| c==
'\t' || c==
'\n' )
676 if (isdigit(c) || c==
'.') {
680 }
while (c==
'.' || isdigit(c) ||
681 c==
'e' || c==
'E' || c==
'+' || c==
'-');
684 std::istringstream is(t);
685 if ( IsInt(buf.
data(),20) ) {
689 if ( IsDouble(buf.
data()) ) {
697 if (isalpha(c)|| c==
'_') {
700 }
while ((c=G4UIpGetc()) != EOF && (isalnum(c) || c==
'_'));
702 if( buf == parameterName ) {
713 case '=':
return (
tokenNum) Follow(
'=',
EQ,
'=');
714 case '!':
return (
tokenNum) Follow(
'=',
NE,
'!');
723 G4int G4UIparameter::
726 G4int c = G4UIpGetc();
734 G4int G4UIparameter::
736 G4int length = parameterRange.length();
738 return parameterRange(bp++);
742 G4int G4UIparameter::
743 G4UIpUngetc(
G4int c) {
745 if (bp >0 && c == parameterRange(bp-1)) {
749 G4cerr <<
"bp="<<bp <<
" c="<<c
750 <<
" pR(bp-1)=" << parameterRange(bp-1)
G4double G4NeutronHPJENDLHEData::G4double result
void SetDefaultValue(const char *theDefaultValue)
G4int operator==(const G4UIparameter &right) const
G4int CheckNewValue(const char *newValue)
G4GLOB_DLL std::ostream G4cout
const char * data() const
G4int operator!=(const G4UIparameter &right) const
G4GLOB_DLL std::ostream G4cerr