microsoft/onnxruntime-extensions
Publicmirrored fromhttps://github.com/microsoft/onnxruntime-extensionsAvailable
base/status.h
31lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | // Licensed under the MIT License. |
| 3 | #pragma once |
| 4 | |
| 5 | #include <string> |
| 6 | #include <memory> |
| 7 | #include "ortx_types.h" |
| 8 | |
| 9 | struct OrtStatus; |
| 10 | |
| 11 | struct OrtxStatus { |
| 12 | OrtxStatus(); |
| 13 | ~OrtxStatus(); |
| 14 | OrtxStatus(extError_t code, const std::string& error_message); |
| 15 | OrtxStatus(const OrtxStatus& s); |
| 16 | OrtxStatus& operator=(const OrtxStatus& s); |
| 17 | bool operator==(const OrtxStatus& s) const; |
| 18 | bool operator!=(const OrtxStatus& s) const; |
| 19 | [[nodiscard]] inline bool IsOk() const { return rep_ == nullptr; } |
| 20 | |
| 21 | void SetErrorMessage(const char* str); |
| 22 | [[nodiscard]] const char* Message() const; |
| 23 | [[nodiscard]] extError_t Code() const; |
| 24 | std::string ToString() const; |
| 25 | |
| 26 | OrtStatus* CreateOrtStatus() const; |
| 27 | |
| 28 | private: |
| 29 | struct Rep; |
| 30 | std::unique_ptr<Rep> rep_; |
| 31 | }; |
| 32 | |