Keyple Plugin PC/SC C++ Library - 2.5.2
Component of the Keyple C++ middleware
PcscReader.cpp
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ *
3 * *
4 * See the NOTICE file(s) distributed with this work for additional *
5 * information regarding copyright ownership. *
6 * *
7 * This program and the accompanying materials are made available under the *
8 * terms of the Eclipse Public License 2.0 which is available at *
9 * http://www.eclipse.org/legal/epl-2.0 *
10 * *
11 * SPDX-License-Identifier: EPL-2.0 *
12 ******************************************************************************/
13
14#include "keyple/plugin/pcsc/PcscReader.hpp"
15
16namespace keyple {
17namespace plugin {
18namespace pcsc {
19
20/* ISO PROTOCOL ------------------------------------------------------------- */
21
22const PcscReader::IsoProtocol PcscReader::IsoProtocol::ANY("*");
23const PcscReader::IsoProtocol PcscReader::IsoProtocol::DIRECT("DIRECT");
24const PcscReader::IsoProtocol PcscReader::IsoProtocol::T0("T=0");
25const PcscReader::IsoProtocol PcscReader::IsoProtocol::T1("T=1");
26const PcscReader::IsoProtocol PcscReader::IsoProtocol::TCL("T=CL");
27
28PcscReader::IsoProtocol::IsoProtocol(const std::string& value)
29: mValue(value)
30{
31}
32
33const std::string&
34PcscReader::IsoProtocol::getValue() const
35{
36 return mValue;
37}
38
39std::ostream&
40operator<<(std::ostream& os, const PcscReader::IsoProtocol& ip)
41{
42 os << "ISO_PROTOCOL: ";
43
44 if (ip == PcscReader::IsoProtocol::ANY) {
45 os << "ANY";
46 } else if (ip == PcscReader::IsoProtocol::DIRECT) {
47 os << "DIRECT";
48 } else if (ip == PcscReader::IsoProtocol::T0) {
49 os << "T0";
50 } else if (ip == PcscReader::IsoProtocol::T1) {
51 os << "T1";
52 } else if (ip == PcscReader::IsoProtocol::TCL) {
53 os << "TCL";
54 } else {
55 os << "UNKNOWN";
56 }
57
58 return os;
59}
60
61bool
62PcscReader::IsoProtocol::operator==(const PcscReader::IsoProtocol& ip) const
63{
64 return ip.getValue() == this->getValue();
65}
66
67/* SHARING MODE ------------------------------------------------------------- */
68
69std::ostream&
70operator<<(std::ostream& os, const PcscReader::SharingMode sm)
71{
72 os << "SHARING_MODE: ";
73
74 switch (sm) {
75 case PcscReader::SharingMode::EXCLUSIVE:
76 os << "EXCLUSIVE";
77 break;
78 case PcscReader::SharingMode::SHARED:
79 os << "SHARED";
80 break;
81 default:
82 os << "UNKNOWN";
83 break;
84 }
85
86 return os;
87}
88
89/* DISCONNECTION MODE ------------------------------------------------------- */
90
91std::ostream&
92operator<<(std::ostream& os, const PcscReader::DisconnectionMode dm)
93{
94 os << "DISCONNECTION_MODE: ";
95
96 switch (dm) {
97 case PcscReader::DisconnectionMode::RESET:
98 os << "RESET";
99 break;
100 case PcscReader::DisconnectionMode::LEAVE:
101 os << "LEAVE";
102 break;
103 default:
104 os << "UNKNOWN";
105 break;
106 }
107
108 return os;
109}
110
111} /* namespace pcsc */
112} /* namespace plugin */
113} /* namespace keyple */
PcscReader::DisconnectionMode DisconnectionMode
std::ostream & operator<<(std::ostream &os, const PcscReader::DisconnectionMode dm)
Definition: PcscReader.cpp:92
Definition: Card.cpp:20