|
Blender V5.0
|
A general argument parsing module. More...
#include <cctype>#include <cstdio>#include "MEM_guardedalloc.h"#include "BLI_args.h"#include "BLI_ghash.h"#include "BLI_listbase.h"#include "BLI_string.h"#include "BLI_utildefines.h"Go to the source code of this file.
Classes | |
| struct | bArgDoc |
| struct | bAKey |
| struct | bArgument |
| struct | bArgs |
Macros | |
| #define | USE_DUPLICATE_ARG_WORKAROUND |
Functions | |
| static uint | case_strhash (const void *ptr) |
| static uint | keyhash (const void *ptr) |
| static bool | keycmp (const void *a, const void *b) |
| static bArgument * | lookUp (bArgs *ba, const char *arg, int pass, int case_str) |
| static void | args_print_wrapper (void *, const char *format, va_list args) |
| bArgs * | BLI_args_create (int argc, const char **argv) |
| void | BLI_args_destroy (bArgs *ba) |
| void | BLI_args_printf (bArgs *ba, const char *format,...) |
| void | BLI_args_print_fn_set (bArgs *ba, bArgPrintFn print_fn, void *user_data) |
| void | BLI_args_pass_set (bArgs *ba, int current_pass) |
| void | BLI_args_print (const bArgs *ba) |
| static bArgDoc * | internalDocs (bArgs *ba, const char *short_arg, const char *long_arg, const char *doc) |
| static void | internalAdd (bArgs *ba, const char *arg, int case_str, BA_ArgCallback cb, void *data, bArgDoc *d) |
| void | BLI_args_add_case (bArgs *ba, const char *short_arg, int short_case, const char *long_arg, int long_case, const char *doc, BA_ArgCallback cb, void *data) |
| void | BLI_args_add (bArgs *ba, const char *short_arg, const char *long_arg, const char *doc, BA_ArgCallback cb, void *data) |
| static void | internalDocPrint (bArgs *ba, bArgDoc *d) |
| void | BLI_args_print_arg_doc (bArgs *ba, const char *arg) |
| void | BLI_args_print_other_doc (bArgs *ba) |
| bool | BLI_args_has_other_doc (const bArgs *ba) |
| void | BLI_args_parse (bArgs *ba, int pass, BA_ArgCallback default_cb, void *default_data) |
Variables | |
| static char | NO_DOCS [] = "NO DOCUMENTATION SPECIFIED" |
A general argument parsing module.
Definition in file BLI_args.cc.
| #define USE_DUPLICATE_ARG_WORKAROUND |
Needed so printing --help doesn't cause a naming collision with: The -a argument which is used twice. This works for argument parsing because the arguments are used in different passes, but causes problems when printing documentation which matches all passes.
NOTE(@ideasman42): Longer term we might want to avoid duplicating arguments because it's confusing and not especially helpful.
Definition at line 30 of file BLI_args.cc.
|
static |
Default print function.
Definition at line 119 of file BLI_args.cc.
References args_print_wrapper().
Referenced by args_print_wrapper(), and BLI_args_create().
| void BLI_args_add | ( | struct bArgs * | ba, |
| const char * | short_arg, | ||
| const char * | long_arg, | ||
| const char * | doc, | ||
| BA_ArgCallback | cb, | ||
| void * | data ) |
Pass starts at 1, -1 means valid all the time short_arg or long_arg can be null to specify no short or long versions
Definition at line 262 of file BLI_args.cc.
References BLI_args_add_case(), and data.
Referenced by main_args_setup().
| void BLI_args_add_case | ( | struct bArgs * | ba, |
| const char * | short_arg, | ||
| int | short_case, | ||
| const char * | long_arg, | ||
| int | long_case, | ||
| const char * | doc, | ||
| BA_ArgCallback | cb, | ||
| void * | data ) |
Short_case and long_case specify if those arguments are case specific
Definition at line 242 of file BLI_args.cc.
References data, internalAdd(), and internalDocs().
Referenced by BLI_args_add(), and main_args_setup().
| bArgs * BLI_args_create | ( | int | argc, |
| const char ** | argv ) |
Definition at line 124 of file BLI_args.cc.
References bArgs::argc, args_print_wrapper(), bArgs::argv, BLI_args_print_fn_set(), BLI_ghash_new(), BLI_listbase_clear(), bArgs::current_pass, bArgs::docs, bArgs::items, keycmp(), keyhash(), MEM_calloc_arrayN(), MEM_callocN(), bArgs::pass_max, and bArgs::passes.
Referenced by main(), and main_args_help_as_string().
| void BLI_args_destroy | ( | bArgs * | ba | ) |
Definition at line 144 of file BLI_args.cc.
References BLI_freelistN(), BLI_ghash_free(), bArgs::docs, bArgs::items, MEM_freeN(), and bArgs::passes.
Referenced by callback_main_atexit(), and main_args_help_as_string().
| bool BLI_args_has_other_doc | ( | const bArgs * | ba | ) |
Definition at line 326 of file BLI_args.cc.
References bArgs::docs, and LISTBASE_FOREACH.
| void BLI_args_parse | ( | bArgs * | ba, |
| int | pass, | ||
| BA_ArgCallback | default_cb, | ||
| void * | default_data ) |
Definition at line 336 of file BLI_args.cc.
References bArgs::argc, bArgs::argv, BLI_assert, bArgument::data, data, bArgument::func, i, bArgument::key, lookUp(), bAKey::pass, and bArgs::passes.
Referenced by main().
| void BLI_args_pass_set | ( | struct bArgs * | ba, |
| int | current_pass ) |
The pass to use for BLI_args_add.
Definition at line 166 of file BLI_args.cc.
References BLI_assert, bArgs::current_pass, and bArgs::pass_max.
Referenced by main_args_setup().
| void BLI_args_print | ( | const bArgs * | ba | ) |
Definition at line 176 of file BLI_args.cc.
References bArgs::argc, bArgs::argv, i, and printf.
| void BLI_args_print_arg_doc | ( | bArgs * | ba, |
| const char * | arg ) |
Definition at line 287 of file BLI_args.cc.
References bArgument::doc, bArgDoc::done, internalDocPrint(), lookUp(), and bArgs::pass_max.
Referenced by print_help().
| void BLI_args_print_fn_set | ( | bArgs * | ba, |
| bArgPrintFn | print_fn, | ||
| void * | user_data ) |
Definition at line 160 of file BLI_args.cc.
References bArgs::print_fn, and bArgs::print_user_data.
Referenced by BLI_args_create().
| void BLI_args_print_other_doc | ( | bArgs * | ba | ) |
Definition at line 317 of file BLI_args.cc.
References bArgs::docs, internalDocPrint(), and LISTBASE_FOREACH.
Referenced by print_help().
| void BLI_args_printf | ( | bArgs * | ba, |
| const char * | format, | ||
| ... ) |
Definition at line 152 of file BLI_args.cc.
References bArgs::print_fn, and bArgs::print_user_data.
Referenced by internalDocPrint().
|
static |
|
static |
Definition at line 206 of file BLI_args.cc.
References bAKey::arg, BLI_ghash_insert(), bAKey::case_str, bArgs::current_pass, bArgument::data, data, bArgument::doc, bArgument::func, bArgs::items, bArgument::key, lookUp(), MEM_callocN(), bAKey::pass, and printf.
Referenced by BLI_args_add_case().
Definition at line 272 of file BLI_args.cc.
References BLI_args_printf(), bArgDoc::documentation, bArgDoc::long_arg, and bArgDoc::short_arg.
Referenced by BLI_args_print_arg_doc(), and BLI_args_print_other_doc().
|
static |
Definition at line 184 of file BLI_args.cc.
References BLI_addtail(), bArgs::docs, bArgDoc::documentation, bArgDoc::long_arg, MEM_callocN(), NO_DOCS, and bArgDoc::short_arg.
Referenced by BLI_args_add_case().
|
static |
Definition at line 93 of file BLI_args.cc.
References bAKey::arg, b, BLI_ghashutil_intcmp(), BLI_strcasecmp(), bAKey::case_str, bAKey::pass, and STREQ.
Referenced by BLI_args_create().
|
static |
Definition at line 87 of file BLI_args.cc.
References bAKey::arg, case_strhash(), and ptr.
Referenced by BLI_args_create().
Definition at line 106 of file BLI_args.cc.
References bAKey::arg, BLI_ghash_lookup(), bAKey::case_str, bArgs::items, and bAKey::pass.
Referenced by BLI_args_parse(), BLI_args_print_arg_doc(), and internalAdd().
|
static |
Definition at line 32 of file BLI_args.cc.
Referenced by internalDocs().