WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
Utility.h
Go to the documentation of this file.
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2008-2017. 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 
20 #define wpi_assert(condition) \
21  wpi_assert_impl(condition, #condition, "", __FILE__, __LINE__, __FUNCTION__)
22 #define wpi_assertWithMessage(condition, message) \
23  wpi_assert_impl(condition, #condition, message, __FILE__, __LINE__, \
24  __FUNCTION__)
25 
26 #define wpi_assertEqual(a, b) \
27  wpi_assertEqual_impl(a, b, #a, #b, "", __FILE__, __LINE__, __FUNCTION__)
28 #define wpi_assertEqualWithMessage(a, b, message) \
29  wpi_assertEqual_impl(a, b, #a, #b, message, __FILE__, __LINE__, __FUNCTION__)
30 
31 #define wpi_assertNotEqual(a, b) \
32  wpi_assertNotEqual_impl(a, b, #a, #b, "", __FILE__, __LINE__, __FUNCTION__)
33 #define wpi_assertNotEqualWithMessage(a, b, message) \
34  wpi_assertNotEqual_impl(a, b, #a, #b, message, __FILE__, __LINE__, \
35  __FUNCTION__)
36 
37 bool wpi_assert_impl(bool conditionValue, llvm::StringRef conditionText,
38  llvm::StringRef message, llvm::StringRef fileName,
39  int lineNumber, llvm::StringRef funcName);
40 bool wpi_assertEqual_impl(int valueA, int valueB, llvm::StringRef valueAString,
41  llvm::StringRef valueBString, llvm::StringRef message,
42  llvm::StringRef fileName, int lineNumber,
43  llvm::StringRef funcName);
44 bool wpi_assertNotEqual_impl(int valueA, int valueB,
45  llvm::StringRef valueAString,
46  llvm::StringRef valueBString,
47  llvm::StringRef message, llvm::StringRef fileName,
48  int lineNumber, llvm::StringRef funcName);
49 
50 void wpi_suspendOnAssertEnabled(bool enabled);
51 
52 namespace frc {
53 
54 int GetFPGAVersion();
55 int64_t GetFPGARevision();
56 uint64_t GetFPGATime();
57 bool GetUserButton();
58 std::string GetStackTrace(int offset);
59 
60 } // namespace frc
bool wpi_assert_impl(bool conditionValue, llvm::StringRef conditionText, llvm::StringRef message, llvm::StringRef fileName, int lineNumber, llvm::StringRef funcName)
Assert implementation.
Definition: Utility.cpp:33
bool wpi_assertEqual_impl(int valueA, int valueB, llvm::StringRef valueAString, llvm::StringRef valueBString, llvm::StringRef message, llvm::StringRef fileName, int lineNumber, llvm::StringRef funcName)
Assert equal implementation.
Definition: Utility.cpp:140
bool wpi_assertNotEqual_impl(int valueA, int valueB, llvm::StringRef valueAString, llvm::StringRef valueBString, llvm::StringRef message, llvm::StringRef fileName, int lineNumber, llvm::StringRef funcName)
Assert not equal implementation.
Definition: Utility.cpp:158