Loading...
Searching...
No Matches
ArgParse.h File Reference
`#include <Zycore/Types.h>`
`#include <Zycore/Status.h>`
`#include <Zycore/Vector.h>`
`#include <Zycore/String.h>`
Include dependency graph for ArgParse.h:

Go to the source code of this file.

## Classes

struct | ZyanArgParseDefinition_
struct | ZyanArgParseConfig_
struct | ZyanArgParseArg_

## Typedefs

typedef struct ZyanArgParseDefinition_ | ZyanArgParseDefinition
typedef struct ZyanArgParseConfig_ | ZyanArgParseConfig
typedef struct ZyanArgParseArg_ | ZyanArgParseArg

## Functions

ZYCORE_EXPORT ZyanStatus | ZyanArgParse (const ZyanArgParseConfig *cfg, ZyanVector *parsed, const char **error_token)
ZYCORE_EXPORT ZyanStatus | ZyanArgParseEx (const ZyanArgParseConfig *cfg, ZyanVector *parsed, const char **error_token, ZyanAllocator *allocator)

## Detailed Description

Implements command-line argument parsing.

## Typedef Documentation

## ZyanArgParseArg

typedef struct ZyanArgParseArg_ ZyanArgParseArg

Information about a parsed argument.

## ZyanArgParseConfig

typedef struct ZyanArgParseConfig_ ZyanArgParseConfig

Configuration for argument parsing.

## ZyanArgParseDefinition

typedef struct ZyanArgParseDefinition_ ZyanArgParseDefinition

Definition of a single argument.

## Function Documentation

## ZyanArgParse()

ZYCORE_EXPORT ZyanStatus ZyanArgParse | ( | const ZyanArgParseConfig * | cfg,
|  | ZyanVector * | parsed,
|  | const char ** | error_token )

Parse arguments according to a ZyanArgParseConfig definition.

Parameters

  cfg | Argument parser config to use.
  parsed | Receives the parsed output. Vector of ZyanArgParseArg. Ownership is transferred to the user. Input is expected to be uninitialized. On error, the vector remains uninitialized.
  error_token | On error, if it makes sense, receives the argument fragment causing the error. Optional, may be ZYAN_NULL. The pointer borrows into the cfg struct and doesn't have to be freed by the user.

Returns
  A ZyanStatus status determining whether the parsing succeeded.

## ZyanArgParseEx()

ZYCORE_EXPORT ZyanStatus ZyanArgParseEx | ( | const ZyanArgParseConfig * | cfg,
|  | ZyanVector * | parsed,
|  | const char ** | error_token,
|  | ZyanAllocator * | allocator )

Parse arguments according to a ZyanArgParseConfig definition.

This version allows specification of a custom memory allocator and thus supports no-libc.

Parameters

  cfg | Argument parser config to use.
  parsed | Receives the parsed output. Vector of ZyanArgParseArg. Ownership is transferred to the user. Input is expected to be uninitialized. On error, the vector remains uninitialized.
  error_token | On error, if it makes sense, receives the argument fragment causing the error. Optional, may be ZYAN_NULL. The pointer borrows into the cfg struct and doesn't have to be freed by the user.
  allocator | The ZyanAllocator to be used for allocating the output vector's data.

Returns
  A ZyanStatus status determining whether the parsing succeeded.