Path: blob/main/contrib/libcbor/src/cbor/internal/stack.h
39566 views
/*1* Copyright (c) 2014-2020 Pavel Kalvoda <[email protected]>2*3* libcbor is free software; you can redistribute it and/or modify4* it under the terms of the MIT license. See LICENSE for details.5*/67#ifndef LIBCBOR_STACK_H8#define LIBCBOR_STACK_H910#include "cbor/common.h"1112#ifdef __cplusplus13extern "C" {14#endif1516/** Simple stack record for the parser */17struct _cbor_stack_record {18/** Pointer to the parent stack frame */19struct _cbor_stack_record *lower;20/** Item under construction */21cbor_item_t *item;22/**23* How many outstanding subitems are expected.24*25* For example, when we see a new definite array, `subitems` is initialized to26* the array length. With every item added, the counter is decreased. When it27* reaches zero, the stack is popped and the complete item is propagated28* upwards.29*/30size_t subitems;31};3233/** Stack handle - contents and size */34struct _cbor_stack {35struct _cbor_stack_record *top;36size_t size;37};3839_CBOR_NODISCARD40struct _cbor_stack _cbor_stack_init(void);4142void _cbor_stack_pop(struct _cbor_stack *);4344_CBOR_NODISCARD45struct _cbor_stack_record *_cbor_stack_push(struct _cbor_stack *, cbor_item_t *,46size_t);4748#ifdef __cplusplus49}50#endif5152#endif // LIBCBOR_STACK_H535455