Skip to content

Commit 8e1ad68

Browse files
committed
Make Reader simple struct
Signed-off-by: Raul Metsma <raul@metsma.ee>
1 parent 333fff8 commit 8e1ad68

File tree

15 files changed

+55
-339
lines changed

15 files changed

+55
-339
lines changed

.github/workflows/cmake-linux-fedora.yml

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,14 @@ name: CMake (Fedora Linux)
22

33
on: [push, pull_request]
44

5-
env:
6-
BUILD_TYPE: RelWithDebInfo
7-
85
jobs:
96
build:
107
runs-on: ubuntu-latest
11-
continue-on-error: ${{ matrix.experimental }}
8+
continue-on-error: ${{ matrix.container == 'fedora:rawhide' }}
129
strategy:
1310
matrix:
14-
container: ['fedora:latest']
15-
experimental: [false]
16-
include:
17-
- container: 'fedora:rawhide'
18-
experimental: true
11+
container: ['fedora:latest', 'fedora:rawhide']
12+
build_type: [Release, RelWithDebInfo]
1913

2014
container:
2115
image: ${{ matrix.container }}
@@ -27,10 +21,10 @@ jobs:
2721
- uses: actions/checkout@v4
2822

2923
- name: Configure CMake
30-
run: cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -S . -B build
24+
run: cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -S . -B build
3125

3226
- name: Build
33-
run: cmake --build build --config $BUILD_TYPE -j $(nproc)
27+
run: cmake --build build --config ${{ matrix.build_type }} -j $(nproc)
3428

3529
- name: Test
36-
run: ctest -V -C $BUILD_TYPE --test-dir build
30+
run: ctest -V -C ${{ matrix.build_type }} --test-dir build

include/electronic-id/electronic-id.hpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class ElectronicID
4242
using byte_type = pcsc_cpp::byte_type;
4343
using Signature = std::pair<byte_vector, SignatureAlgorithm>;
4444

45-
enum Type {
45+
enum Type : uint8_t {
4646
EstEID,
4747
FinEID,
4848
LatEID,
@@ -125,7 +125,6 @@ class CardInfo
125125

126126
const pcsc_cpp::Reader& reader() const { return _reader; }
127127
const ElectronicID& eid() const { return *_eid; }
128-
const ElectronicID::ptr eidPtr() const { return _eid; }
129128

130129
private:
131130
pcsc_cpp::Reader _reader;
@@ -216,7 +215,7 @@ class MsCryptoApiError : public Error
216215
class AutoSelectFailed : public Error
217216
{
218217
public:
219-
enum class Reason {
218+
enum class Reason : uint8_t {
220219
SERVICE_NOT_RUNNING,
221220
NO_READERS,
222221
SINGLE_READER_NO_CARD,
@@ -241,7 +240,7 @@ class VerifyPinFailed : public Error
241240
template <typename T>
242241
using observer_ptr = T*;
243242

244-
enum class Status {
243+
enum class Status : uint8_t {
245244
RETRY_ALLOWED,
246245
INVALID_PIN_LENGTH,
247246
PIN_ENTRY_TIMEOUT,
@@ -264,4 +263,14 @@ class VerifyPinFailed : public Error
264263
int8_t _retries;
265264
};
266265

266+
// Workaround gcc 14.2 bug
267+
struct VectorComparator
268+
{
269+
PCSC_CPP_CONSTEXPR_VECTOR bool operator()(const std::vector<unsigned char>& a,
270+
const std::vector<unsigned char>& b) const
271+
{
272+
return std::lexicographical_compare(a.begin(), a.end(), b.begin(), b.end());
273+
}
274+
};
275+
267276
} // namespace electronic_id

lib/libpcsc-cpp/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ add_library(${PROJECT_NAME}
99
include/${PROJECT_NAME}/${PROJECT_NAME}.hpp
1010
include/${PROJECT_NAME}/${PROJECT_NAME}-utils.hpp
1111
include/${PROJECT_NAME}/comp_winscard.hpp
12-
include/flag-set-cpp/flag_set.hpp
1312
include/magic_enum/magic_enum.hpp
1413
src/Context.hpp
15-
src/Reader.cpp
1614
src/SCardCall.hpp
1715
src/SmartCard.cpp
1816
src/listReaders.cpp

lib/libpcsc-cpp/include/flag-set-cpp/flag_set.hpp

Lines changed: 0 additions & 175 deletions
This file was deleted.

lib/libpcsc-cpp/include/pcsc-cpp/pcsc-cpp.hpp

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222

2323
#pragma once
2424

25-
#include "flag-set-cpp/flag_set.hpp"
26-
2725
#include <cstdint>
2826
#include <limits>
2927
#include <memory>
28+
#include <stdexcept>
29+
#include <string>
3030
#include <vector>
3131

3232
// The rule of five (C++ Core guidelines C.21).
@@ -254,39 +254,14 @@ class SmartCard
254254
};
255255

256256
/** Reader provides card reader information, status and gives access to the smart card in it. */
257-
class Reader
257+
struct Reader
258258
{
259-
public:
260-
enum class Status {
261-
UNAWARE,
262-
IGNORE,
263-
CHANGED,
264-
UNKNOWN,
265-
UNAVAILABLE,
266-
EMPTY,
267-
PRESENT,
268-
ATRMATCH,
269-
EXCLUSIVE,
270-
INUSE,
271-
MUTE,
272-
UNPOWERED,
273-
_
274-
};
275-
276-
Reader(ContextPtr context, string_t name, byte_vector cardAtr, flag_set<Status> status);
277-
278259
SmartCard::ptr connectToCard() const { return std::make_unique<SmartCard>(ctx, name, cardAtr); }
279260

280-
bool isCardInserted() const { return status[Status::PRESENT]; }
281-
282-
std::string statusString() const;
283-
261+
const ContextPtr ctx;
284262
const string_t name;
285263
const byte_vector cardAtr;
286-
const flag_set<Status> status;
287-
288-
private:
289-
ContextPtr ctx;
264+
const bool isCardPresent;
290265
};
291266

292267
/**

lib/libpcsc-cpp/src/Reader.cpp

Lines changed: 0 additions & 54 deletions
This file was deleted.

0 commit comments

Comments
 (0)