Skip to content
This repository was archived by the owner on May 16, 2024. It is now read-only.

Commit 0483f24

Browse files
committed
feat(ResponseApdu): add toSW()
WE2-405 Signed-off-by: Mart Somermaa <[email protected]>
1 parent ccb84b1 commit 0483f24

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

include/pcsc-cpp/pcsc-cpp.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ using string_t = std::string;
4242
class Context;
4343
using ContextPtr = std::shared_ptr<Context>;
4444

45+
/** Returns the value of the response status bytes SW1 and SW2 as a single status word SW. */
46+
inline constexpr uint16_t toSW(byte_vector::value_type sw1, byte_vector::value_type sw2)
47+
{
48+
return sw1 << 8 | sw2;
49+
}
50+
4551
/** Struct that wraps response APDUs. */
4652
struct ResponseApdu
4753
{
@@ -93,6 +99,8 @@ struct ResponseApdu
9399
return bytes;
94100
}
95101

102+
uint16_t toSW() const { return pcsc_cpp::toSW(sw1, sw2); }
103+
96104
bool isOK() const { return sw1 == OK && sw2 == 0x00; }
97105

98106
// TODO: friend function toString() in utilities.hpp

0 commit comments

Comments
 (0)