|
138 | 138 | #define LVARRAY_ASSERT_MSG( EXP, MSG ) ((void) 0) |
139 | 139 | #endif |
140 | 140 |
|
| 141 | +/** |
| 142 | + * @brief Conditionally throw an exception. |
| 143 | + * @param EXP an expression that will be evaluated as a predicate |
| 144 | + * @param MSG a message to log (any expression that can be stream inserted) |
| 145 | + * @param TYPE the type of exception to throw |
| 146 | + */ |
141 | 147 | #define LVARRAY_THROW_IF( EXP, MSG, TYPE ) \ |
142 | 148 | do \ |
143 | 149 | { \ |
|
221 | 227 | " " << #lhs << " = " << lhs << "\n" << \ |
222 | 228 | " " << #rhs << " = " << rhs << "\n" ) |
223 | 229 |
|
| 230 | +/** |
| 231 | + * @brief Throw an exception if @p lhs @p OP @p rhs. |
| 232 | + * @param lhs The left side of the operation. |
| 233 | + * @param OP The operation to apply. |
| 234 | + * @param NOP The opposite of @p OP, used in the message. |
| 235 | + * @param rhs The right side of the operation. |
| 236 | + * @param msg The message to diplay. |
| 237 | + * @param TYPE the type of exception to throw. |
| 238 | + */ |
224 | 239 | #define LVARRAY_THROW_IF_OP_MSG( lhs, OP, NOP, rhs, msg, TYPE ) \ |
225 | 240 | LVARRAY_THROW_IF( lhs OP rhs, \ |
226 | 241 | msg << "\n" << \ |
|
236 | 251 | */ |
237 | 252 | #define LVARRAY_ERROR_IF_EQ_MSG( lhs, rhs, msg ) LVARRAY_ERROR_IF_OP_MSG( lhs, ==, !=, rhs, msg ) |
238 | 253 |
|
| 254 | +/** |
| 255 | + * @brief Throw an exception if two values are equal. |
| 256 | + * @param lhs expression to be evaluated and used as left-hand side in comparison |
| 257 | + * @param rhs expression to be evaluated and used as right-hand side in comparison |
| 258 | + * @param msg a message to log (any expression that can be stream inserted) |
| 259 | + * @param TYPE the type of exception to throw |
| 260 | + */ |
239 | 261 | #define LVARRAY_THROW_IF_EQ_MSG( lhs, rhs, msg, TYPE ) LVARRAY_THROW_IF_OP_MSG( lhs, ==, !=, rhs, msg, TYPE ) |
240 | 262 |
|
241 | 263 | /** |
|
245 | 267 | */ |
246 | 268 | #define LVARRAY_ERROR_IF_EQ( lhs, rhs ) LVARRAY_ERROR_IF_EQ_MSG( lhs, rhs, "" ) |
247 | 269 |
|
| 270 | +/** |
| 271 | + * @brief Throw an exception if two values are equal. |
| 272 | + * @param lhs expression to be evaluated and used as left-hand side in comparison |
| 273 | + * @param rhs expression to be evaluated and used as right-hand side in comparison |
| 274 | + * @param TYPE the type of exception to throw |
| 275 | + */ |
248 | 276 | #define LVARRAY_THROW_IF_EQ( lhs, rhs, TYPE ) LVARRAY_THROW_IF_EQ_MSG( lhs, rhs, "", TYPE ) |
249 | 277 |
|
250 | 278 | /** |
|
255 | 283 | */ |
256 | 284 | #define LVARRAY_ERROR_IF_NE_MSG( lhs, rhs, msg ) LVARRAY_ERROR_IF_OP_MSG( lhs, !=, ==, rhs, msg ) |
257 | 285 |
|
| 286 | +/** |
| 287 | + * @brief Throw an exception if two values are not equal. |
| 288 | + * @param lhs expression to be evaluated and used as left-hand side in comparison |
| 289 | + * @param rhs expression to be evaluated and used as right-hand side in comparison |
| 290 | + * @param msg a message to log (any expression that can be stream inserted) |
| 291 | + * @param TYPE the type of exception to throw |
| 292 | + */ |
258 | 293 | #define LVARRAY_THROW_IF_NE_MSG( lhs, rhs, msg, TYPE ) LVARRAY_THROW_IF_OP_MSG( lhs, !=, ==, rhs, msg, TYPE ) |
259 | 294 |
|
260 | 295 | /** |
|
264 | 299 | */ |
265 | 300 | #define LVARRAY_ERROR_IF_NE( lhs, rhs ) LVARRAY_ERROR_IF_NE_MSG( lhs, rhs, "" ) |
266 | 301 |
|
| 302 | +/** |
| 303 | + * @brief Throw an exception if two values are not equal. |
| 304 | + * @param lhs expression to be evaluated and used as left-hand side in comparison |
| 305 | + * @param rhs expression to be evaluated and used as right-hand side in comparison |
| 306 | + * @param TYPE the type of exception to throw |
| 307 | + */ |
267 | 308 | #define LVARRAY_THROW_IF_NE( lhs, rhs, TYPE ) LVARRAY_THROW_IF_NE_MSG( lhs, rhs, "", TYPE ) |
268 | 309 |
|
269 | 310 | /** |
|
274 | 315 | */ |
275 | 316 | #define LVARRAY_ERROR_IF_GT_MSG( lhs, rhs, msg ) LVARRAY_ERROR_IF_OP_MSG( lhs, >, <=, rhs, msg ) |
276 | 317 |
|
| 318 | +/** |
| 319 | + * @brief Throw an exception if one value compares greater than the other. |
| 320 | + * @param lhs expression to be evaluated and used as left-hand side in comparison |
| 321 | + * @param rhs expression to be evaluated and used as right-hand side in comparison |
| 322 | + * @param msg a message to log (any expression that can be stream inserted) |
| 323 | + * @param TYPE the type of exception to throw |
| 324 | + */ |
277 | 325 | #define LVARRAY_THROW_IF_GT_MSG( lhs, rhs, msg, TYPE ) LVARRAY_THROW_IF_OP_MSG( lhs, >, <=, rhs, msg, TYPE ) |
278 | 326 |
|
279 | 327 | /** |
|
283 | 331 | */ |
284 | 332 | #define LVARRAY_ERROR_IF_GT( lhs, rhs ) LVARRAY_ERROR_IF_GT_MSG( lhs, rhs, "" ) |
285 | 333 |
|
| 334 | +/** |
| 335 | + * @brief Throw an exception if one value compares greater than the other. |
| 336 | + * @param lhs expression to be evaluated and used as left-hand side in comparison |
| 337 | + * @param rhs expression to be evaluated and used as right-hand side in comparison |
| 338 | + * @param TYPE the type of exception to throw |
| 339 | + */ |
286 | 340 | #define LVARRAY_THROW_IF_GT( lhs, rhs, TYPE ) LVARRAY_THROW_IF_GT_MSG( lhs, rhs, "", TYPE ) |
287 | 341 |
|
288 | 342 | /** |
|
293 | 347 | */ |
294 | 348 | #define LVARRAY_ERROR_IF_GE_MSG( lhs, rhs, msg ) LVARRAY_ERROR_IF_OP_MSG( lhs, >=, <, rhs, msg ) |
295 | 349 |
|
| 350 | +/** |
| 351 | + * @brief Throw an exception if one value compares greater than or equal to the other. |
| 352 | + * @param lhs expression to be evaluated and used as left-hand side in comparison |
| 353 | + * @param rhs expression to be evaluated and used as right-hand side in comparison |
| 354 | + * @param msg a message to log (any expression that can be stream inserted) |
| 355 | + * @param TYPE the type of exception to throw |
| 356 | + */ |
296 | 357 | #define LVARRAY_THROW_IF_GE_MSG( lhs, rhs, msg, TYPE ) LVARRAY_THROW_IF_OP_MSG( lhs, >=, <, rhs, msg, TYPE ) |
297 | 358 |
|
298 | 359 | /** |
|
302 | 363 | */ |
303 | 364 | #define LVARRAY_ERROR_IF_GE( lhs, rhs ) LVARRAY_ERROR_IF_GE_MSG( lhs, rhs, "" ) |
304 | 365 |
|
| 366 | +/** |
| 367 | + * @brief Throw an exception if one value compares greater than or equal to the other. |
| 368 | + * @param lhs expression to be evaluated and used as left-hand side in comparison |
| 369 | + * @param rhs expression to be evaluated and used as right-hand side in comparison |
| 370 | + * @param TYPE the type of exception to throw |
| 371 | + */ |
305 | 372 | #define LVARRAY_THROW_IF_GE( lhs, rhs, TYPE ) LVARRAY_THROW_IF_GE_MSG( lhs, rhs, "", TYPE ) |
306 | 373 |
|
307 | | - |
308 | 374 | /** |
309 | 375 | * @brief Raise a hard error if one value compares less than the other. |
310 | 376 | * @param lhs expression to be evaluated and used as left-hand side in comparison |
|
313 | 379 | */ |
314 | 380 | #define LVARRAY_ERROR_IF_LT_MSG( lhs, rhs, msg ) LVARRAY_ERROR_IF_OP_MSG( lhs, <, >=, rhs, msg ) |
315 | 381 |
|
| 382 | +/** |
| 383 | + * @brief Throw an exception if one value compares less than the other. |
| 384 | + * @param lhs expression to be evaluated and used as left-hand side in comparison |
| 385 | + * @param rhs expression to be evaluated and used as right-hand side in comparison |
| 386 | + * @param msg a message to log (any expression that can be stream inserted) |
| 387 | + * @param TYPE the type of exception to throw |
| 388 | + */ |
316 | 389 | #define LVARRAY_THROW_IF_LT_MSG( lhs, rhs, msg, TYPE ) LVARRAY_THROW_IF_OP_MSG( lhs, <, >=, rhs, msg, TYPE ) |
317 | 390 |
|
318 | 391 | /** |
|
322 | 395 | */ |
323 | 396 | #define LVARRAY_ERROR_IF_LT( lhs, rhs ) LVARRAY_ERROR_IF_LT_MSG( lhs, rhs, "" ) |
324 | 397 |
|
| 398 | +/** |
| 399 | + * @brief Throw an exception if one value compares less than the other. |
| 400 | + * @param lhs expression to be evaluated and used as left-hand side in comparison |
| 401 | + * @param rhs expression to be evaluated and used as right-hand side in comparison |
| 402 | + * @param TYPE the type of exception to throw |
| 403 | + */ |
325 | 404 | #define LVARRAY_THROW_IF_LT( lhs, rhs, TYPE ) LVARRAY_THROW_IF_LT_MSG( lhs, rhs, "", TYPE ) |
326 | 405 |
|
327 | 406 | /** |
|
332 | 411 | */ |
333 | 412 | #define LVARRAY_ERROR_IF_LE_MSG( lhs, rhs, msg ) LVARRAY_ERROR_IF_OP_MSG( lhs, <=, >, rhs, msg ) |
334 | 413 |
|
| 414 | +/** |
| 415 | + * @brief Throw an exception if one value compares less than or equal to the other. |
| 416 | + * @param lhs expression to be evaluated and used as left-hand side in comparison |
| 417 | + * @param rhs expression to be evaluated and used as right-hand side in comparison |
| 418 | + * @param msg a message to log (any expression that can be stream inserted) |
| 419 | + * @param TYPE the type of exception to throw |
| 420 | + */ |
335 | 421 | #define LVARRAY_THROW_IF_LE_MSG( lhs, rhs, msg, TYPE ) LVARRAY_THROW_IF_OP_MSG( lhs, <=, >, rhs, msg, TYPE ) |
336 | 422 |
|
337 | 423 | /** |
|
341 | 427 | */ |
342 | 428 | #define LVARRAY_ERROR_IF_LE( lhs, rhs ) LVARRAY_ERROR_IF_GE_MSG( lhs, rhs, "" ) |
343 | 429 |
|
| 430 | +/** |
| 431 | + * @brief Throw an exception if one value compares less than or equal to the other. |
| 432 | + * @param lhs expression to be evaluated and used as left-hand side in comparison |
| 433 | + * @param rhs expression to be evaluated and used as right-hand side in comparison |
| 434 | + * @param TYPE the type of exception to throw |
| 435 | + */ |
344 | 436 | #define LVARRAY_THROW_IF_LE( lhs, rhs, TYPE ) LVARRAY_THROW_IF_GE_MSG( lhs, rhs, "", TYPE ) |
345 | 437 |
|
346 | 438 | /** |
|
0 commit comments