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 (" << newValue
161 <<
") is not listed in the candidate List." <<
G4endl;
165 G4int G4UIparameter::
166 RangeCheck(
const char* newValue) {
169 std::istringstream is(newValue);
170 char type = toupper( parameterType );
172 case 'D': { is >> newVal.
D; }
break;
173 case 'I': { is >> newVal.
I; }
break;
178 result = Expression();
179 if( paramERR == 1 )
return 0;
181 G4cerr <<
"Illegal Expression in parameter range." <<
G4endl;
184 if ( result.
I )
return 1;
185 G4cerr <<
"parameter out of range: "<< parameterRange <<
G4endl;
190 G4int G4UIparameter::
191 TypeCheck(
const char* newValue)
194 char type = toupper( parameterType );
197 if( IsDouble(newValueString.data())== 0) {
198 G4cerr<<newValue<<
": double value expected."
203 if( IsInt(newValueString.data(),20)== 0) {
204 G4cerr<<newValue<<
": integer expected."
210 newValueString.toUpper();
211 if ( newValueString ==
"Y" || newValueString ==
"N"
212 ||newValueString ==
"YES" || newValueString ==
"NO"
213 ||newValueString ==
"1" || newValueString ==
"0"
214 ||newValueString ==
"T" || newValueString ==
"F"
215 ||newValueString ==
"TRUE" || newValueString ==
"FALSE")
227 G4int G4UIparameter::
228 IsInt(
const char* buf,
short maxDigits)
232 if( *p ==
'+' || *p ==
'-') { ++
p; }
233 if( isdigit( (
G4int)(*p) )) {
234 while( isdigit( (
G4int)(*p) )) { ++
p; ++length; }
236 if( length > maxDigits) {
251 G4int G4UIparameter::
252 ExpectExponent(
const char* str)
255 if( IsInt( str, maxExplength=7 ))
return 1;
259 G4int G4UIparameter::
260 IsDouble(
const char* buf)
264 case '+':
case '-': ++
p;
266 while( isdigit( (
G4int)(*p) )) { ++
p; }
270 return ExpectExponent(++p );
272 if( *p ==
'\0' )
return 1;
273 if( *p ==
'e' || *p ==
'E' )
return ExpectExponent(++p );
275 while( isdigit( (
G4int)(*p) )) { ++
p; }
276 if( *p ==
'\0' )
return 1;
277 if( *p ==
'e' || *p ==
'E')
return ExpectExponent(++p);
278 }
else return 0;
break;
282 if( *p ==
'.' ) { ++
p;
284 while( isdigit( (
G4int)(*p) )) { ++
p; }
285 if( *p ==
'\0' )
return 1;
286 if( *p ==
'e' || *p ==
'E')
return ExpectExponent(++p);
292 while( isdigit( (
G4int)(*p) )) { ++
p; }
293 if( *p ==
'\0' )
return 1;
294 if( *p ==
'e' || *p ==
'E' )
return ExpectExponent(++p);
298 while( isdigit( (
G4int)(*p) )) { ++
p; }
299 if( *p ==
'\0' )
return 1;
300 if( *p ==
'e' || *p ==
'E')
return ExpectExponent(++p);
301 if( *p ==
'.' ) { ++
p;
302 if( *p ==
'\0' )
return 1;
303 if( *p ==
'e' || *p ==
'E')
return ExpectExponent(++p);
305 while( isdigit( (
G4int)(*p) )) { ++
p; }
306 if( *p ==
'\0' )
return 1;
307 if( *p ==
'e' || *p ==
'E')
return ExpectExponent(++p);
325 result = LogicalORExpression();
330 LogicalORExpression(
void)
334 p = LogicalANDExpression();
337 G4cerr <<
"Parameter range: illegal type at '||'" <<
G4endl;
344 p = LogicalANDExpression();
346 G4cerr <<
"Parameter range: illegal type at '||'" <<
G4endl;
354 result.
I += (p.
D != 0.0);
365 LogicalANDExpression(
void)
369 p = EqualityExpression();
372 G4cerr <<
"Parameter range: illegal type at '&&'" <<
G4endl;
379 p = EqualityExpression();
381 G4cerr <<
"Parameter range: illegal type at '&&'" <<
G4endl;
389 result.
I *= (p.
D != 0.0);
401 EqualityExpression(
void)
409 result = RelationalExpression();
410 if( token==
EQ || token==
NE ) {
414 arg2 = RelationalExpression();
415 result.
I = Eval2( arg1, operat, arg2 );
422 G4cerr <<
"Parameter range: error at EqualityExpression"
432 RelationalExpression(
void)
441 arg1 = AdditiveExpression();
442 if( token==
GT || token==
GE || token==
LT || token==
LE ) {
445 arg2 = AdditiveExpression();
446 result.
I = Eval2( arg1, operat, arg2 );
461 AdditiveExpression(
void)
463 result = MultiplicativeExpression();
464 if( token !=
'+' && token !=
'-' )
return result;
465 G4cerr <<
"Parameter range: operator "
467 <<
" is not supported." << G4endl;
473 MultiplicativeExpression(
void)
475 result = UnaryExpression();
476 if( token !=
'*' && token !=
'/' && token !=
'%' )
return result;
477 G4cerr <<
"Parameter range: operator "
479 <<
" is not supported." << G4endl;
485 UnaryExpression(
void)
495 p = UnaryExpression();
506 result = UnaryExpression();
break;
509 G4cerr <<
"Parameter range error: "
510 <<
"operator '!' is not supported (sorry)."
513 result = UnaryExpression();
break;
515 result = PrimaryExpression();
522 PrimaryExpression(
void)
532 token = Yylex();
break;
536 token= Yylex();
break;
540 token = Yylex();
break;
543 result = Expression();
558 G4int G4UIparameter::
563 <<
": meaningless comparison "
567 char type = toupper( parameterType );
572 return CompareInt( newVal.
I, op, arg2.
I );
574 G4cerr <<
"integer operand expected for "
575 << parameterRange <<
'.'
581 return CompareDouble( newVal.
D, op, arg2.
D );
584 return CompareDouble( newVal.
D, op, arg2.
I );
593 return CompareInt( arg1.
I, op, newVal.
I );
595 G4cerr <<
"integer operand expected for "
596 << parameterRange <<
'.'
602 return CompareDouble( arg1.
D, op, newVal.
D );
605 return CompareDouble( arg1.
I, op, newVal.
D );
610 G4cerr <<
"no param name is specified at the param range."<<
G4endl;
614 G4int G4UIparameter::
620 case GT: result = ( arg1 > arg2); opr=
">" ;
break;
621 case GE: result = ( arg1 >= arg2); opr=
">=";
break;
622 case LT: result = ( arg1 < arg2); opr=
"<" ;
break;
623 case LE: result = ( arg1 <= arg2); opr=
"<=";
break;
624 case EQ: result = ( arg1 == arg2); opr=
"==";
break;
625 case NE: result = ( arg1 != arg2); opr=
"!=";
break;
627 G4cerr <<
"Parameter range: error at CompareInt" <<
G4endl;
632 << arg1 <<
" " << opr << arg2
633 <<
" result: " << result
639 G4int G4UIparameter::
645 case GT: result = ( arg1 > arg2); opr=
">";
break;
646 case GE: result = ( arg1 >= arg2); opr=
">=";
break;
647 case LT: result = ( arg1 < arg2); opr=
"<";
break;
648 case LE: result = ( arg1 <= arg2); opr=
"<=";
break;
649 case EQ: result = ( arg1 == arg2); opr=
"==";
break;
650 case NE: result = ( arg1 != arg2); opr=
"!=";
break;
652 G4cerr <<
"Parameter range: error at CompareDouble" <<
G4endl;
656 G4cerr <<
"CompareDouble "
657 << arg1 <<
" " << opr <<
" "<< arg2
658 <<
" result: " << result
672 while(( c= G4UIpGetc())==
' '|| c==
'\t' || c==
'\n' )
677 if (isdigit(c) || c==
'.') {
681 }
while (c==
'.' || isdigit(c) ||
682 c==
'e' || c==
'E' || c==
'+' || c==
'-');
685 std::istringstream is(t);
686 if ( IsInt(buf.
data(),20) ) {
690 if ( IsDouble(buf.
data()) ) {
698 if (isalpha(c)|| c==
'_') {
701 }
while ((c=G4UIpGetc()) != EOF && (isalnum(c) || c==
'_'));
703 if( buf == parameterName ) {
714 case '=':
return (
tokenNum) Follow(
'=',
EQ,
'=');
715 case '!':
return (
tokenNum) Follow(
'=',
NE,
'!');
724 G4int G4UIparameter::
727 G4int c = G4UIpGetc();
735 G4int G4UIparameter::
737 G4int length = parameterRange.length();
739 return parameterRange(bp++);
743 G4int G4UIparameter::
744 G4UIpUngetc(
G4int c) {
746 if (bp >0 && c == parameterRange(bp-1)) {
750 G4cerr <<
"bp="<<bp <<
" c="<<c
751 <<
" pR(bp-1)=" << parameterRange(bp-1)
G4double G4ParticleHPJENDLHEData::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