Error.inc (1469B)
1 // 2 // Copyright 2014 The ANGLE Project Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 6 // Error.inc: Inline definitions of egl::Error and gl::Error classes which encapsulate API errors 7 // and optional error messages. 8 9 #include "common/angleutils.h" 10 11 #include <cstdarg> 12 13 namespace egl 14 { 15 16 Error::Error(EGLint errorCode) 17 : mCode(errorCode), 18 mID(0) 19 { 20 } 21 22 Error::Error(const Error &other) 23 : mCode(other.mCode), 24 mID(other.mID) 25 { 26 if (other.mMessage) 27 { 28 createMessageString(); 29 *mMessage = *(other.mMessage); 30 } 31 } 32 33 Error::Error(Error &&other) 34 : mCode(other.mCode), 35 mID(other.mID), 36 mMessage(std::move(other.mMessage)) 37 { 38 } 39 40 Error &Error::operator=(const Error &other) 41 { 42 mCode = other.mCode; 43 mID = other.mID; 44 45 if (other.mMessage) 46 { 47 createMessageString(); 48 *mMessage = *(other.mMessage); 49 } 50 else 51 { 52 mMessage.reset(); 53 } 54 55 return *this; 56 } 57 58 Error &Error::operator=(Error &&other) 59 { 60 if (this != &other) 61 { 62 mCode = other.mCode; 63 mID = other.mID; 64 mMessage = std::move(other.mMessage); 65 } 66 67 return *this; 68 } 69 70 EGLint Error::getCode() const 71 { 72 return mCode; 73 } 74 75 EGLint Error::getID() const 76 { 77 return mID; 78 } 79 80 bool Error::isError() const 81 { 82 return (mCode != EGL_SUCCESS); 83 } 84 85 // Static 86 Error Error::NoError() 87 { 88 return Error(EGL_SUCCESS); 89 } 90 91 }