replaced mrw::Shared by std::shared_ptr; refs #28

master
Marc Wäckerlin 11 years ago
parent 512d32e8ba
commit cc62637188
  1. 1
      doc/examples/cardos-demo.cxx
  2. 1
      doc/examples/create-files-demo.cxx
  3. 2
      doc/examples/suisse-id-demo.hxx
  4. 8
      src/cardos.hxx
  5. 1
      src/cryptoki.cxx
  6. 8
      src/cryptoki.hxx
  7. 31
      src/pcsc.hxx
  8. 19
      src/suisseid.hxx

@ -10,6 +10,7 @@
// #include <openssl.hxx>
#include <string>
#include <mrw/checkcxx11.hxx>
#include <memory>
#include <cctype>
#include <stdexcept>

@ -14,6 +14,7 @@
#include <mrw/args.hxx>
#include <string>
#include <mrw/checkcxx11.hxx>
#include <memory>
#include <cctype>
#include <stdexcept>

@ -18,7 +18,7 @@ class TextualCycle: public suisseid::StatusCycle {
public:
// just pass the card to parent
TextualCycle(mrw::Shared<suisseid::Card> card):
TextualCycle(std::shared_ptr<suisseid::Card> card):
StatusCycle(card) {
}

@ -424,12 +424,12 @@ namespace cardos {
Commands() {}
/// Initialize with given smart card reader.
Commands(pcsc::shared_ptr<pcsc::Connection::Reader>::t r):
Commands(std::shared_ptr<pcsc::Connection::Reader> r):
_reader(r) {
}
/// Set smart card reader.
void reader(pcsc::shared_ptr<pcsc::Connection::Reader>::t r) {
void reader(std::shared_ptr<pcsc::Connection::Reader> r) {
_reader = r;
}
@ -1549,7 +1549,7 @@ namespace cardos {
protected:
pcsc::shared_ptr<pcsc::Connection::Reader>::t _reader;
std::shared_ptr<pcsc::Connection::Reader> _reader;
};
@ -1557,7 +1557,7 @@ namespace cardos {
/// Represents a CardOS Filesystem Object
class Object {
public:
typedef pcsc::shared_ptr<Object>::t Child;
typedef std::shared_ptr<Object> Child;
typedef std::vector<Child> Children;
public:
Object(const std::string& p): _path(p) {}

@ -8,6 +8,7 @@
#include <cryptoki.hxx>
#include <sstream>
#include <mrw/checkcxx11.hxx>
#include <memory>
#ifndef WIN32
#include <dlfcn.h>

@ -18,7 +18,8 @@
#include <vector>
#include <map>
#include <set>
#include <mrw/shared.hxx>
#include <mrw/checkcxx11.hxx>
#include <memory>
// for inline implementations only
#include <cryptaux.hxx>
@ -27,7 +28,6 @@
#include <cstring> // memset
#include <cassert> // assert
#include <iomanip>
#include <memory>
/*! @defgroup gcryptoki C++ Wrapper around Cryptoki API
@ -1903,7 +1903,7 @@ namespace cryptoki {
void login(const std::string& pin,
CK_USER_TYPE userType=CKU_USER) {
CRYPTOLOG("log");
_login = new Login(*this, pin, userType);
_login = std::shared_ptr<Login>(new Login(*this, pin, userType));
}
/// Logout from card
@ -1913,7 +1913,7 @@ namespace cryptoki {
_login.reset();
}
mrw::Shared<Login> _login;
std::shared_ptr<Login> _login;
//@}

@ -56,27 +56,12 @@
#include <vector>
#include <map>
#include <mrw/checkcxx11.hxx>
#include <memory>
#include <sstream>
#include <iomanip>
#if __cplusplus > 199711L
namespace pcsc {
template<typename T> struct shared_ptr {
typedef std::shared_ptr<T> t;
};
}
#else
#warning Old compiler (pre 2011): using boost as replacement for std
#include <boost/shared_ptr.hpp>
namespace pcsc {
template<typename T> struct shared_ptr {
typedef boost::shared_ptr<T> t;
};
}
#endif
/*! @defgroup gpcsc C++ Wrapper around pcsc-lite API
This library is a C++ wrapper to the awful pcsc-lite interface.
@ -200,7 +185,7 @@ namespace pcsc {
/*! @note Please note that the Reader is required in the
destructor und must therefore live longer than the
Transaction instance. */
Transaction(shared_ptr<Reader>::t r):
Transaction(std::shared_ptr<Reader> r):
_reader(r), _running(true) {
CRYPTOLOG("log");
_reader->beginTransaction();
@ -218,7 +203,7 @@ namespace pcsc {
_running = false;
}
private:
shared_ptr<Reader>::t _reader;
std::shared_ptr<Reader> _reader;
bool _running;
};
@ -422,7 +407,7 @@ namespace pcsc {
friend class Connection;
//! Establishes a connection to the given named cardreader
Reader(const std::string& nm, shared_ptr<Connection>::t c,
Reader(const std::string& nm, std::shared_ptr<Connection> c,
DWORD mode=SCARD_SHARE_SHARED,
DWORD protocol=SCARD_PROTOCOL_T1):
name(nm), _connection(c) {
@ -439,7 +424,7 @@ namespace pcsc {
//...........................................................variables
private:
shared_ptr<Connection>::t _connection;
std::shared_ptr<Connection> _connection;
SCARDHANDLE _id;
DWORD _state;
DWORD _protocol;
@ -514,12 +499,12 @@ namespace pcsc {
//! Get a reader, open a connection if not already open.
/*! First use scan() to get a list of readers, then open a
connection to the reader, then access it. */
static shared_ptr<Reader>::t reader(const std::string& name,
static std::shared_ptr<Reader> reader(const std::string& name,
Scope s=USER, bool exceptions=true) {
CRYPTOLOG("get reader: "<<name);
return shared_ptr<Reader>::t
return std::shared_ptr<Reader>
(new Reader(name,
shared_ptr<Connection>::t
std::shared_ptr<Connection>
(new Connection(s, exceptions))));
}

@ -12,7 +12,8 @@
#include <cryptoki.hxx>
#include <pcsc.hxx>
#include <mrw/vector.hxx>
#include <mrw/shared.hxx>
#include <mrw/checkcxx11.hxx>
#include <memory>
/*! @defgroup gsuisseid C++ library to access SuisseID smart cards
@ -185,7 +186,7 @@ namespace suisseid {
/** Instance requires a connenction to the reader an a cryptoky
library. This is passes automatically when this class is
instanciated through suisseid::Scanner. */
Card(mrw::Shared<pcsc::Connection::Reader> reader,
Card(std::shared_ptr<pcsc::Connection::Reader> reader,
const cryptoki::Library& cryptoki):
cardos::Commands(reader),
_cryptoki(cryptoki) {
@ -205,7 +206,7 @@ namespace suisseid {
pcsc::Connection::Reader::Transaction lock(card.reader());
[... do some low level stuff ...]
@endcode */
mrw::Shared<pcsc::Connection::Reader> reader() {
std::shared_ptr<pcsc::Connection::Reader> reader() {
return _reader;
}
@ -290,7 +291,7 @@ namespace suisseid {
public:
/// @copydoc Card::Card
Post(mrw::Shared<pcsc::Connection::Reader> reader,
Post(std::shared_ptr<pcsc::Connection::Reader> reader,
const cryptoki::Library& cryptoki):
Card(reader, cryptoki), _minPinLen(0), _maxPinLen(0) {
}
@ -368,7 +369,7 @@ namespace suisseid {
};
//! List of cards, returned by @ref suisseid::Scanner::scan.
typedef std::vector<mrw::Shared<Card> > Cards;
typedef std::vector<std::shared_ptr<Card> > Cards;
//! Auxiliary SuisseID card manager.
/** Use this manager to scan your system for SuisseID cards.
@ -418,7 +419,7 @@ namespace suisseid {
CRYPTOLOG("number of cryptoki-readers for "<<*reader
<<": "<<slots.size());
if (slots.size()==1)
res.push_back(dynamic_cast<Card*>
res.push_back(std::shared_ptr<Card>
(new Post(pcsc::Connection::reader(*reader),
_cryptoki)));
}
@ -435,7 +436,7 @@ namespace suisseid {
public:
StatusCycle(mrw::Shared<Card> card, unsigned int maxRetries = 20):
StatusCycle(std::shared_ptr<Card> card, unsigned int maxRetries = 20):
_card(card), _maxRetries(maxRetries), _counter(0) {
}
@ -449,7 +450,7 @@ namespace suisseid {
protected:
mrw::Shared<Card> card() {
std::shared_ptr<Card> card() {
return _card;
}
@ -595,7 +596,7 @@ namespace suisseid {
return start();
}
mrw::Shared<Card> _card;
std::shared_ptr<Card> _card;
unsigned int _maxRetries;
unsigned int _counter;

Loading…
Cancel
Save