TR_datastructures 0.1.0
A generic C data structures library
Loading...
Searching...
No Matches
tr_result.h
Go to the documentation of this file.
1/**
2 * @file tr_result.h
3 * @brief Library wide error code definitions for the tr_datastructures library
4 */
5
6/*******************************************************************************************************
7 * NAME: tr_result.h
8 *
9 * PURPOSE: Defines the tr_result_t error code enum for the tr_datastructures library
10 *
11 * GLOBAL VARIABLES: None
12 *
13 * DEVELOPMENT HISTORY:
14 *
15 * Date Author Change Id Release Description Of Change
16 * ---------- --------------- --------- ------- -----------------------------------
17 * 28-05-2026 Tiago Rodrigues 1 File preparation
18 *
19 *******************************************************************************************************/
20#ifndef TR_RESULT_H
21#define TR_RESULT_H
22
23/* 0 copyright/licensing */
24/*******************************************************************************************************
25 *
26 * This is free and unencumbered software released into the public domain (Unlicense).
27 *
28 ********************************************************************************************************/
29
30#ifdef __cplusplus
31extern "C"
32{
33#endif
34
35/* 1 includes */
36/*****************************************************/
37/*****************************************************/
38
39/* 2 defines */
40/*****************************************************/
41/*****************************************************/
42
43/* 3 external declarations */
44/*****************************************************/
45/*****************************************************/
46
47/* 4 typedefs */
48/*****************************************************/
49
50/**
51 * @brief Library wide error code returned by all API functions
52 *
53 * Every public API function returns a value of this type.
54 * @c TR_OK indicates success. Any other value indicates a specific
55 * failure condition that the caller should handle.
56 *
57 * Example usage:
58 * @code
59 * struct stack *p_stack = NULL;
60 * tr_result_t res = TR_OK;
61 *
62 * res = tr_stack_create(sizeof(int), 10, TR_STACK_ARRAY_DYNAMIC, &p_stack);
63 * if (TR_OK != res)
64 * {
65 * // handle error
66 * }
67 * @endcode
68 */
69typedef enum tr_result
70{
71 TR_OK = 0, /**< Operation completed successfully */
72 TR_ERR_NULL = 1, /**< NULL pointer passed where a valid pointer expected */
73 TR_ERR_ALLOC = 2, /**< Memory allocation failed */
74 TR_ERR_EMPTY = 3, /**< Operation failed because structure is empty */
75 TR_ERR_FULL = 4, /**< Operation failed because structure is full */
76 TR_ERR_INVALID = 5, /**< Invalid argument (e.g. size of 0) */
77 TR_ERR_NOT_FOUND = 6, /**< Element not found in the structure */
78 TR_ERR_DUPLICATE = 7, /**< Duplicate element detected */
79 TR_ERR_OUT_OF_RANGE = 8 /**< Index or position is out of valid range */
81
82/*****************************************************/
83
84/* 5 global variable declarations */
85/*****************************************************/
86/*****************************************************/
87
88/* 6 function prototypes */
89/*****************************************************/
90/*****************************************************/
91
92#ifdef __cplusplus
93}
94#endif
95
96#endif /* TR_RESULT_H */
tr_result
Library wide error code returned by all API functions.
Definition tr_result.h:70
@ TR_ERR_OUT_OF_RANGE
Definition tr_result.h:79
@ TR_ERR_ALLOC
Definition tr_result.h:73
@ TR_ERR_DUPLICATE
Definition tr_result.h:78
@ TR_ERR_INVALID
Definition tr_result.h:76
@ TR_OK
Definition tr_result.h:71
@ TR_ERR_EMPTY
Definition tr_result.h:74
@ TR_ERR_FULL
Definition tr_result.h:75
@ TR_ERR_NOT_FOUND
Definition tr_result.h:77
@ TR_ERR_NULL
Definition tr_result.h:72
enum tr_result tr_result_t
Library wide error code returned by all API functions.