jx_match.h
Go to the documentation of this file.
/*
Copyright (C) 2022 The University of Notre Dame
This software is distributed under the GNU General Public License.
See the file COPYING for details.
*/
#ifndef JX_MATCH_H
#define JX_MATCH_H
#include "jx.h"
#ifndef JX_ANY
#define JX_ANY -1
#endif
/*
* Macro to test if we're using a GNU C compiler of a specific vintage
* or later, for e.g. features that appeared in a particular version
* of GNU C. Usage:
*
* #if __GNUC_PREREQ__(major, minor)
* ...cool feature...
* #else
* ...delete feature...
* #endif
*/
#ifndef __GNUC_PREREQ__
#ifdef __GNUC__
#define __GNUC_PREREQ__(x, y) \
((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) || \
(__GNUC__ > (x)))
#else
#define __GNUC_PREREQ__(x, y) 0
#endif
#endif
#ifndef __wur
#if __GNUC_PREREQ__(3, 4)
#define __wur __attribute__((warn_unused_result))
#else
#define __wur
#endif
#endif
#ifndef __sentinel
#if __GNUC_PREREQ__(4, 0)
#define __sentinel __attribute__((sentinel))
#else
#define __sentinel
#endif
#endif
int jx_match_boolean(struct jx *j, int *v) __wur;
int jx_match_integer(struct jx *j, jx_int_t *v) __wur;
int jx_match_double(struct jx *j, double *v) __wur;
int jx_match_string(struct jx *j, char **v) __wur;
int jx_match_symbol(struct jx *j, char **v) __wur;
int jx_match_array(struct jx *j, ...) __wur __sentinel;
#endif
jx.h
JSON Expressions (JX) library.
jx_match_symbol
int jx_match_symbol(struct jx *j, char **v) __wur
Unwrap a symbol value.
jx_match_string
int jx_match_string(struct jx *j, char **v) __wur
Unwrap a string value.
jx_match_boolean
int jx_match_boolean(struct jx *j, int *v) __wur
Unwrap a boolean value.
jx_match_array
int jx_match_array(struct jx *j,...) __wur __sentinel
Destructure an array.
jx_match_double
int jx_match_double(struct jx *j, double *v) __wur
Unwrap a double value.
jx_match_integer
int jx_match_integer(struct jx *j, jx_int_t *v) __wur
Unwrap an integer value.
jx
JX value representing any expression type.
Definition jx.h:117