fbxstatus.h 5.0 KB

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