aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--device.cc15
-rw-r--r--libnitrokey/device.h3
2 files changed, 18 insertions, 0 deletions
diff --git a/device.cc b/device.cc
index aabcbfc..35aefca 100644
--- a/device.cc
+++ b/device.cc
@@ -57,6 +57,21 @@ Option<DeviceModel> nitrokey::device::product_id_to_model(uint16_t product_id) {
std::atomic_int Device::instances_count{0};
std::chrono::milliseconds Device::default_delay {0} ;
+std::ostream& nitrokey::device::operator<<(std::ostream& stream, DeviceModel model) {
+ switch (model) {
+ case DeviceModel::PRO:
+ stream << "Pro";
+ break;
+ case DeviceModel::STORAGE:
+ stream << "Storage";
+ break;
+ default:
+ stream << "Unknown";
+ break;
+ }
+ return stream;
+}
+
Device::Device(const uint16_t vid, const uint16_t pid, const DeviceModel model,
const milliseconds send_receive_delay, const int retry_receiving_count,
const milliseconds retry_timeout)
diff --git a/libnitrokey/device.h b/libnitrokey/device.h
index eab3888..4b1c239 100644
--- a/libnitrokey/device.h
+++ b/libnitrokey/device.h
@@ -26,6 +26,7 @@
#include <cstdint>
#include <memory>
#include <string>
+#include <ostream>
#include <vector>
#include "misc.h"
@@ -52,6 +53,8 @@ enum class DeviceModel{
STORAGE
};
+std::ostream& operator<<(std::ostream& stream, DeviceModel model);
+
/**
* The USB vendor ID for Nitrokey devices.
*/