Blender V4.3
BLI_args.h File Reference

A general argument parsing module. More...

#include <stdarg.h>
#include "BLI_compiler_attrs.h"

Go to the source code of this file.

Typedefs

typedef struct bArgs bArgs
 
typedef int(* BA_ArgCallback) (int argc, const char **argv, void *data)
 
typedef void(* bArgPrintFn) (void *user_data, const char *format, va_list args)
 

Functions

struct bArgsBLI_args_create (int argc, const char **argv)
 
void BLI_args_destroy (struct bArgs *ba)
 
void BLI_args_printf (struct bArgs *ba, const char *format,...)
 
void BLI_args_print_fn_set (struct bArgs *ba, ATTR_PRINTF_FORMAT(2, 0) bArgPrintFn print_fn, void *user_data)
 
void BLI_args_pass_set (struct bArgs *ba, int current_pass)
 
void BLI_args_add (struct bArgs *ba, const char *short_arg, const char *long_arg, const char *doc, BA_ArgCallback cb, void *data)
 
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)
 
void BLI_args_parse (struct bArgs *ba, int pass, BA_ArgCallback default_cb, void *default_data)
 
void BLI_args_print_arg_doc (struct bArgs *ba, const char *arg)
 
void BLI_args_print_other_doc (struct bArgs *ba)
 
bool BLI_args_has_other_doc (const struct bArgs *ba)
 
void BLI_args_print (const struct bArgs *ba)
 

Detailed Description

A general argument parsing module.

Definition in file BLI_args.h.

Typedef Documentation

◆ BA_ArgCallback

typedef int(* BA_ArgCallback) (int argc, const char **argv, void *data)

Returns the number of extra arguments consumed by the function.

  • 0 is normal value,
  • -1 stops parsing arguments, other negative indicates skip

Definition at line 28 of file BLI_args.h.

◆ bArgPrintFn

typedef void(* bArgPrintFn) (void *user_data, const char *format, va_list args)

Definition at line 33 of file BLI_args.h.

◆ bArgs

typedef struct bArgs bArgs

Definition at line 17 of file BLI_args.h.

Function Documentation

◆ BLI_args_add()

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 241 of file BLI_args.c.

References BLI_args_add_case().

Referenced by main_args_setup().

◆ BLI_args_add_case()

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 221 of file BLI_args.c.

References internalAdd(), and internalDocs().

Referenced by BLI_args_add(), and main_args_setup().

◆ BLI_args_create()

◆ BLI_args_destroy()

void BLI_args_destroy ( struct bArgs * ba)

◆ BLI_args_has_other_doc()

bool BLI_args_has_other_doc ( const struct bArgs * ba)

Referenced by print_help().

◆ BLI_args_parse()

void BLI_args_parse ( struct bArgs * ba,
int pass,
BA_ArgCallback default_cb,
void * default_data )

Definition at line 300 of file BLI_args.c.

References bArgs::argc, bArgs::argv, BLI_assert, lookUp(), NULL, and bArgs::passes.

Referenced by main().

◆ BLI_args_pass_set()

void BLI_args_pass_set ( struct bArgs * ba,
int current_pass )

The pass to use for BLI_args_add.

Definition at line 149 of file BLI_args.c.

References BLI_assert, and bArgs::current_pass.

Referenced by main_args_setup().

◆ BLI_args_print()

void BLI_args_print ( const struct bArgs * ba)

◆ BLI_args_print_arg_doc()

void BLI_args_print_arg_doc ( struct bArgs * ba,
const char * arg )

Definition at line 266 of file BLI_args.c.

References bArgDoc::done, internalDocPrint(), and lookUp().

Referenced by print_help().

◆ BLI_args_print_fn_set()

void BLI_args_print_fn_set ( struct bArgs * ba,
ATTR_PRINTF_FORMAT(2, 0) bArgPrintFn print_fn,
void * user_data )

◆ BLI_args_print_other_doc()

void BLI_args_print_other_doc ( struct bArgs * ba)

Definition at line 279 of file BLI_args.c.

References bArgs::docs, bArgDoc::done, ListBase::first, internalDocPrint(), and bArgDoc::next.

Referenced by print_help().

◆ BLI_args_printf()

void BLI_args_printf ( struct bArgs * ba,
const char * format,
... )

Definition at line 135 of file BLI_args.c.

References bArgs::print_fn, and bArgs::print_user_data.

Referenced by internalDocPrint().