wut  1.0.0-beta9
Wii U Toolchain
result.h
Go to the documentation of this file.
1 #pragma once
2 #include <wut.h>
3 
11 typedef struct NNResult NNResult;
12 
19 struct NNResult
20 {
22  int32_t value;
23 };
24 
37 static inline int NNResult_IsSuccess(NNResult result)
38 {
39  return result.value >= 0;
40 }
41 
54 static inline int NNResult_IsFailure(NNResult result)
55 {
56  return result.value < 0;
57 }
58 
59 #ifdef __cplusplus
60 
61 namespace nn
62 {
63 
67 class Result
68 {
69 public:
70  enum Level
71  {
76  LEVEL_END = -7,
77  };
78 
80  {
86  };
87 
88  enum Module
89  {
112  };
113 
115  {
133  MODULE_NN_FS = 0x11,
134  MODULE_NN_DI = 0x12,
137  MODULE_NN_PI = 0x15,
138  MODULE_NN_PM = 0x16,
148  MODULE_NN_AM = 0x20,
153  MODULE_NN_MP = 0x25,
155  MODULE_NN_AC = 0x27,
171  MODULE_NN_MC = 0x37,
181  MODULE_NN_PS = 0x41,
183  MODULE_NN_IR = 0x43,
185  MODULE_NN_PL = 0x45,
189  MODULE_NN_NS = 0x49,
191  MODULE_NN_RO = 0x4B,
192  MODULE_NN_GD = 0x4C,
194  MODULE_NN_EC = 0x4E,
200  };
201 
203  {
216  };
217 
219  {
221  };
222 
223 public:
224  Result(Level level, Module module, unsigned description) :
225  mDescription(description),
226  mModule(module),
227  mLevel(level)
228  {
229  }
230 
231  Result(const NNResult &result) :
232  mValue(result.value)
233  {
234  }
235 
245  bool IsFailure() const
246  {
247  return !IsSuccess();
248  }
249 
259  bool IsSuccess() const
260  {
261  return mLevel >= 0;
262  }
263 
264  bool IsLegacy() const
265  {
266  return mLegacy.signature == SIGNATURE_IS_LEGACY;
267  }
268 
269  unsigned GetDescription() const
270  {
271  if (IsLegacy()) {
272  return mLegacy.description;
273  }
274 
275  return mDescription;
276  }
277 
278  int GetLevel() const
279  {
280  if (IsLegacy()) {
281  return mLegacy.level;
282  }
283 
284  return mLevel;
285  }
286 
287  unsigned GetModule() const
288  {
289  if (IsLegacy()) {
290  return mLegacy.module;
291  }
292 
293  return mModule;
294  }
295 
296  unsigned GetSummary() const
297  {
298  if (IsLegacy()) {
299  return mLegacy.summary;
300  }
301 
302  return 0;
303  }
304 
305  operator bool() const
306  {
307  return IsSuccess();
308  }
309 
310  operator NNResult() const
311  {
312  NNResult result;
313  result.value = mValue;
314  return result;
315  }
316 
317  bool operator==(const Result &other) const
318  {
319  return mValue == other.mValue;
320  }
321 
322  bool operator!=(const Result &other) const
323  {
324  return mValue != other.mValue;
325  }
326 
327 private:
328  union {
329  struct {
330  uint32_t description : 10;
331  uint32_t summary : 4;
332  int32_t level : 4;
333  uint32_t : 2;
334  uint32_t module : 7;
335  uint32_t signature : 2;
336  } mLegacy;
337 
338  struct {
339  uint32_t mDescription : 20;
340  uint32_t mModule : 9;
341  int32_t mLevel : 3;
342  };
343 
344  int32_t mValue;
345  };
346 };
347 
348 } // namespace nn
349 
350 #endif // ifdef __cplusplus
351 
nn::Result::MODULE_NN_AMLOW
@ MODULE_NN_AMLOW
Definition: result.h:163
nn::Result::MODULE_NN_NWM
@ MODULE_NN_NWM
Definition: result.h:143
nn::Result::MODULE_NN_DLP
@ MODULE_NN_DLP
Definition: result.h:159
nn::Result::MODULE_NN_MCU
@ MODULE_NN_MCU
Definition: result.h:188
nn::Result::MODULE_NN_ACC
@ MODULE_NN_ACC
Definition: result.h:146
nn::Result::RESULT_MODULE_NN_AC
@ RESULT_MODULE_NN_AC
Definition: result.h:103
nn::Result::MODULE_NN_SRV
@ MODULE_NN_SRV
Definition: result.h:141
NNResult_IsSuccess
static int NNResult_IsSuccess(NNResult result)
Determine if a NNResult represents a successful state.
Definition: result.h:37
nn::Result::RESULT_MODULE_NN_BOSS
@ RESULT_MODULE_NN_BOSS
Definition: result.h:92
nn::Result::LegacyModule
LegacyModule
Definition: result.h:114
nn::Result::MODULE_NN_GPIO
@ MODULE_NN_GPIO
Definition: result.h:128
nn::Result::LEVEL_RESET
@ LEVEL_RESET
Definition: result.h:82
nn::Result::MODULE_NN_DMNT
@ MODULE_NN_DMNT
Definition: result.h:124
nn::Result::MODULE_NN_SSL
@ MODULE_NN_SSL
Definition: result.h:162
nn::Result::MODULE_NN_SWC
@ MODULE_NN_SWC
Definition: result.h:172
nn::Result::MODULE_NN_AC
@ MODULE_NN_AC
Definition: result.h:155
nn::Result::Module
Module
Definition: result.h:88
nn::Result::MODULE_NN_CFG
@ MODULE_NN_CFG
Definition: result.h:180
nn::Result::MODULE_NN_CARD
@ MODULE_NN_CARD
Definition: result.h:175
nn::Result::RESULT_MODULE_NN_SPM
@ RESULT_MODULE_NN_SPM
Definition: result.h:110
nn::Result::MODULE_NN_FSI
@ MODULE_NN_FSI
Definition: result.h:140
nn::Result::MODULE_NN_CUP
@ MODULE_NN_CUP
Definition: result.h:186
nn::Result::SUMMARY_INVALID_ARGUMENT
@ SUMMARY_INVALID_ARGUMENT
Definition: result.h:211
nn::Result::MODULE_NN_MIDI
@ MODULE_NN_MIDI
Definition: result.h:170
nn::Result::MODULE_NN_MC
@ MODULE_NN_MC
Definition: result.h:171
nn::Result::MODULE_NN_PIA
@ MODULE_NN_PIA
Definition: result.h:198
nn::Result::MODULE_COMMON
@ MODULE_COMMON
Definition: result.h:116
nn::Result::RESULT_MODULE_NN_FP
@ RESULT_MODULE_NN_FP
Definition: result.h:102
nn::Result::MODULE_NN_UDS
@ MODULE_NN_UDS
Definition: result.h:184
nn::Result::SUMMARY_WRONG_ARGUMENT
@ SUMMARY_WRONG_ARGUMENT
Definition: result.h:212
nn::Result::RESULT_MODULE_NN_ACP
@ RESULT_MODULE_NN_ACP
Definition: result.h:93
nn::Result::operator==
bool operator==(const Result &other) const
Definition: result.h:317
nn::Result::MODULE_NN_CAMERA
@ MODULE_NN_CAMERA
Definition: result.h:136
nn::Result::MODULE_NN_UTIL
@ MODULE_NN_UTIL
Definition: result.h:118
nn::Result::MODULE_APPLICATION
@ MODULE_APPLICATION
Definition: result.h:199
nn::Result::RESULT_MODULE_NN_IOS
@ RESULT_MODULE_NN_IOS
Definition: result.h:94
nn::Result::MODULE_NN_LDR
@ MODULE_NN_LDR
Definition: result.h:145
nn::Result::LEVEL_SUCCESS
@ LEVEL_SUCCESS
Definition: result.h:72
nn::Result::Result
Result(Level level, Module module, unsigned description)
Definition: result.h:224
nn::Result::SUMMARY_INTERNAL
@ SUMMARY_INTERNAL
Definition: result.h:215
nn::Result::MODULE_NN_OS
@ MODULE_NN_OS
Definition: result.h:122
nn::Result::LEVEL_REINIT
@ LEVEL_REINIT
Definition: result.h:83
wut.h
nn::Result::LEVEL_STATUS
@ LEVEL_STATUS
Definition: result.h:75
nn::Result::GetModule
unsigned GetModule() const
Definition: result.h:287
nn::Result::MODULE_NN_CSND
@ MODULE_NN_CSND
Definition: result.h:161
nn::Result::MODULE_NN_DSP
@ MODULE_NN_DSP
Definition: result.h:157
nn::Result::MODULE_NN_SPI
@ MODULE_NN_SPI
Definition: result.h:131
nn::Result::MODULE_NN_CARDSPI
@ MODULE_NN_CARDSPI
Definition: result.h:193
nn::Result::LEVEL_TEMPORARY
@ LEVEL_TEMPORARY
Definition: result.h:85
nn::Result::MODULE_NN_GX
@ MODULE_NN_GX
Definition: result.h:126
nn::Result::LegacyLevel
LegacyLevel
Definition: result.h:79
nn::Result::MODULE_NN_NIM
@ MODULE_NN_NIM
Definition: result.h:168
nn::Result::RESULT_MODULE_NN_VCTL
@ RESULT_MODULE_NN_VCTL
Definition: result.h:108
nn::Result::MODULE_NN_DI
@ MODULE_NN_DI
Definition: result.h:134
nn::Result::SUMMARY_NOT_SUPPORTED
@ SUMMARY_NOT_SUPPORTED
Definition: result.h:210
nn::Result::SUMMARY_SUCCESS
@ SUMMARY_SUCCESS
Definition: result.h:204
nn::Result::MODULE_NN_HTTP
@ MODULE_NN_HTTP
Definition: result.h:156
nn::Result::MODULE_NN_FS
@ MODULE_NN_FS
Definition: result.h:133
nn::Result::MODULE_NN_RO
@ MODULE_NN_RO
Definition: result.h:191
nn::Result::RESULT_MODULE_NN_TEST
@ RESULT_MODULE_NN_TEST
Definition: result.h:111
nn::Result::MODULE_NN_CODEC
@ MODULE_NN_CODEC
Definition: result.h:130
nn::Result::SUMMARY_NOT_FOUND
@ SUMMARY_NOT_FOUND
Definition: result.h:208
nn::Result::MODULE_NN_DBG
@ MODULE_NN_DBG
Definition: result.h:123
nn::Result::SUMMARY_OUT_OF_RESOURCE
@ SUMMARY_OUT_OF_RESOURCE
Definition: result.h:207
nn::Result::LEVEL_END
@ LEVEL_END
Definition: result.h:76
nn::Result::MODULE_NN_TCB
@ MODULE_NN_TCB
Definition: result.h:121
nn::Result::RESULT_MODULE_NN_OLV
@ RESULT_MODULE_NN_OLV
Definition: result.h:107
nn::Result::MODULE_NN_FRIENDS
@ MODULE_NN_FRIENDS
Definition: result.h:165
nn::Result::MODULE_NN_MIC
@ MODULE_NN_MIC
Definition: result.h:151
nn::Result::RESULT_MODULE_NN_NIM
@ RESULT_MODULE_NN_NIM
Definition: result.h:95
nn::Result::MODULE_NN_PL
@ MODULE_NN_PL
Definition: result.h:185
nn::Result::GetSummary
unsigned GetSummary() const
Definition: result.h:296
nn::Result::IsSuccess
bool IsSuccess() const
Determine if the Result instance represents a successful state.
Definition: result.h:259
nn::Result::operator!=
bool operator!=(const Result &other) const
Definition: result.h:322
nn::Result::MODULE_NN_ENC
@ MODULE_NN_ENC
Definition: result.h:197
nn::Result::GetLevel
int GetLevel() const
Definition: result.h:278
nn::Result::MODULE_NN_PDN
@ MODULE_NN_PDN
Definition: result.h:125
nn::Result::RESULT_MODULE_NN_CONNTEST
@ RESULT_MODULE_NN_CONNTEST
Definition: result.h:104
nn::Result::RESULT_MODULE_NN_ECA
@ RESULT_MODULE_NN_ECA
Definition: result.h:99
nn::Result::MODULE_NN_SND
@ MODULE_NN_SND
Definition: result.h:158
nn::Result::MODULE_NN_PXI
@ MODULE_NN_PXI
Definition: result.h:132
nn::Result::MODULE_NN_I2C
@ MODULE_NN_I2C
Definition: result.h:127
nn::Result::RESULT_MODULE_NN_TELNET
@ RESULT_MODULE_NN_TELNET
Definition: result.h:106
nn::Result::MODULE_NN_APPLET
@ MODULE_NN_APPLET
Definition: result.h:167
nn::Result::MODULE_NN_ROMFS
@ MODULE_NN_ROMFS
Definition: result.h:147
nn::Result::LEVEL_PERMANENT
@ LEVEL_PERMANENT
Definition: result.h:84
nn::Result::LEVEL_FATAL
@ LEVEL_FATAL
Definition: result.h:73
nn::Result::MODULE_NN_AM
@ MODULE_NN_AM
Definition: result.h:148
nn::Result::MODULE_NN_PI
@ MODULE_NN_PI
Definition: result.h:137
nn::Result::MODULE_NN_HIO
@ MODULE_NN_HIO
Definition: result.h:149
nn::Result::LegacySummary
LegacySummary
Definition: result.h:202
nn::Result::RESULT_MODULE_NN_NDM
@ RESULT_MODULE_NN_NDM
Definition: result.h:101
nn::Result::MODULE_NN_FND
@ MODULE_NN_FND
Definition: result.h:152
nn::Result::SUMMARY_CANCELLED
@ SUMMARY_CANCELLED
Definition: result.h:213
nn::Result::MODULE_NN_NS
@ MODULE_NN_NS
Definition: result.h:189
nn::Result
Result value type used by nn libraries.
Definition: result.h:67
nn::Result::MODULE_NN_UPDATER
@ MODULE_NN_UPDATER
Definition: result.h:150
nn::Result::RESULT_MODULE_NN_NUP
@ RESULT_MODULE_NN_NUP
Definition: result.h:100
nn::Result::MODULE_NN_NEX
@ MODULE_NN_NEX
Definition: result.h:164
nn::Result::MODULE_NN_BOSS
@ MODULE_NN_BOSS
Definition: result.h:178
nn::Result::MODULE_NN_PS
@ MODULE_NN_PS
Definition: result.h:181
nn::Result::SIGNATURE_IS_LEGACY
@ SIGNATURE_IS_LEGACY
Definition: result.h:220
nn::Result::MODULE_NN_CEC
@ MODULE_NN_CEC
Definition: result.h:182
nn::Result::LegacySignature
LegacySignature
Definition: result.h:218
nn::Result::MODULE_NN_NDM
@ MODULE_NN_NDM
Definition: result.h:142
nn::Result::GetDescription
unsigned GetDescription() const
Definition: result.h:269
nn::Result::MODULE_NN_SOCKET
@ MODULE_NN_SOCKET
Definition: result.h:144
nn::Result::MODULE_NN_MPWL
@ MODULE_NN_MPWL
Definition: result.h:154
nn
Definition: ac_cpp.h:14
nn::Result::MODULE_NN_WEBBRS
@ MODULE_NN_WEBBRS
Definition: result.h:195
nn::Result::MODULE_NN_GYROSCOPE
@ MODULE_NN_GYROSCOPE
Definition: result.h:187
nn::Result::Result
Result(const NNResult &result)
Definition: result.h:231
nn::Result::MODULE_NN_GD
@ MODULE_NN_GD
Definition: result.h:192
nn::Result::MODULE_NN_HIOLOW
@ MODULE_NN_HIOLOW
Definition: result.h:160
nn::Result::RESULT_MODULE_NN_PDM
@ RESULT_MODULE_NN_PDM
Definition: result.h:96
nn::Result::MODULE_NN_IR
@ MODULE_NN_IR
Definition: result.h:183
nn::Result::Level
Level
Definition: result.h:70
nn::Result::MODULE_NN_EC
@ MODULE_NN_EC
Definition: result.h:194
nn::Result::MODULE_NN_NGC
@ MODULE_NN_NGC
Definition: result.h:174
nn::Result::MODULE_NN_PMLOW
@ MODULE_NN_PMLOW
Definition: result.h:139
nn::Result::SUMMARY_NOTHING_HAPPENED
@ SUMMARY_NOTHING_HAPPENED
Definition: result.h:205
nn::Result::MODULE_NN_PM
@ MODULE_NN_PM
Definition: result.h:138
nn::Result::MODULE_NN_RDT
@ MODULE_NN_RDT
Definition: result.h:166
nn::Result::MODULE_NN_NEWS
@ MODULE_NN_NEWS
Definition: result.h:190
nn::Result::MODULE_NN_MP
@ MODULE_NN_MP
Definition: result.h:153
NNResult::value
int32_t value
Aggregate value of result bitfield.
Definition: result.h:22
nn::Result::MODULE_NN_HID
@ MODULE_NN_HID
Definition: result.h:135
nn::Result::SUMMARY_INVALID_STATE
@ SUMMARY_INVALID_STATE
Definition: result.h:209
nn::Result::LEVEL_USAGE
@ LEVEL_USAGE
Definition: result.h:74
nn::Result::LEVEL_INFO
@ LEVEL_INFO
Definition: result.h:81
nn::Result::MODULE_NN_LOADER_SERVER
@ MODULE_NN_LOADER_SERVER
Definition: result.h:120
nn::Result::MODULE_NN_FILE_SERVER
@ MODULE_NN_FILE_SERVER
Definition: result.h:119
NNResult
Result structure for nn libraries.
Definition: result.h:19
nn::Result::RESULT_MODULE_NN_DRMAPP
@ RESULT_MODULE_NN_DRMAPP
Definition: result.h:105
nn::Result::RESULT_MODULE_NN_IPC
@ RESULT_MODULE_NN_IPC
Definition: result.h:91
nn::Result::MODULE_NN_DD
@ MODULE_NN_DD
Definition: result.h:129
nn::Result::RESULT_MODULE_NN_NGC
@ RESULT_MODULE_NN_NGC
Definition: result.h:98
NNResult
struct NNResult NNResult
Definition: result.h:11
nn::Result::IsFailure
bool IsFailure() const
Determine if the Result instance represents a failure.
Definition: result.h:245
NNResult_IsFailure
static int NNResult_IsFailure(NNResult result)
Determine if a NNResult represents a failure.
Definition: result.h:54
nn::Result::RESULT_MODULE_NN_NEIA
@ RESULT_MODULE_NN_NEIA
Definition: result.h:109
nn::Result::RESULT_MODULE_COMMON
@ RESULT_MODULE_COMMON
Definition: result.h:90
nn::Result::MODULE_NN_KERNEL
@ MODULE_NN_KERNEL
Definition: result.h:117
nn::Result::MODULE_NN_TEST
@ MODULE_NN_TEST
Definition: result.h:196
nn::Result::MODULE_NN_DBM
@ MODULE_NN_DBM
Definition: result.h:179
nn::Result::MODULE_NN_CARDNOR
@ MODULE_NN_CARDNOR
Definition: result.h:176
nn::Result::SUMMARY_WOULD_BLOCK
@ SUMMARY_WOULD_BLOCK
Definition: result.h:206
nn::Result::IsLegacy
bool IsLegacy() const
Definition: result.h:264
nn::Result::SUMMARY_STATUS_CHANGED
@ SUMMARY_STATUS_CHANGED
Definition: result.h:214
nn::Result::RESULT_MODULE_NN_ACT
@ RESULT_MODULE_NN_ACT
Definition: result.h:97
nn::Result::MODULE_NN_FATFS
@ MODULE_NN_FATFS
Definition: result.h:173
nn::Result::MODULE_NN_SDMC
@ MODULE_NN_SDMC
Definition: result.h:177
nn::Result::MODULE_NN_PTM
@ MODULE_NN_PTM
Definition: result.h:169