DetourStatus.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //
  2. // Copyright (c) 2009-2010 Mikko Mononen memon@inside.org
  3. //
  4. // This software is provided 'as-is', without any express or implied
  5. // warranty. In no event will the authors be held liable for any damages
  6. // arising from the use of this software.
  7. // Permission is granted to anyone to use this software for any purpose,
  8. // including commercial applications, and to alter it and redistribute it
  9. // freely, subject to the following restrictions:
  10. // 1. The origin of this software must not be misrepresented; you must not
  11. // claim that you wrote the original software. If you use this software
  12. // in a product, an acknowledgment in the product documentation would be
  13. // appreciated but is not required.
  14. // 2. Altered source versions must be plainly marked as such, and must not be
  15. // misrepresented as being the original software.
  16. // 3. This notice may not be removed or altered from any source distribution.
  17. //
  18. #ifndef DETOURSTATUS_H
  19. #define DETOURSTATUS_H
  20. typedef unsigned int dtStatus;
  21. // High level status.
  22. static const unsigned int DT_FAILURE = 1u << 31; // Operation failed.
  23. static const unsigned int DT_SUCCESS = 1u << 30; // Operation succeed.
  24. static const unsigned int DT_IN_PROGRESS = 1u << 29; // Operation still in progress.
  25. // Detail information for status.
  26. static const unsigned int DT_STATUS_DETAIL_MASK = 0x0ffffff;
  27. static const unsigned int DT_WRONG_MAGIC = 1 << 0; // Input data is not recognized.
  28. static const unsigned int DT_WRONG_VERSION = 1 << 1; // Input data is in wrong version.
  29. static const unsigned int DT_OUT_OF_MEMORY = 1 << 2; // Operation ran out of memory.
  30. static const unsigned int DT_INVALID_PARAM = 1 << 3; // An input parameter was invalid.
  31. static const unsigned int DT_BUFFER_TOO_SMALL = 1 << 4; // Result buffer for the query was too small to store all results.
  32. static const unsigned int DT_OUT_OF_NODES = 1 << 5; // Query ran out of nodes during search.
  33. static const unsigned int DT_PARTIAL_RESULT = 1 << 6; // Query did not reach the end location, returning best guess.
  34. // Returns true of status is success.
  35. inline bool dtStatusSucceed(dtStatus status)
  36. {
  37. return (status & DT_SUCCESS) != 0;
  38. }
  39. // Returns true of status is failure.
  40. inline bool dtStatusFailed(dtStatus status)
  41. {
  42. return (status & DT_FAILURE) != 0;
  43. }
  44. // Returns true of status is in progress.
  45. inline bool dtStatusInProgress(dtStatus status)
  46. {
  47. return (status & DT_IN_PROGRESS) != 0;
  48. }
  49. // Returns true if specific detail is set.
  50. inline bool dtStatusDetail(dtStatus status, unsigned int detail)
  51. {
  52. return (status & detail) != 0;
  53. }
  54. #endif // DETOURSTATUS_H