Keypop Card C++ API 2.0.0
Reference Card API for C++
ApduRequestSpi.hpp
Go to the documentation of this file.
1/**************************************************************************************************
2 * Copyright (c) 2024 Calypso Networks Association https://calypsonet.org/ *
3 * *
4 * This program and the accompanying materials are made available under the *
5 * terms of the MIT License which is available at https://opensource.org/licenses/MIT. *
6 * *
7 * SPDX-License-Identifier: MIT *
8 **************************************************************************************************/
9
10#pragma once
11
12#include <cstdint>
13#include <memory>
14#include <ostream>
15#include <string>
16#include <vector>
17
18namespace keypop {
19namespace card {
20namespace spi {
21
29public:
33 virtual ~ApduRequestSpi() = default;
34
41 virtual std::vector<uint8_t>& getApdu() = 0;
42
49 virtual const std::vector<int>& getSuccessfulStatusWords() const = 0;
50
59 virtual const std::string& getInfo() const = 0;
60
64 friend std::ostream&
65 operator<<(std::ostream& os, ApduRequestSpi& ars) {
66 os << "APDU_REQUEST_SPI: {"
67 << "APDU: " << ars.getApdu() << ", "
68 << "SUCCESSFUL_STATUS_WORDS: " << ars.getSuccessfulStatusWords() << ", "
69 << "INFO: " << ars.getInfo() << "}";
70
71 return os;
72 }
73
77 friend std::ostream&
78 operator<<(std::ostream& os, const std::shared_ptr<ApduRequestSpi> ars) {
79 if (ars == nullptr) {
80 os << "APDU_REQUEST_SPI: null";
81 } else {
82 os << *ars.get();
83 }
84
85 return os;
86 }
87
91 friend std::ostream&
92 operator<<(std::ostream& os, const std::vector<std::shared_ptr<ApduRequestSpi>>& ars) {
93 os << "APDU_REQUEST_SPIS: {";
94
95 for (auto it = ars.begin(); it != ars.end(); it++) {
96 if (it != ars.begin()) {
97 os << ", ";
98 }
99 os << *it;
100 }
101
102 os << "}";
103
104 return os;
105 }
106};
107
108} /* namespace spi */
109} /* namespace card */
110} /* namespace keypop */
virtual const std::string & getInfo() const =0
virtual std::vector< uint8_t > & getApdu()=0
virtual const std::vector< int > & getSuccessfulStatusWords() const =0
friend std::ostream & operator<<(std::ostream &os, ApduRequestSpi &ars)