Browse Source

去除编译警告

disinfection_machine
zhaohe 2 years ago
parent
commit
17f6697046
  1. 0
      core/driver/sockcanpp/.clang-format
  2. 6
      core/driver/sockcanpp/CanDriver.cpp
  3. 47
      core/driver/sockcanpp/CanId.hpp

0
core/driver/sockcanpp/.clang-format

6
core/driver/sockcanpp/CanDriver.cpp

@ -77,7 +77,6 @@ namespace sockcanpp {
const int32_t CanDriver::CAN_SOCK_RAW = CAN_RAW; const int32_t CanDriver::CAN_SOCK_RAW = CAN_RAW;
const int32_t CanDriver::CAN_SOCK_SEVEN = 7; const int32_t CanDriver::CAN_SOCK_SEVEN = 7;
#pragma region Object Construction
CanDriver::CanDriver(string canInterface, int32_t canProtocol, const CanId defaultSenderId): CanDriver::CanDriver(string canInterface, int32_t canProtocol, const CanId defaultSenderId):
CanDriver(canInterface, canProtocol, 0 /* match all */, defaultSenderId) {} CanDriver(canInterface, canProtocol, 0 /* match all */, defaultSenderId) {}
@ -85,9 +84,7 @@ namespace sockcanpp {
_defaultSenderId(defaultSenderId), _canProtocol(canProtocol), _canInterface(canInterface), _canFilterMask(filterMask), _socketFd(-1) { _defaultSenderId(defaultSenderId), _canProtocol(canProtocol), _canInterface(canInterface), _canFilterMask(filterMask), _socketFd(-1) {
initialiseSocketCan(); initialiseSocketCan();
} }
#pragma endregion
#pragma region I / O
/** /**
* @brief Blocks until one or more CAN messages appear on the bus, or until the timeout runs out. * @brief Blocks until one or more CAN messages appear on the bus, or until the timeout runs out.
* *
@ -229,13 +226,11 @@ namespace sockcanpp {
_canFilterMask = mask; _canFilterMask = mask;
} }
#pragma endregion
////////////////////////////////////// //////////////////////////////////////
// PROTECTED IMPLEMENTATION // // PROTECTED IMPLEMENTATION //
////////////////////////////////////// //////////////////////////////////////
#pragma region Socket Management
/** /**
* @brief Initialises the underlying CAN socket. * @brief Initialises the underlying CAN socket.
@ -290,6 +285,5 @@ namespace sockcanpp {
_socketFd = -1; _socketFd = -1;
} }
#pragma endregion
} // namespace sockcanpp } // namespace sockcanpp

47
core/driver/sockcanpp/CanId.hpp

@ -68,14 +68,12 @@ namespace sockcanpp {
public: // +++ Operators +++ public: // +++ Operators +++
#pragma region "Implicit Cast Operators"
operator int16_t() const { return isStandardFrameId() ? (int16_t)_identifier : throw system_error(error_code(0xbad1d, generic_category()), "INVALID CAST: ID is extended or invalid!"); } operator int16_t() const { return isStandardFrameId() ? (int16_t)_identifier : throw system_error(error_code(0xbad1d, generic_category()), "INVALID CAST: ID is extended or invalid!"); }
operator uint16_t() const { return isStandardFrameId() ? (uint16_t)_identifier : throw system_error(error_code(0xbad1d, generic_category()), "INVALID CAST: ID is extended or invalid!"); } operator uint16_t() const { return isStandardFrameId() ? (uint16_t)_identifier : throw system_error(error_code(0xbad1d, generic_category()), "INVALID CAST: ID is extended or invalid!"); }
operator int32_t() const { return _identifier; } operator int32_t() const { return _identifier; }
operator uint32_t() const { return _identifier; } operator uint32_t() const { return _identifier; }
#pragma endregion
#pragma region "Bitwise Operators"
CanId operator &(CanId& x) const { return _identifier & x._identifier; } CanId operator &(CanId& x) const { return _identifier & x._identifier; }
CanId operator &(const CanId x) const { return _identifier & x._identifier; } CanId operator &(const CanId x) const { return _identifier & x._identifier; }
CanId operator &(const int16_t x) const { return _identifier & x; } CanId operator &(const int16_t x) const { return _identifier & x; }
@ -93,45 +91,41 @@ namespace sockcanpp {
CanId operator |(const uint32_t x) const { return _identifier | x; } CanId operator |(const uint32_t x) const { return _identifier | x; }
CanId operator |(const int64_t x) const { return _identifier | x; } CanId operator |(const int64_t x) const { return _identifier | x; }
CanId operator |(const uint64_t x) const { return _identifier | x; } CanId operator |(const uint64_t x) const { return _identifier | x; }
#pragma endregion
#pragma region "Comparison Operators"
bool operator ==(CanId& x) const { return _identifier == x._identifier; } bool operator ==(CanId& x) const { return _identifier == x._identifier; }
bool operator ==(const CanId& x) const { return _identifier == x._identifier; } bool operator ==(const CanId& x) const { return _identifier == x._identifier; }
bool operator ==(const int16_t x) const { return _identifier == x; }
bool operator ==(const uint16_t x) const { return _identifier == x; }
bool operator ==(const int32_t x) const { return _identifier == x; }
bool operator ==(const uint32_t x) const { return _identifier == x; }
bool operator ==(const int64_t x) const { return (x > UINT32_MAX || x < INT32_MIN) ? false : x == _identifier; }
bool operator ==(const uint64_t x) const { return x > UINT32_MAX ? false : x == _identifier; }
bool operator ==(const int16_t x) const { return int16_t (_identifier) == x; }
bool operator ==(const uint16_t x) const { return uint16_t (_identifier) == x; }
bool operator ==(const int32_t x) const { return int32_t (_identifier) == x; }
bool operator ==(const uint32_t x) const { return uint32_t (_identifier) == x; }
bool operator ==(const int64_t x) const { return (x > UINT32_MAX || x < INT32_MIN) ? false : x == int64_t(_identifier); }
bool operator ==(const uint64_t x) const { return x > UINT32_MAX ? false : x == uint64_t(_identifier); }
bool operator !=(CanId& x) const { return _identifier != x._identifier; } bool operator !=(CanId& x) const { return _identifier != x._identifier; }
bool operator !=(const CanId& x) const { return _identifier != x._identifier; } bool operator !=(const CanId& x) const { return _identifier != x._identifier; }
bool operator !=(const int16_t x) const { return _identifier != x; }
bool operator !=(const uint16_t x) const { return _identifier != x; }
bool operator !=(const int32_t x) const { return _identifier != x; }
bool operator !=(const uint32_t x) const { return _identifier != x; }
bool operator !=(const int16_t x) const { return int16_t(_identifier) != x; }
bool operator !=(const uint16_t x) const { return uint16_t(_identifier) != x; }
bool operator !=(const int32_t x) const { return int32_t(_identifier) != x; }
bool operator !=(const uint32_t x) const { return uint32_t(_identifier) != x; }
bool operator !=(const int64_t x) const { return (x > UINT32_MAX || x < INT32_MIN) ? false : x != _identifier; } bool operator !=(const int64_t x) const { return (x > UINT32_MAX || x < INT32_MIN) ? false : x != _identifier; }
bool operator !=(const uint64_t x) const { return x > UINT32_MAX ? false : x != _identifier; } bool operator !=(const uint64_t x) const { return x > UINT32_MAX ? false : x != _identifier; }
bool operator <(CanId& x) const { return x._identifier < _identifier; } bool operator <(CanId& x) const { return x._identifier < _identifier; }
bool operator <(int32_t x) const { return x < _identifier; }
bool operator <(uint32_t x) const { return x < _identifier; }
bool operator <(int16_t x) const { return x < _identifier; }
bool operator <(uint16_t x) const { return x < _identifier; }
bool operator <(int32_t x) const { return x < int32_t(_identifier); }
bool operator <(uint32_t x) const { return x < uint32_t(_identifier); }
bool operator <(int16_t x) const { return x < int16_t(_identifier); }
bool operator <(uint16_t x) const { return x < uint16_t(_identifier); }
bool operator <=(CanId& x) const { return x._identifier <= _identifier; } bool operator <=(CanId& x) const { return x._identifier <= _identifier; }
bool operator >(CanId& x) const { return x._identifier > _identifier; } bool operator >(CanId& x) const { return x._identifier > _identifier; }
bool operator >(int32_t x) const { return x > _identifier; }
bool operator >(uint32_t x) const { return x > _identifier; }
bool operator >(int16_t x) const { return x > _identifier; }
bool operator >(uint16_t x) const { return x > _identifier; }
bool operator >(int32_t x) const { return x > int32_t(_identifier); }
bool operator >(uint32_t x) const { return x > uint32_t(_identifier); }
bool operator >(int16_t x) const { return x > int16_t(_identifier); }
bool operator >(uint16_t x) const { return x > uint16_t(_identifier); }
bool operator >=(CanId& x) const { return x._identifier >= _identifier; } bool operator >=(CanId& x) const { return x._identifier >= _identifier; }
bool operator <(const CanId& x) const { return x._identifier < _identifier; } bool operator <(const CanId& x) const { return x._identifier < _identifier; }
bool operator <=(const CanId& x) const { return x._identifier <= _identifier; } bool operator <=(const CanId& x) const { return x._identifier <= _identifier; }
bool operator >(const CanId& x) const { return x._identifier > _identifier; } bool operator >(const CanId& x) const { return x._identifier > _identifier; }
bool operator >=(const CanId& x) const { return x._identifier >= _identifier; } bool operator >=(const CanId& x) const { return x._identifier >= _identifier; }
#pragma endregion
#pragma region "Assignment Operators"
CanId operator =(const int32_t val) { CanId operator =(const int32_t val) {
uint32_t tmpVal = val; uint32_t tmpVal = val;
auto tmp = (isValidIdentifier(tmpVal) ? CanId(val) : throw system_error(error_code(0x5421, generic_category()), "INVALID CAST: ID is extended or invalid!")); auto tmp = (isValidIdentifier(tmpVal) ? CanId(val) : throw system_error(error_code(0x5421, generic_category()), "INVALID CAST: ID is extended or invalid!"));
@ -144,9 +138,7 @@ namespace sockcanpp {
} }
CanId operator =(const int64_t val) { return operator =((int32_t)val); } CanId operator =(const int64_t val) { return operator =((int32_t)val); }
#pragma endregion
#pragma region "Arithmetic Operators"
CanId operator +(CanId& x) const { return _identifier + x._identifier; } CanId operator +(CanId& x) const { return _identifier + x._identifier; }
CanId operator +(const CanId& x) const { return _identifier + x._identifier; } CanId operator +(const CanId& x) const { return _identifier + x._identifier; }
CanId operator +(const int16_t x) const { return _identifier + x; } CanId operator +(const int16_t x) const { return _identifier + x; }
@ -164,7 +156,6 @@ namespace sockcanpp {
CanId operator -(const uint32_t x) const { return _identifier - x; } CanId operator -(const uint32_t x) const { return _identifier - x; }
CanId operator -(const int64_t x) const { return _identifier - x; } CanId operator -(const int64_t x) const { return _identifier - x; }
CanId operator -(const uint64_t x) const { return _identifier - x; } CanId operator -(const uint64_t x) const { return _identifier - x; }
#pragma endregion
public: // +++ Validity Checks +++ public: // +++ Validity Checks +++
/** /**

Loading…
Cancel
Save