1/****************************************************************************************
2
3 Copyright (C) 2015 Autodesk, Inc.
4 All rights reserved.
5
6 Use of this software is subject to the terms of the Autodesk license agreement
7 provided at the time of installation or download, or which otherwise accompanies
8 this software in either electronic or hard copy form.
9
10****************************************************************************************/
11
12//! \file fbxstatus.h
13#ifndef _FBXSDK_CORE_BASE_STATUS_H_
14#define _FBXSDK_CORE_BASE_STATUS_H_
15
16#include <fbxsdk/fbxsdk_def.h>
17
18#include <fbxsdk/core/base/fbxstring.h>
19
20#include <fbxsdk/fbxsdk_nsbegin.h>
21
22/** This class facilitates the testing/reporting of errors. It encapsulates the
23 * status code and the internal FBXSDK error code as returned by the API functions.
24 * \nosubgrouping
25 */
26class FBXSDK_DLL FbxStatus
27{
28public:
29
30
31 //! Available status codes.
32 enum EStatusCode {
33 eSuccess = 0, //!< Operation was successful
34 eFailure, //!< Operation failed
35 eInsufficientMemory, //!< Operation failed due to insufficient memory
36 eInvalidParameter, //!< An invalid parameter was provided
37 eIndexOutOfRange, //!< Index value outside the valid range
38 ePasswordError, //!< Operation on FBX file password failed
39 eInvalidFileVersion, //!< File version not supported (anymore or yet)
40 eInvalidFile //!< Operation on the file access failed
41 };
42
43 //! Default constructor.
44 FbxStatus();
45
46 FbxStatus(EStatusCode pCode);
47 FbxStatus(const FbxStatus& rhs);
48
49 FbxStatus& operator=(const FbxStatus& rhs);
50
51 /** Equivalence operator.
52 * \param rhs Status object to compare.
53 * \return \c True if all the members of \e rhs are equal to this instance members and \c False otherwise.
54 */
55 bool operator==(const FbxStatus& rhs) const { return (mCode == rhs.mCode); }
56 /** Equivalence operator.
57 * \param pCode Status code to compare.
58 * \return \c True if the code member of this instance equals \e pCode and \c False otherwise.
59 */
60 bool operator==(const EStatusCode pCode) const { return (mCode == pCode); }
61 /** Non-Equivalence operator.
62 * \param rhs Status object to compare.
63 * \return \c True if at least one member of \e rhs is not equal to this instance member and \c True otherwise.
64 */
65 bool operator!=(const FbxStatus& rhs) const { return (mCode != rhs.mCode); }
66 /** Non-Equivalence operator.
67 * \param rhs Status code to compare.
68 * \return \c True if the code member of this instance equals \e rhs and \c False otherwise.
69 */
70 bool operator!=(const EStatusCode rhs) const { return (mCode != rhs); }
71
72 /** The conversion operator that converts a FbxStatus object to bool.
73 * The result it returns will be \c True if the FbxStatus does not contain
74 * an error, and \c False if it does.
75 */
76 operator bool() const { return mCode==eSuccess; }
77
78 /** Determines whether there is an error.
79 * \return \c True if an error occured and \c False if the operation was sucessful.
80 */
81 bool Error() const { return !this->operator bool(); }
82
83 //! Clear error code and message from the instance. After this call, it will behave as if it contained eSuccess.
84 void Clear();
85
86 //! Retrieve the type of error that occurred, as specified in the enumeration.
87 EStatusCode GetCode() const { return mCode; }
88
89 /** Change the current code of the instance.
90 * \param rhs New code value.
91 */
92 void SetCode(const EStatusCode rhs);
93
94 /** Change the current code of the instance.
95 * \param rhs New code value.
96 * \param pErrorMsg Optional error description string. This string can have formatting characters
97 * The function will use the vsnprintf function to assemble the final string
98 * using an internal buffer of 4096 characters.
99 */
100 void SetCode(const EStatusCode rhs, const char* pErrorMsg, ...);
101
102 //! Get the error message string corresponding to the current code.
103 const char* GetErrorString() const;
104
105/*****************************************************************************************************************************
106** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
107*****************************************************************************************************************************/
108#ifndef DOXYGEN_SHOULD_SKIP_THIS
109
110private:
111 EStatusCode mCode;
112 FbxString mErrorString;
113
114#endif /* !DOXYGEN_SHOULD_SKIP_THIS */
115};
116
117#include <fbxsdk/fbxsdk_nsend.h>
118
119#endif /* _FBXSDK_CORE_BASE_STATUS_H_ */
120