Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
opt
build
coinutils
coinutils-2.6.4
CoinUtils
src
CoinParam.hpp
Go to the documentation of this file.
1
/* $Id: CoinParam.hpp 1191 2009-07-25 08:38:12Z forrest $ */
2
#ifndef CoinParam_H
3
#define CoinParam_H
4
5
/*
6
Copyright (C) 2002, International Business Machines
7
Corporation and others. All Rights Reserved.
8
*/
9
14
#include <vector>
15
#include <string>
16
72
class
CoinParam
73
{
74
75
public
:
76
79
92
typedef
enum
{
coinParamInvalid
= 0,
93
coinParamAct
,
coinParamInt
,
coinParamDbl
,
94
coinParamStr
,
coinParamKwd
}
CoinParamType
;
95
103
typedef
int (*
CoinParamFunc
)(
CoinParam
*param) ;
104
106
113
116
CoinParam
() ;
117
124
CoinParam
(std::string
name
, std::string help,
125
double
lower,
double
upper,
double
dflt = 0.0,
126
bool
display
=
true
) ;
127
132
CoinParam
(std::string
name
, std::string help,
133
int
lower,
int
upper,
int
dflt = 0,
134
bool
display
=
true
) ;
135
150
CoinParam
(std::string
name
, std::string help,
151
std::string firstValue,
int
dflt,
bool
display
=
true
) ;
152
161
CoinParam
(std::string
name
, std::string help,
162
std::string dflt,
bool
display
=
true
) ;
163
166
CoinParam
(std::string
name
, std::string help,
167
bool
display
=
true
) ;
168
171
CoinParam
(
const
CoinParam
&orig) ;
172
175
virtual
CoinParam
*
clone
() ;
176
179
CoinParam
&
operator=
(
const
CoinParam
&rhs) ;
180
183
virtual
~CoinParam
() ;
184
186
189
192
void
appendKwd
(std::string kwd) ;
193
198
int
kwdIndex
(std::string kwd)
const
;
199
203
std::string
kwdVal
()
const
;
204
211
void
setKwdVal
(
int
value,
bool
printIt
=
false
) ;
212
219
void
setKwdVal
(
const
std::string value ) ;
220
224
void
printKwds
()
const
;
225
226
229
void
setStrVal
(std::string value) ;
230
233
std::string
strVal
()
const
;
234
235
238
void
setDblVal
(
double
value) ;
239
242
double
dblVal
()
const
;
243
244
247
void
setIntVal
(
int
value) ;
248
251
int
intVal
()
const
;
252
253
256
inline
void
setShortHelp
(
const
std::string help) {
shortHelp_
= help ; }
257
260
inline
std::string
shortHelp
()
const
{
return
(
shortHelp_
) ; }
261
267
inline
void
setLongHelp
(
const
std::string help) {
longHelp_
= help ; }
268
271
inline
std::string
longHelp
()
const
{
return
(
longHelp_
) ; }
272
281
void
printLongHelp
()
const
;
282
284
287
290
inline
CoinParamType
type
()
const
{
return
(
type_
) ; }
291
294
inline
void
setType
(
CoinParamType
type
) {
type_
=
type
; }
295
298
inline
std::string
name
()
const
{
return
(
name_
) ; }
299
302
inline
void
setName
(std::string
name
) {
name_
=
name
;
processName
() ; }
303
311
int
matches
(std::string input)
const
;
312
319
std::string
matchName
()
const
;
320
327
inline
void
setDisplay
(
bool
display
) {
display_
=
display
; }
328
331
inline
bool
display
()
const
{
return
(
display_
) ; }
332
335
inline
CoinParamFunc
pushFunc
() {
return
(
pushFunc_
) ; }
336
339
inline
void
setPushFunc
(
CoinParamFunc
func) {
pushFunc_
= func ; }
340
343
inline
CoinParamFunc
pullFunc
() {
return
(
pullFunc_
) ; }
344
347
inline
void
setPullFunc
(
CoinParamFunc
func) {
pullFunc_
= func ; }
348
350
351
private
:
352
355
357
void
processName
() ;
358
360
363
CoinParamType
type_
;
365
367
std::string
name_
;
368
370
unsigned
int
lengthName_
;
371
375
unsigned
int
lengthMatch_
;
376
378
double
lowerDblValue_
;
379
381
double
upperDblValue_
;
382
384
double
dblValue_
;
385
387
int
lowerIntValue_
;
388
390
int
upperIntValue_
;
391
393
int
intValue_
;
394
396
std::string
strValue_
;
397
399
std::vector<std::string>
definedKwds_
;
400
403
int
currentKwd_
;
404
406
CoinParamFunc
pushFunc_
;
407
409
CoinParamFunc
pullFunc_
;
410
412
std::string
shortHelp_
;
413
415
std::string
longHelp_
;
416
418
bool
display_
;
420
421
} ;
422
426
typedef
std::vector<CoinParam*>
CoinParamVec
;
427
431
std::ostream &
operator<<
(std::ostream &s,
const
CoinParam
¶m) ;
432
433
/*
434
Bring in the utility functions for parameter handling (CbcParamUtils).
435
*/
436
444
namespace
CoinParamUtils {
450
void
setInputSrc
(FILE *src) ;
451
455
bool
isCommandLine
() ;
456
460
bool
isInteractive
() ;
461
469
std::string
getStringField
(
int
argc,
const
char
*argv[],
int
*valid) ;
470
478
int
getIntField
(
int
argc,
const
char
*argv[],
int
*valid) ;
479
487
double
getDoubleField
(
int
argc,
const
char
*argv[],
int
*valid) ;
488
501
int
matchParam
(
const
CoinParamVec ¶mVec, std::string name,
502
int
&matchNdx,
int
&shortCnt) ;
503
534
std::string
getCommand
(
int
argc,
const
char
*argv[],
535
const
std::string prompt, std::string *pfx = 0) ;
536
574
int
lookupParam
(std::string name, CoinParamVec ¶mVec,
575
int
*matchCnt = 0,
int
*shortCnt = 0,
int
*queryCnt = 0) ;
576
584
void
printIt
(
const
char
*msg) ;
585
void
shortOrHelpOne
(CoinParamVec ¶mVec,
int
matchNdx, std::string
602
name,
int
numQuery) ;
603
612
void
shortOrHelpMany
(CoinParamVec ¶mVec,
613
std::string name,
int
numQuery) ;
614
620
void
printGenericHelp
() ;
621
634
void
printHelp
(CoinParamVec ¶mVec,
int
firstParam,
int
lastParam,
635
std::string prefix,
636
bool
shortHelp,
bool
longHelp,
bool
hidden) ;
637
}
638
639
640
#endif
/* CoinParam_H */
641
Generated on Tue Mar 1 2016 22:31:56 by
1.8.4