DCMTK Version 3.7.0 OFFIS DICOM Toolkit

Public Member Functions | Protected Member Functions | Private Attributes | List of all members
OFConsoleApplication Class Reference

support class for console applications. More...

## Public Member Functions
| OFConsoleApplication (const char *app, const char *desc=NULL, const char *rcsid=NULL)
| constructor More...
| ~OFConsoleApplication ()
| destructor
OFBool | parseCommandLine (OFCommandLine &cmd, int argCount, char *argValue[], const int flags=0, const int startPos=1)
| parse command line. More...
OFBool | parseCommandLine (OFCommandLine &cmd, int argCount, wchar_t *argValue[], const int flags=0, const int startPos=1)
| parse command line. More...
void | printHeader (const OFBool hostInfo=OFFalse, const OFBool stdError=OFFalse)
| print header of console application (consisting of identifier, name and description) More...
void | printUsage (const OFCommandLine *cmd=NULL)
| print usage (syntax of command line options) to standard output stream More...
void | printArguments (OFCommandLine *cmd=NULL)
| print expanded command line arguments to standard error stream More...
void | printIdentifier ()
| print resource identifier to standard error stream
void | printError (const char *str, const int code=EXITCODE_COMMANDLINE_SYNTAX_ERROR)
| print error message (incl. More...
void | printWarning (const char *str, const char *prefix="warning")
| print warning message (w/o header) to standard error stream More...
void | printMessage (const char *str)
| print message (w/o header) to standard error stream. More...
OFBool | quietMode () const
| check quiet mode More...
void | setQuietMode (const OFBool mode=OFTrue)
| switch on/off quiet mode More...
void | checkValue (const OFCommandLine::E_ValueStatus status, OFCommandLine *cmd=NULL)
| check value status and print error message if necessary More...
void | checkParam (const OFCommandLine::E_ParamValueStatus status, OFCommandLine *cmd=NULL)
| check parameter status and print error message if necessary More...
void | checkDependence (const char *subOpt, const char *baseOpt, OFBool condition)
| check dependence between sub and base option and report an error if required. More...
void | checkConflict (const char *firstOpt, const char *secondOpt, OFBool condition)
| check conflict between two options and report an error if required. More...

## Protected Member Functions
OFBool | checkParseStatus (const OFCommandLine::E_ParseStatus status)
| check parse status of previously parsed command line

## Private Attributes
OFString | Name
| Name of the application (short form)
OFString | Description
| Short description of the application.
OFString | Identification
| Identification string (rcsid)
OFBool | QuietMode
| Switch on/off error and warning messages.
OFCommandLine * | CmdLine
| Pointer to associated CommandLine class.

## Detailed Description

support class for console applications.

Builds an envelope for the OFCommandLine class to provide a consistent behaviour for all DCMTK console applications. Performs console output operations and error checking.

## Constructor & Destructor Documentation

## ◆ OFConsoleApplication()

OFConsoleApplication::OFConsoleApplication | ( | const char * | app,
|  | const char * | desc = `NULL`,
|  | const char * | rcsid = `NULL`
| ) |  |

constructor

Parameters

  app | application name
  desc | (short) description of what the application does
  rcsid | identifier for console application

## Member Function Documentation

## ◆ checkConflict()

void OFConsoleApplication::checkConflict | ( | const char * | firstOpt,
|  | const char * | secondOpt,
|  | OFBool | condition
| ) |  |

check conflict between two options and report an error if required.

Message format: "error: " + firstOpt + " not allowed with " + secondOpt

Parameters

  firstOpt | first option to be checked
  secondOpt | second option to be checked
  condition | if true error message is printed (i.e. a conflict exists)

## ◆ checkDependence()

void OFConsoleApplication::checkDependence | ( | const char * | subOpt,
|  | const char * | baseOpt,
|  | OFBool | condition
| ) |  |

check dependence between sub and base option and report an error if required.

Message format: "error: " + subOpt + " only allowed with " + baseOpt

Parameters

  subOpt | option to be checked
  baseOpt | base option required for sub option
  condition | if false error message is printed (i.e. base option is absent)

## ◆ checkParam()

void OFConsoleApplication::checkParam | ( | const OFCommandLine::E_ParamValueStatus | status,
|  | OFCommandLine * | cmd = `NULL`
| ) |  |

check parameter status and print error message if necessary

Parameters

  status | status of OFCommandLine::getParam() call
  cmd | reference to command line class (default: object used for parsing)

## ◆ checkValue()

void OFConsoleApplication::checkValue | ( | const OFCommandLine::E_ValueStatus | status,
|  | OFCommandLine * | cmd = `NULL`
| ) |  |

check value status and print error message if necessary

Parameters

  status | status of OFCommandLine::getValue() call
  cmd | reference to command line class (default: object used for parsing)

## ◆ parseCommandLine() [1/2]

OFBool OFConsoleApplication::parseCommandLine | ( | OFCommandLine & | cmd,
|  | int | argCount,
|  | char * | argValue[],
|  | const int | flags = `0`,
|  | const int | startPos = `1`
| ) |  |

parse command line.

If the command line has no argument (in case at least one argument is required) and if the command line has only one argument, namely "--help" or the specified shortcut, (in all cases) the usage is printed (see printUsage).

Parameters

  cmd | reference to the OFCommandLine object. Should be valid at least as long as this object exists.
  argCount | number of arguments (argc)
  argValue | pointer to argument array (argv[])
  flags | flags to be used for parsing (e.g. OFCommandLine::PF_NoCommandFiles)
  startPos | first argument to be parsed (default: 1, i.e. omit program name)

Returns
  status of parsing process, true if successful, false otherwise

## ◆ parseCommandLine() [2/2]

OFBool OFConsoleApplication::parseCommandLine | ( | OFCommandLine & | cmd,
|  | int | argCount,
|  | wchar_t * | argValue[],
|  | const int | flags = `0`,
|  | const int | startPos = `1`
| ) |  |

parse command line.

This is a Windows-specific version supporting the wide character encoding (UTF-16). If the command line has no argument (in case at least one argument is required) and if the command line has only one argument, namely "--help" or the specified shortcut, (in all cases) the usage is printed (see printUsage).

Remarks
  This method is only available if DCMTK is compiled on Windows Operating Systems with wide chars available.

Parameters

  cmd | reference to the OFCommandLine object. Should be valid at least as long as this object exists.
  argCount | number of arguments (argc)
  argValue | pointer to argument array (argv[])
  flags | flags to be used for parsing (e.g. OFCommandLine::PF_NoCommandFiles)
  startPos | first argument to be parsed (default: 1, i.e. omit program name)

Returns
  status of parsing process, true if successful, false otherwise

## ◆ printArguments()

void OFConsoleApplication::printArguments | ( | OFCommandLine * | cmd = `NULL` | ) |

print expanded command line arguments to standard error stream

Parameters

  cmd | reference to command line class (default: object used for parsing)

## ◆ printError()

void OFConsoleApplication::printError | ( | const char * | str,
|  | const int | code = `EXITCODE_COMMANDLINE_SYNTAX_ERROR`
| ) |  |

print error message (incl.

header) to standard error stream and exit with error code

Parameters

  str | error message to be printed
  code | error code to be returned (exit)

## ◆ printHeader()

void OFConsoleApplication::printHeader | ( | const OFBool | hostInfo = `OFFalse`,
|  | const OFBool | stdError = `OFFalse`
| ) |  |

print header of console application (consisting of identifier, name and description)

Parameters

  hostInfo | print host information as reported by 'config.guess' if OFTrue. If compiled with 'libiconv' support, the current locale's character encoding is also shown. On Windows systems, either the current OEM and ANSI code page identifiers are printed or "Unicode (UTF-16)" if support is enabled. Finally, if the DEBUG macro is defined, a note on the presence of debug code is given.
  stdError | print to standard error stream if OFTrue (default: standard output)

## ◆ printMessage()

void OFConsoleApplication::printMessage | ( | const char * | str | ) |

print message (w/o header) to standard error stream.

Parameters

  str | message to be printed

## ◆ printUsage()

void OFConsoleApplication::printUsage | ( | const OFCommandLine * | cmd = `NULL` | ) |

print usage (syntax of command line options) to standard output stream

Parameters

  cmd | reference to command line class (default: object used for parsing)

## ◆ printWarning()

void OFConsoleApplication::printWarning | ( | const char * | str,
|  | const char * | prefix = `"warning"`
| ) |  |

print warning message (w/o header) to standard error stream

Parameters

  str | warning message to be printed
  prefix | prefix printed in front of the message

## ◆ quietMode()

OFBool OFConsoleApplication::quietMode | ( |  | ) | const

check quiet mode

Returns
  OFTrue if quiet mode is active, OFFalse otherwise

## ◆ setQuietMode()

void OFConsoleApplication::setQuietMode | ( | const OFBool | mode = `OFTrue` | ) |

switch on/off quiet mode

Parameters

  mode | if OFTrue all error and warning messages will be suppressed

The documentation for this class was generated from the following file:

- ofstd/include/dcmtk/ofstd/ofconapp.h

Generated on Mon Dec 15 2025 for DCMTK Version 3.7.0 by Doxygen 1.9.1