Loading HTML parameters into a program

The simplest way to load the parameters is to use one of the load_from_args() functions. These functions parse the command line for any command line arguments specific to TDRP and act on them. These functions are suitable only in the standard case of a single TDRP module or class per program. For multiple modules or classes, refer to the API pages.

Using C API:

_tdrp_load_from_args()

The following code fragment shows how to load the parameters into the params struct. It is assumed that the override list has already been initialized and loaded.

  char *params_file_path = NULL;
  tdrp_override_t override;
  _tdrp_struct params;   /* parameter struct */
  if (_tdrp_load_from_args(argc, argv, ¶ms,
			   override.list, ¶ms_file_path)) {
    fprintf(stderr, "ERROR - Problems with params file '%s'\n",
	    params_file_path);
    return(-1);
  }
After loading, the parameters are available through the struct params.

Using C++ API:

loadFromArgs()

The following code fragment shows how to load the parameters into the Params class. It is assumed that the override list has already been initialized and loaded.

  Params *params = new Params();
  char *paramsPath = "unknown";
  if (params->loadFromArgs(argc, argv,
                           _args->override.list,
                           &_paramsPath)) {
    fprintf(stderr, "ERROR: problems with TDRP parameters\n");
    return;
  }
After loading, the parameters are available through the object params.

Using Old C API:

TDRP_load_from_args()

The following code fragment shows how to load the parameters into the params struct. It is assumed that the override list has already been initialized and loaded.

  char *params_file_path = NULL;
  tdrp_override_t override;
  TDRPtable *table;                  /* TDRP parsing table */
  tdrp_example_tdrp_struct params;   /* parameter struct */

  table = tdrp_example_tdrp_init(¶ms);
  if (TDRP_load_from_args(argc, argv,
			  table, ¶ms,
			  override.list, ¶ms_file_path)) {
    fprintf(stderr, "ERROR - Problems with params file '%s'\n",
	    params_file_path);
    return(-1);
  }
After loading, the parameters are available through the struct params.