libmicroemu 0.2.0
ARM Microcontroller Emulator Library
Loading...
Searching...
No Matches
exec_result.h
Go to the documentation of this file.
1
5
6#pragma once
7
9#include "libmicroemu/types.h"
10#include <string_view>
11
12namespace libmicroemu {
13
19public:
23 ExecResult(StatusCode status_code, int program_exit_code) noexcept
24 : status_code(status_code), program_exit_code(program_exit_code) {}
25
29 ExecResult(ExecResult &&r) noexcept = default;
30
35
39 ExecResult(const ExecResult &r) noexcept = default;
40
44 ExecResult &operator=(const ExecResult &r) = delete;
45
50 inline bool IsOk() const noexcept { return status_code == StatusCode::kSuccess; };
51
56 inline bool IsErr() const noexcept { return status_code != StatusCode::kSuccess; };
57
62 inline bool IsMaxInstructionsReached() const noexcept {
63 return status_code == StatusCode::kMaxInstructionsReached;
64 };
65
70 std::string_view ToString() const noexcept { return StatusCodeToString(status_code); }
71
77 StatusCode GetStatusCode() const noexcept { return status_code; }
78
83 u32 GetProgramExitCode() const noexcept { return program_exit_code; }
84
85private:
86 const StatusCode status_code;
87 const int program_exit_code;
88};
89
90} // namespace libmicroemu
bool IsMaxInstructionsReached() const noexcept
Checks if the maximum number of instructions has been reached.
Definition exec_result.h:62
u32 GetProgramExitCode() const noexcept
Gets the program exit code.
Definition exec_result.h:83
bool IsErr() const noexcept
Checks if the execution result is an error.
Definition exec_result.h:56
ExecResult(const ExecResult &r) noexcept=default
Copy Constructor.
std::string_view ToString() const noexcept
Converts the contained status code to a string.
Definition exec_result.h:70
ExecResult(ExecResult &&r) noexcept=default
Move Constructor.
ExecResult & operator=(const ExecResult &r)=delete
Copy Assignment.
StatusCode GetStatusCode() const noexcept
Gets the status code of the execution result.
Definition exec_result.h:77
bool IsOk() const noexcept
Checks if the execution result is a success.
Definition exec_result.h:50
ExecResult(StatusCode status_code, int program_exit_code) noexcept
Constructs a new ExecResult object.
Definition exec_result.h:23
ExecResult & operator=(ExecResult &&r)=delete
Move Assignment.
The libmicroemu namespace contains all classes and functions of the libmicroemu which are public.
Definition bkpt_flags.h:6
static std::string_view StatusCodeToString(const StatusCode &status_code) noexcept
Converts a status code to a string.
Definition status_code.h:108
StatusCode
Enum representing various status codes used throughout the system.
Definition status_code.h:17
@ kMaxInstructionsReached
Maximum instruction count reached.
Definition status_code.h:100
@ kSuccess
Operation succeeded successfully.
Definition status_code.h:20
File contains enum class for status codes.