Where Online Learning is simpler!
The C and C++ Include Header Files
cat -n /usr/include/wabt/result.h
1 /* 2 * Copyright 2017 WebAssembly Community Group participants 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef WABT_RESULT_H_ 18 #define WABT_RESULT_H_ 19 20 namespace wabt { 21 22 struct Result { 23 enum Enum { 24 Ok, 25 Error, 26 }; 27 28 Result() : Result(Ok) {} 29 Result(Enum e) : enum_(e) {} 30 operator Enum() const { return enum_; } 31 Result& operator|=(Result rhs); 32 33 private: 34 Enum enum_; 35 }; 36 37 inline Result operator|(Result lhs, Result rhs) { 38 return (lhs == Result::Error || rhs == Result::Error) ? Result::Error 39 : Result::Ok; 40 } 41 42 inline Result& Result::operator|=(Result rhs) { 43 enum_ = *this | rhs; 44 return *this; 45 } 46 47 inline bool Succeeded(Result result) { 48 return result == Result::Ok; 49 } 50 inline bool Failed(Result result) { 51 return result == Result::Error; 52 } 53 54 #define CHECK_RESULT(expr) \ 55 do { \ 56 if (Failed(expr)) { \ 57 return ::wabt::Result::Error; \ 58 } \ 59 } while (0) 60 61 } // namespace wabt 62 63 #endif // WABT_RESULT_H_