Cpp: Remove last usages of boost
authorAndre Heinecke <aheinecke@intevation.de>
Mon, 11 Apr 2016 13:50:17 +0000 (15:50 +0200)
committerAndre Heinecke <aheinecke@intevation.de>
Mon, 11 Apr 2016 15:00:59 +0000 (17:00 +0200)
* lang/cpp/src/configuration.cpp: Use std::remove_pointer.
  (Configuration::operator<<): std::for_each.
* lang/cpp/src/context.cpp: Delete manually instead of scoped ptr.
* lang/cpp/src/scdgetinfoassuantransaction.cpp: Use static_assert.
  (to_reader_list): Tokenize with getline.

lang/cpp/src/configuration.cpp
lang/cpp/src/context.cpp
lang/cpp/src/scdgetinfoassuantransaction.cpp

index 4bd0186..7ef2883 100644 (file)
@@ -26,8 +26,6 @@
 
 #include <gpgme.h>
 
 
 #include <gpgme.h>
 
-#include <boost/foreach.hpp>
-
 #include <iterator>
 #include <algorithm>
 #include <ostream>
 #include <iterator>
 #include <algorithm>
 #include <ostream>
 using namespace GpgME;
 using namespace GpgME::Configuration;
 
 using namespace GpgME;
 using namespace GpgME::Configuration;
 
-typedef std::shared_ptr< boost::remove_pointer<gpgme_conf_opt_t>::type > shared_gpgme_conf_opt_t;
-typedef std::weak_ptr< boost::remove_pointer<gpgme_conf_opt_t>::type > weak_gpgme_conf_opt_t;
+typedef std::shared_ptr< std::remove_pointer<gpgme_conf_opt_t>::type > shared_gpgme_conf_opt_t;
+typedef std::weak_ptr< std::remove_pointer<gpgme_conf_opt_t>::type > weak_gpgme_conf_opt_t;
 
 
-typedef std::shared_ptr< boost::remove_pointer<gpgme_conf_arg_t>::type > shared_gpgme_conf_arg_t;
-typedef std::weak_ptr< boost::remove_pointer<gpgme_conf_arg_t>::type > weak_gpgme_conf_arg_t;
+typedef std::shared_ptr< std::remove_pointer<gpgme_conf_arg_t>::type > shared_gpgme_conf_arg_t;
+typedef std::weak_ptr< std::remove_pointer<gpgme_conf_arg_t>::type > weak_gpgme_conf_arg_t;
 
 
-typedef std::shared_ptr< boost::remove_pointer<gpgme_ctx_t>::type > shared_gpgme_ctx_t;
-typedef std::weak_ptr< boost::remove_pointer<gpgme_ctx_t>::type > weak_gpgme_ctx_t;
+typedef std::shared_ptr< std::remove_pointer<gpgme_ctx_t>::type > shared_gpgme_ctx_t;
+typedef std::weak_ptr< std::remove_pointer<gpgme_ctx_t>::type > weak_gpgme_ctx_t;
 
 namespace
 {
 
 namespace
 {
@@ -898,14 +896,14 @@ std::ostream &Configuration::operator<<(std::ostream &os, const Argument &a)
                 os << v.size() << ':';
                 // can't use std::copy + ostream_iterator here, since we need the protect() call
                 bool first = true;
                 os << v.size() << ':';
                 // can't use std::copy + ostream_iterator here, since we need the protect() call
                 bool first = true;
-                BOOST_FOREACH(const char *s, v) {
+                std::for_each(v.begin(), v.end(), [&first, &os](const char *s) {
                     if (first) {
                         first = false;
                     } else {
                         os << ',';
                     }
                     os << protect(s);
                     if (first) {
                         first = false;
                     } else {
                         os << ',';
                     }
                     os << protect(s);
-                }
+                });
             } else {
                 os << protect(a.stringValue());
             }
             } else {
                 os << protect(a.stringValue());
             }
index 398836c..93244b4 100644 (file)
@@ -45,8 +45,6 @@
 
 #include <gpgme.h>
 
 
 #include <gpgme.h>
 
-#include <boost/scoped_array.hpp>
-
 #include <istream>
 #ifndef NDEBUG
 #include <iostream>
 #include <istream>
 #ifndef NDEBUG
 #include <iostream>
@@ -584,7 +582,7 @@ ImportResult Context::importKeys(const std::vector<Key> &kk)
     d->lasterr = make_error(GPG_ERR_NOT_IMPLEMENTED);
 
     bool shouldHaveResult = false;
     d->lasterr = make_error(GPG_ERR_NOT_IMPLEMENTED);
 
     bool shouldHaveResult = false;
-    const boost::scoped_array<gpgme_key_t> keys(new gpgme_key_t[ kk.size() + 1 ]);
+    gpgme_key_t * const keys = new gpgme_key_t[ kk.size() + 1 ];
     gpgme_key_t *keys_it = &keys[0];
     for (std::vector<Key>::const_iterator it = kk.begin(), end = kk.end() ; it != end ; ++it) {
         if (it->impl()) {
     gpgme_key_t *keys_it = &keys[0];
     for (std::vector<Key>::const_iterator it = kk.begin(), end = kk.end() ; it != end ; ++it) {
         if (it->impl()) {
@@ -592,7 +590,7 @@ ImportResult Context::importKeys(const std::vector<Key> &kk)
         }
     }
     *keys_it++ = 0;
         }
     }
     *keys_it++ = 0;
