Debian Codegraph @

u8stream/include/u8/u8_error_info.h

raw symbols SCIP
1 /* File: u8_error_info.h; Copyright and License: see below */
2
3 #ifndef U8_ERROR_INFO_H
4 #define U8_ERROR_INFO_H
5
6 /* public file for the doxygen documentation: */
7 /*!
8 * \file
9 * \brief Defines a struct defining detailed error information
10 */
11
12 #include "u8/u8_error.h"
13 #include "u8/u8_error_info_unit.h"
14 #include <stdbool.h>
15 #include <stdint.h>
16
17 /*!
18 * \brief constants for max string sizes
19 */
20 enum u8_error_info_max_enum {
21 U8_ERROR_INFO_MAX_NAME_SIZE = 48,
22 };
23
24 /*!
25 * \brief struct of error code and additional information
26 *
27 * This struct is intended to be provided as out-parameter (pointer-to-struct) to a function call.
28 *
29 * In case of an error, the function shall return an error code and fill in the u8_error_info_struct.
30 * There is no need that return error code and error info refer to the same error code, especially since
31 * the return error may be a bitwise-or of several errors whereas the error info struct refers to exactly one error.
32 * In case of an error, a function may return an error code as return value and nonetheless set u8_error_info_t.error
33 * to U8_ERROR_NONE (e.g. when there is no additional information available).
34 */
35 struct u8_error_info_struct {
36 u8_error_t error;
37 u8_error_info_unit_t unit;
38 int32_t position;
39 char name[U8_ERROR_INFO_MAX_NAME_SIZE];
40 };
41
42 typedef struct u8_error_info_struct u8_error_info_t;
43
44 /*!
45 * \brief initializes the u8_error_info_t struct to no error
46 *
47 * \param this_ pointer to own object attributes
48 */
49 static inline void u8_error_info_init_void ( u8_error_info_t *this_ );
50
51 /*!
52 * \brief initializes the u8_error_info_t struct with an error code
53 *
54 * \param this_ pointer to own object attributes
55 * \param error error code to set
56 */
57 static inline void u8_error_info_init ( u8_error_info_t *this_, u8_error_t error );
58
59 /*!
60 * \brief initializes the u8_error_info_t struct with an error code and a position
61 *
62 * \param this_ pointer to own object attributes
63 * \param error error code to set
64 * \param line line position of origin
65 */
66 static inline void u8_error_info_init_line ( u8_error_info_t *this_, u8_error_t error, int32_t line );
67
68 /*!
69 * \brief initializes the u8_error_info_t struct with an error code and a position and a name
70 *
71 * \param this_ pointer to own object attributes
72 * \param error error code to set
73 * \param name name of origin-object
74 */
75 static inline void u8_error_info_init_name ( u8_error_info_t *this_, u8_error_t error, const char* name );
76
77 /*!
78 * \brief initializes the u8_error_info_t struct with an error code and a position and a name
79 *
80 * \param this_ pointer to own object attributes
81 * \param error error code to set
82 * \param line line position of origin
83 * \param name name of origin-object
84 */
85 static inline void u8_error_info_init_line_name ( u8_error_info_t *this_, u8_error_t error, int32_t line, const char* name );
86
87 /*!
88 * \brief destroys the u8_error_info_t struct
89 *
90 * \param this_ pointer to own object attributes
91 */
92 static inline void u8_error_info_destroy ( u8_error_info_t *this_ );
93
94 /*!
95 * \brief checks if error is set (not void)
96 *
97 * \param this_ pointer to own object attributes
98 * \return true if there is an error code unequal to U8_ERROR_NONE
99 */
100 static inline bool u8_error_info_is_error ( const u8_error_info_t *this_ );
101
102 /*!
103 * \brief gets the error code
104 *
105 * \param this_ pointer to own object attributes
106 * \return the error code
107 */
108 static inline u8_error_t u8_error_info_get_error ( const u8_error_info_t *this_ );
109
110 /*!
111 * \brief gets the error unit
112 *
113 * \param this_ pointer to own object attributes
114 * \return the semantics and unit of additional data
115 */
116 static inline u8_error_info_unit_t u8_error_info_get_unit ( const u8_error_info_t *this_ );
117
118 /*!
119 * \brief gets the error line
120 *
121 * \param this_ pointer to own object attributes
122 * \return the origin line of the error
123 */
124 static inline int32_t u8_error_info_get_line ( const u8_error_info_t *this_ );
125
126 /*!
127 * \brief gets the error-origin name
128 *
129 * \param this_ pointer to own object attributes
130 * \return the object name at the error origin
131 */
132 static inline const char* u8_error_info_get_name ( const u8_error_info_t *this_ );
133
134 #include "u8/u8_error_info.inl"
135
136 #endif /* U8_ERROR_INFO_H */
137
138
139 /*
140 Copyright 2022-2026 Andreas Warnke
141
142 Licensed under the Apache License, Version 2.0 (the "License");
143 you may not use this file except in compliance with the License.
144 You may obtain a copy of the License at
145
146 http://www.apache.org/licenses/LICENSE-2.0
147
148 Unless required by applicable law or agreed to in writing, software
149 distributed under the License is distributed on an "AS IS" BASIS,
150 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
151 See the License for the specific language governing permissions and
152 limitations under the License.
153 */