---
name: "ArgParse.h"
section: "3"
platform: "linux"
package: "libzycore-doc"
version: "1.5.2-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/ArgParse.h"
---

# ArgParse.h(3)

## NAME

include/Zycore/ArgParse.h

## SYNOPSIS

`#include <Zycore/Types.h>`\
 `#include <Zycore/Status.h>`\
 `#include <Zycore/Vector.h>`\
 `#include <Zycore/String.h>`\

### 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

### typedef struct ZyanArgParseArg\_ ZyanArgParseArg

Information about a parsed argument.

### typedef struct ZyanArgParseConfig\_ ZyanArgParseConfig

Configuration for argument parsing.

### typedef struct ZyanArgParseDefinition\_ ZyanArgParseDefinition

Definition of a single argument.

## Function Documentation

### 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.

### 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.

## Author

Generated automatically by Doxygen for Zycore from the source code.
