Free Electron
Result.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 #ifndef __platform_Result_h__
8 #define __platform_Result_h__
9 
10 namespace fe
11 {
12 
13 #define FE_FAILURE 0x80000000
14 
15 /**************************************************************************//**
16  @brief Generalized return value indicating success or failure, and why
17 
18  @ingroup platform
19 
20  The functions fe::succeeded and fe::failed can quickly determine which
21  category the result belongs to.
22 *//***************************************************************************/
23 /// @todo eventually grep code for usage a remove useless ones
24 typedef enum
25 {
26  e_ok=0x00000000,
27  e_cancel,
28  e_poison,
29  e_alreadyAvailable,
30  e_notNeeded,
31  // add new success codes here. NOTE: be sure to update resultString()
32 
33  e_undefinedFailure=FE_FAILURE,
34  e_unsupported,
35  e_refused,
36  e_outOfMemory,
37  e_invalidFile,
38  e_invalidHandle,
39  e_invalidPointer,
40  e_invalidRange,
41  e_notInitialized,
42  e_cannotChange,
43  e_aborted,
44  e_writeFailed,
45  e_readFailed,
46  e_cannotFind,
47  e_cannotCreate,
48  e_unsolvable,
49  e_impossible,
50  e_usage,
51  e_system,
52  e_typeMismatch,
53  e_corrupt
54  // add new failure codes here. NOTE: be sure to update resultString()
55 } Result;
56 
57 /**************************************************************************//**
58  @brief Returns TRUE if the result value indicates a success
59 
60  @ingroup platform
61 *//***************************************************************************/
62 inline BWORD successful(Result result)
63 {
64  return ((result&FE_FAILURE)==0);
65 }
66 
67 /**************************************************************************//**
68  @brief Returns TRUE if the result value indicates a failure
69 
70  @ingroup platform
71 *//***************************************************************************/
72 inline BWORD failure(Result result)
73 {
74  return ((result&FE_FAILURE)!=0);
75 }
76 
77 /**************************************************************************//**
78  @brief Return a string for a result code
79 
80  @ingroup platform
81 *//***************************************************************************/
82 FE_DL_EXPORT const char *resultString(Result result);
83 
84 } /* namespace */
85 
86 #endif /* __platform_Result_h__ */
kernel
Definition: namespace.dox:3
BWORD failure(Result result)
Returns TRUE if the result value indicates a failure.
Definition: Result.h:72
Result
Generalized return value indicating success or failure, and why.
Definition: Result.h:24
BWORD successful(Result result)
Returns TRUE if the result value indicates a success.
Definition: Result.h:62
const char * resultString(Result result)
Return a string for a result code.
Definition: Result.cc:12