-    d->lasterr = gpgme_op_import_keys(d->ctx, keys.get());
+    d->lasterr = gpgme_op_import_keys(d->ctx, keys);
     shouldHaveResult = true;
     if ((gpgme_err_code(d->lasterr) == GPG_ERR_NOT_IMPLEMENTED ||
             gpgme_err_code(d->lasterr) == GPG_ERR_NOT_SUPPORTED) &&
     shouldHaveResult = true;
     if ((gpgme_err_code(d->lasterr) == GPG_ERR_NOT_IMPLEMENTED ||
             gpgme_err_code(d->lasterr) == GPG_ERR_NOT_SUPPORTED) &&
@@ -623,6 +621,7 @@ ImportResult Context::importKeys(const std::vector<Key> &kk)
             shouldHaveResult = true;
         }
     }
             shouldHaveResult = true;
         }
     }
+    delete[] keys;
     if (shouldHaveResult) {
         return ImportResult(d->ctx, Error(d->lasterr));
     } else {
     if (shouldHaveResult) {
         return ImportResult(d->ctx, Error(d->lasterr));
     } else {
@@ -640,7 +639,7 @@ Error Context::startKeyImport(const Data &data)
 Error Context::startKeyImport(const std::vector<Key> &kk)
 {
     d->lastop = Private::Import;
 Error Context::startKeyImport(const std::vector<Key> &kk)
 {
     d->lastop = Private::Import;
-    const boost::scoped_array<gpgme_key_t> keys(new gpgme_key_t[ kk.size() + 1 ]);
+    gpgme_key_t * const keys = new gpgme_key_t[ kk.size() + 1 ];
     gpgme_key_t *keys_it = &keys[0];
     for (std::vector<Key>::const_iterator it = kk.begin(), end = kk.end() ; it != end ; ++it) {
         if (it->impl()) {
     gpgme_key_t *keys_it = &keys[0];
     for (std::vector<Key>::const_iterator it = kk.begin(), end = kk.end() ; it != end ; ++it) {
         if (it->impl()) {
@@ -648,7 +647,9 @@ Error Context::startKeyImport(const std::vector<Key> &kk)
         }
     }
     *keys_it++ = 0;
         }
     }
     *keys_it++ = 0;
-    return Error(d->lasterr = gpgme_op_import_keys_start(d->ctx, keys.get()));
+    Error err = Error(d->lasterr = gpgme_op_import_keys_start(d->ctx, keys));
+    delete[] keys;
+    return err;
 }
 
 ImportResult Context::importResult() const
 }
 
 ImportResult Context::importResult() const
index a07ed96..073d772 100644 (file)
 #include "data.h"
 #include "util.h"
 
 #include "data.h"
 #include "util.h"
 
-#include <boost/algorithm/string/split.hpp>
-#include <boost/algorithm/string/classification.hpp>
-#include <boost/static_assert.hpp>
-
 #include <sstream>
 #include <sstream>
+#include <assert.h>
 
 using namespace GpgME;
 
 using namespace GpgME;
-using namespace boost;
 
 ScdGetInfoAssuanTransaction::ScdGetInfoAssuanTransaction(InfoItem item)
     : AssuanTransaction(),
 
 ScdGetInfoAssuanTransaction::ScdGetInfoAssuanTransaction(InfoItem item)
     : AssuanTransaction(),
@@ -48,7 +44,12 @@ ScdGetInfoAssuanTransaction::~ScdGetInfoAssuanTransaction() {}
 static std::vector<std::string> to_reader_list(const std::string &s)
 {
     std::vector<std::string> result;
 static std::vector<std::string> to_reader_list(const std::string &s)
 {
     std::vector<std::string> result;
-    return split(result, s, is_any_of("\n"), token_compress_on);
+    std::stringstream ss(s);
+    std::string tok;
+    while (std::getline(ss, tok, '\n')) {
+        result.push_back(tok);
+    }
+    return result;
 }
 
 static std::vector<std::string> to_app_list(const std::string &s)
 }
 
 static std::vector<std::string> to_app_list(const std::string &s)
@@ -119,7 +120,8 @@ static const char *const scd_getinfo_tokens[] = {
     "deny_admin",
     "app_list",
 };
     "deny_admin",
     "app_list",
 };
-BOOST_STATIC_ASSERT((sizeof scd_getinfo_tokens / sizeof * scd_getinfo_tokens == ScdGetInfoAssuanTransaction::LastInfoItem));
+static_assert((sizeof scd_getinfo_tokens / sizeof * scd_getinfo_tokens == ScdGetInfoAssuanTransaction::LastInfoItem),
+              "getinfo_tokens size mismatch");
 
 void ScdGetInfoAssuanTransaction::makeCommand() const
 {
 
 void ScdGetInfoAssuanTransaction::makeCommand() const
 {