WPILibC++  unspecified
Utility.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2008-2018 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 
14 #include <stdint.h>
15 
16 #include <string>
17 
18 #include <llvm/StringRef.h>
19 #include <llvm/Twine.h>
20 #include <support/deprecated.h>
21 
22 #define wpi_assert(condition) \
23  wpi_assert_impl(condition, #condition, "", __FILE__, __LINE__, __FUNCTION__)
24 #define wpi_assertWithMessage(condition, message) \
25  wpi_assert_impl(condition, #condition, message, __FILE__, __LINE__, \
26  __FUNCTION__)
27 
28 #define wpi_assertEqual(a, b) \
29  wpi_assertEqual_impl(a, b, #a, #b, "", __FILE__, __LINE__, __FUNCTION__)
30 #define wpi_assertEqualWithMessage(a, b, message) \
31  wpi_assertEqual_impl(a, b, #a, #b, message, __FILE__, __LINE__, __FUNCTION__)
32 
33 #define wpi_assertNotEqual(a, b) \
34  wpi_assertNotEqual_impl(a, b, #a, #b, "", __FILE__, __LINE__, __FUNCTION__)
35 #define wpi_assertNotEqualWithMessage(a, b, message) \
36  wpi_assertNotEqual_impl(a, b, #a, #b, message, __FILE__, __LINE__, \
37  __FUNCTION__)
38 
39 bool wpi_assert_impl(bool conditionValue, const llvm::Twine& conditionText,
40  const llvm::Twine& message, llvm::StringRef fileName,
41  int lineNumber, llvm::StringRef funcName);
42 bool wpi_assertEqual_impl(int valueA, int valueB,
43  const llvm::Twine& valueAString,
44  const llvm::Twine& valueBString,
45  const llvm::Twine& message, llvm::StringRef fileName,
46  int lineNumber, llvm::StringRef funcName);
47 bool wpi_assertNotEqual_impl(int valueA, int valueB,
48  const llvm::Twine& valueAString,
49  const llvm::Twine& valueBString,
50  const llvm::Twine& message,
51  llvm::StringRef fileName, int lineNumber,
52  llvm::StringRef funcName);
53 
54 void wpi_suspendOnAssertEnabled(bool enabled);
55 
56 namespace frc {
57 
58 WPI_DEPRECATED("Use RobotController static class method")
59 int GetFPGAVersion();
60 WPI_DEPRECATED("Use RobotController static class method")
61 int64_t GetFPGARevision();
62 WPI_DEPRECATED("Use RobotController static class method")
63 uint64_t GetFPGATime();
64 WPI_DEPRECATED("Use RobotController static class method")
65 bool GetUserButton();
66 std::string GetStackTrace(int offset);
67 
68 } // namespace frc
Definition: RobotController.cpp:14
Definition: json.cpp:1170
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:79
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:42