aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-09-14 10:45:55 +0200
committerSven Gothel <[email protected]>2020-09-14 10:45:55 +0200
commitcfb04ae46588d0904315c65f2c021026ac395bbc (patch)
tree4c82a0280245e1c078257c867e7425f6e9dee796 /src
parent22fbf43bf956b5cebabaee326dfe625333bce0f6 (diff)
C++: First round propagating noexcept: Adding nocheck '_nc' variants in OctetTypes and use them if allowed.
Diffstat (limited to 'src')
-rw-r--r--src/direct_bt/ATTPDUTypes.cpp4
-rw-r--r--src/direct_bt/BTTypes.cpp16
-rw-r--r--src/direct_bt/BasicTypes.cpp22
3 files changed, 21 insertions, 21 deletions
diff --git a/src/direct_bt/ATTPDUTypes.cpp b/src/direct_bt/ATTPDUTypes.cpp
index 88747d25..5276f777 100644
--- a/src/direct_bt/ATTPDUTypes.cpp
+++ b/src/direct_bt/ATTPDUTypes.cpp
@@ -74,7 +74,7 @@ using namespace direct_bt;
#define CASE_TO_STRING(V) case V: return #V;
-std::string AttPDUMsg::getOpcodeString(const Opcode opc) {
+std::string AttPDUMsg::getOpcodeString(const Opcode opc) noexcept {
switch(opc) {
OPCODE_ENUM(CASE_TO_STRING)
default: ; // fall through intended
@@ -82,7 +82,7 @@ std::string AttPDUMsg::getOpcodeString(const Opcode opc) {
return "Unknown Opcode";
}
-std::string AttErrorRsp::getPlainErrorString(const ErrorCode errorCode) {
+std::string AttErrorRsp::getPlainErrorString(const ErrorCode errorCode) noexcept {
switch(errorCode) {
case INVALID_HANDLE: return "Invalid Handle";
case NO_READ_PERM: return "Read Not Permitted";
diff --git a/src/direct_bt/BTTypes.cpp b/src/direct_bt/BTTypes.cpp
index 6310a1a2..a71a6d0a 100644
--- a/src/direct_bt/BTTypes.cpp
+++ b/src/direct_bt/BTTypes.cpp
@@ -40,7 +40,7 @@ using namespace direct_bt;
#define CASE_TO_STRING(V) case V: return #V;
#define CASE2_TO_STRING(U,V) case U::V: return #V;
-BDAddressType direct_bt::getBDAddressType(const HCILEPeerAddressType hciPeerAddrType) {
+BDAddressType direct_bt::getBDAddressType(const HCILEPeerAddressType hciPeerAddrType) noexcept {
switch(hciPeerAddrType) {
case HCILEPeerAddressType::PUBLIC:
return BDADDR_LE_PUBLIC;
@@ -62,7 +62,7 @@ BDAddressType direct_bt::getBDAddressType(const HCILEPeerAddressType hciPeerAddr
X(HCILEPeerAddressType,RANDOM_STATIC_IDENTITY) \
X(HCILEPeerAddressType,UNDEFINED)
-std::string direct_bt::getHCILEPeerAddressTypeString(const HCILEPeerAddressType type) {
+std::string direct_bt::getHCILEPeerAddressTypeString(const HCILEPeerAddressType type) noexcept {
switch(type) {
CHAR_DECL_HCILEPeerAddressType_ENUM(CASE2_TO_STRING)
default: ; // fall through intended
@@ -70,7 +70,7 @@ std::string direct_bt::getHCILEPeerAddressTypeString(const HCILEPeerAddressType
return "Unknown HCILEPeerAddressType";
}
-BDAddressType direct_bt::getBDAddressType(const HCILEOwnAddressType hciOwnAddrType) {
+BDAddressType direct_bt::getBDAddressType(const HCILEOwnAddressType hciOwnAddrType) noexcept {
switch(hciOwnAddrType) {
case HCILEOwnAddressType::PUBLIC:
return BDADDR_LE_PUBLIC;
@@ -92,7 +92,7 @@ BDAddressType direct_bt::getBDAddressType(const HCILEOwnAddressType hciOwnAddrTy
X(HCILEOwnAddressType,RESOLVABLE_OR_RANDOM) \
X(HCILEOwnAddressType,UNDEFINED)
-std::string direct_bt::getHCILEOwnAddressTypeString(const HCILEOwnAddressType type) {
+std::string direct_bt::getHCILEOwnAddressTypeString(const HCILEOwnAddressType type) noexcept {
switch(type) {
CHAR_DECL_HCILEOwnAddressType_ENUM(CASE2_TO_STRING)
default: ; // fall through intended
@@ -107,7 +107,7 @@ std::string direct_bt::getHCILEOwnAddressTypeString(const HCILEOwnAddressType ty
X(BDADDR_LE_RANDOM) \
X(BDADDR_UNDEFINED)
-std::string direct_bt::getBDAddressTypeString(const BDAddressType type) {
+std::string direct_bt::getBDAddressTypeString(const BDAddressType type) noexcept {
switch(type) {
CHAR_DECL_BDADDRESSTYPE_ENUM(CASE_TO_STRING)
default: ; // fall through intended
@@ -122,7 +122,7 @@ std::string direct_bt::getBDAddressTypeString(const BDAddressType type) {
X(BLERandomAddressType,STATIC_PUBLIC) \
X(BLERandomAddressType,UNDEFINED)
-std::string direct_bt::getBLERandomAddressTypeString(const BLERandomAddressType type) {
+std::string direct_bt::getBLERandomAddressTypeString(const BLERandomAddressType type) noexcept {
switch(type) {
CHAR_DECL_LERANDOMADDRESSTYPE_ENUM(CASE2_TO_STRING)
default: ; // fall through intended
@@ -130,7 +130,7 @@ std::string direct_bt::getBLERandomAddressTypeString(const BLERandomAddressType
return "Unknown BLERandomAddressType";
}
-BLERandomAddressType EUI48::getBLERandomAddressType(const BDAddressType addressType) const {
+BLERandomAddressType EUI48::getBLERandomAddressType(const BDAddressType addressType) const noexcept {
if( BDAddressType::BDADDR_LE_RANDOM != addressType ) {
return BLERandomAddressType::UNDEFINED;
}
@@ -176,7 +176,7 @@ EUI48::EUI48(const std::string str) {
// hence no endian conversion
}
-EUI48::EUI48(const uint8_t * _b) {
+EUI48::EUI48(const uint8_t * _b) noexcept {
memcpy(b, _b, sizeof(b));
}
diff --git a/src/direct_bt/BasicTypes.cpp b/src/direct_bt/BasicTypes.cpp
index f1aea683..f0c0c54d 100644
--- a/src/direct_bt/BasicTypes.cpp
+++ b/src/direct_bt/BasicTypes.cpp
@@ -78,7 +78,7 @@ const char* direct_bt::RuntimeException::what() const noexcept {
#endif
}
-std::string direct_bt::get_string(const uint8_t *buffer, int const buffer_len, int const max_len) {
+std::string direct_bt::get_string(const uint8_t *buffer, int const buffer_len, int const max_len) noexcept {
const int cstr_len = std::min(buffer_len, max_len);
char cstr[max_len+1]; // EOS
memcpy(cstr, buffer, cstr_len);
@@ -208,9 +208,13 @@ std::string direct_bt::uint64HexString(const uint64_t v, const bool leading0X) {
return str;
}
+std::string direct_bt::aptrHexString(const void * v, const bool leading0X) {
+ return uint64HexString((uint64_t)v, leading0X);
+}
+
static const char* HEX_ARRAY = "0123456789ABCDEF";
-std::string direct_bt::bytesHexString(const uint8_t * bytes, const int offset, const int length, const bool lsbFirst, const bool leading0X) {
+std::string direct_bt::bytesHexString(const uint8_t * bytes, const int offset, const int length, const bool lsbFirst, const bool leading0X) noexcept {
std::string str;
if( nullptr == bytes ) {
@@ -244,7 +248,7 @@ std::string direct_bt::bytesHexString(const uint8_t * bytes, const int offset, c
return str;
}
-std::string direct_bt::int32SeparatedString(const int32_t v, const char separator) {
+std::string direct_bt::int32SeparatedString(const int32_t v, const char separator) noexcept {
// INT32_MIN: -2147483648 int32_t 11 chars
// INT32_MIN: -2,147,483,648 int32_t 14 chars
// INT32_MAX: 2147483647 int32_t 10 chars
@@ -273,7 +277,7 @@ std::string direct_bt::int32SeparatedString(const int32_t v, const char separato
return std::string(dst, p_dst - dst);
}
-std::string direct_bt::uint32SeparatedString(const uint32_t v, const char separator) {
+std::string direct_bt::uint32SeparatedString(const uint32_t v, const char separator) noexcept {
// UINT32_MAX: 4294967295 uint32_t 10 chars
// UINT32_MAX: 4,294,967,295 uint32_t 13 chars
char src[16]; // aligned 4 byte
@@ -295,7 +299,7 @@ std::string direct_bt::uint32SeparatedString(const uint32_t v, const char separa
return std::string(dst, p_dst - dst);
}
-std::string direct_bt::uint64SeparatedString(const uint64_t v, const char separator) {
+std::string direct_bt::uint64SeparatedString(const uint64_t v, const char separator) noexcept {
// UINT64_MAX: 18446744073709551615 uint64_t 20 chars
// UINT64_MAX: 18,446,744,073,709,551,615 uint64_t 26 chars
char src[28]; // aligned 4 byte
@@ -317,11 +321,7 @@ std::string direct_bt::uint64SeparatedString(const uint64_t v, const char separa
return std::string(dst, p_dst - dst);
}
-std::string direct_bt::aptrHexString(const void * v, const bool leading0X) {
- return uint64HexString((uint64_t)v, leading0X);
-}
-
-void direct_bt::trimInPlace(std::string &s) {
+void direct_bt::trimInPlace(std::string &s) noexcept {
s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int ch) {
return !std::isspace(ch);
}));
@@ -330,7 +330,7 @@ void direct_bt::trimInPlace(std::string &s) {
}).base(), s.end());
}
-std::string direct_bt::trimCopy(const std::string &_s) {
+std::string direct_bt::trimCopy(const std::string &_s) noexcept {
std::string s(_s);
trimInPlace(s);
return s;