libsc 2.8.5.210-64a7
The SC library provides support for parallel scientific applications.
sc_options.h
Go to the documentation of this file.
1/*
2 This file is part of the SC Library.
3 The SC Library provides support for parallel scientific applications.
4
5 Copyright (C) 2010 The University of Texas System
6 Additional copyright (C) 2011 individual authors
7
8 The SC Library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 The SC Library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with the SC Library; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 02110-1301, USA.
22*/
23
24#ifndef SC_OPTIONS_H
25#define SC_OPTIONS_H
26
83#include <sc_keyvalue.h>
84
85SC_EXTERN_C_BEGIN;
86
88typedef struct sc_options sc_options_t;
89
98typedef int (*sc_options_callback_t) (sc_options_t * opt,
99 const char *opt_arg,
100 void *data);
101
107sc_options_t *sc_options_new (const char *program_path);
108
118
124
137 int space_type, int space_help);
138
151 int opt_char,
152 const char *opt_name,
153 int *variable,
154 const char *help_string);
155
169 int opt_char,
170 const char *opt_name,
171 int *variable, int init_value,
172 const char *help_string);
173
183 int opt_char,
184 const char *opt_name,
185 int *variable, int init_value,
186 const char *help_string);
187
198 int opt_char,
199 const char *opt_name,
200 size_t *variable,
201 size_t init_value,
202 const char *help_string);
203
214 int opt_char,
215 const char *opt_name,
216 double *variable,
217 double init_value,
218 const char *help_string);
219
230 int opt_char,
231 const char *opt_name,
232 const char **variable,
233 const char *init_value,
234 const char *help_string);
235
246 int opt_char,
247 const char *opt_name,
248 const char *help_string);
249
264 int opt_char,
265 const char *opt_name,
266 const char *help_string);
267
284 int opt_char,
285 const char *opt_name,
286 int has_arg,
288 void *data,
289 const char *help_string);
290
308 int opt_char,
309 const char *opt_name,
310 int *variable,
311 const char *init_value,
312 sc_keyvalue_t * keyvalue,
313 const char *help_string);
314
326 sc_options_t * subopt,
327 const char *prefix);
328
344void sc_options_print_usage (int package_id, int log_priority,
345 sc_options_t * opt,
346 const char *arg_usage);
347
358void sc_options_print_summary (int package_id,
359 int log_priority,
360 sc_options_t * opt);
361
372int sc_options_load (int package_id, int err_priority,
373 sc_options_t * opt, const char *file);
374
386int sc_options_load_ini (int package_id, int err_priority,
387 sc_options_t * opt,
388 const char *inifile, void *re);
389
401int sc_options_load_json (int package_id, int err_priority,
402 sc_options_t * opt,
403 const char *jsonfile, void *re);
404
417int sc_options_save (int package_id, int err_priority,
418 sc_options_t * opt, const char *inifile);
419
429int sc_options_load_args (int package_id, int err_priority,
430 sc_options_t * opt,
431 const char *inifile);
432
444int sc_options_parse (int package_id, int err_priority,
445 sc_options_t * opt, int argc,
446 char **argv);
447
448SC_EXTERN_C_END;
449
450#endif /* !SC_OPTIONS_H */
This file provides a lookup structure for key-value pairs.
struct sc_keyvalue sc_keyvalue_t
The key-value container is an opaque structure.
Definition: sc_keyvalue.h:47
void sc_options_destroy_deep(sc_options_t *opt)
Destroy the options structure and all allocated structures contained.
void sc_options_add_switch(sc_options_t *opt, int opt_char, const char *opt_name, int *variable, const char *help_string)
Add a switch option.
void sc_options_add_size_t(sc_options_t *opt, int opt_char, const char *opt_name, size_t *variable, size_t init_value, const char *help_string)
Add an option that takes a size_t argument.
void sc_options_add_bool(sc_options_t *opt, int opt_char, const char *opt_name, int *variable, int init_value, const char *help_string)
Add a boolean option.
void sc_options_print_usage(int package_id, int log_priority, sc_options_t *opt, const char *arg_usage)
Print a usage message.
void sc_options_add_callback(sc_options_t *opt, int opt_char, const char *opt_name, int has_arg, sc_options_callback_t fn, void *data, const char *help_string)
Add an option that calls a user-defined function when parsed.
int sc_options_save(int package_id, int err_priority, sc_options_t *opt, const char *inifile)
Save all options and arguments to a file in .ini format.
void sc_options_add_keyvalue(sc_options_t *opt, int opt_char, const char *opt_name, int *variable, const char *init_value, sc_keyvalue_t *keyvalue, const char *help_string)
Add an option that takes string keys into a lookup table of integers.
void sc_options_print_summary(int package_id, int log_priority, sc_options_t *opt)
Print a summary of all option values.
int sc_options_load_args(int package_id, int err_priority, sc_options_t *opt, const char *inifile)
Load a file in .ini format and update entries found under [Arguments].
void sc_options_add_int(sc_options_t *opt, int opt_char, const char *opt_name, int *variable, int init_value, const char *help_string)
Add an option that takes an integer argument.
void sc_options_destroy(sc_options_t *opt)
Destroy the options structure.
int sc_options_load_ini(int package_id, int err_priority, sc_options_t *opt, const char *inifile, void *re)
Load a file in .ini format and update entries found under [Options].
void sc_options_add_inifile(sc_options_t *opt, int opt_char, const char *opt_name, const char *help_string)
Add an option to read in a file in .ini format.
struct sc_options sc_options_t
The options data structure is opaque.
Definition: sc_options.h:88
int(* sc_options_callback_t)(sc_options_t *opt, const char *opt_arg, void *data)
This callback can be invoked with sc_options_parse.
Definition: sc_options.h:98
void sc_options_add_string(sc_options_t *opt, int opt_char, const char *opt_name, const char **variable, const char *init_value, const char *help_string)
Add a string option.
void sc_options_add_double(sc_options_t *opt, int opt_char, const char *opt_name, double *variable, double init_value, const char *help_string)
Add an option that takes a double argument.
int sc_options_load(int package_id, int err_priority, sc_options_t *opt, const char *file)
Load a file in the default format and update option values.
void sc_options_set_spacing(sc_options_t *opt, int space_type, int space_help)
Set the spacing for sc_options_print_summary.
void sc_options_add_suboptions(sc_options_t *opt, sc_options_t *subopt, const char *prefix)
Copy one set of options to another as a subset, with a prefix.
int sc_options_load_json(int package_id, int err_priority, sc_options_t *opt, const char *jsonfile, void *re)
Load a file in JSON format and update entries from object "Options".
sc_options_t * sc_options_new(const char *program_path)
Create an empty options structure.
int sc_options_parse(int package_id, int err_priority, sc_options_t *opt, int argc, char **argv)
Parse command line options.
void sc_options_add_jsonfile(sc_options_t *opt, int opt_char, const char *opt_name, const char *help_string)
Add an option to read in a file in JSON format.