From 4136928f0d894e873eb0ecb0bc79931a023ba32c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20Kl=C3=B6cker?= Date: Mon, 10 Jun 2024 11:48:05 +0200 Subject: [PATCH] cpp: Remove commented out and disabled code * lang/cpp/src/configuration.cpp: Remove disabled, abandoned code. * lang/cpp/src/context.cpp: Remove commented out, obsolete code. -- --- lang/cpp/src/configuration.cpp | 152 --------------------------------- lang/cpp/src/context.cpp | 4 - 2 files changed, 156 deletions(-) diff --git a/lang/cpp/src/configuration.cpp b/lang/cpp/src/configuration.cpp index 33c812f7..b3b62d6f 100644 --- a/lang/cpp/src/configuration.cpp +++ b/lang/cpp/src/configuration.cpp @@ -257,158 +257,6 @@ Type Option::alternateType() const return isNull() ? NoType : static_cast(opt->alt_type) ; } -#if 0 -static Option::Variant argument_to_variant(gpgme_conf_type_t type, bool list, gpgme_conf_arg_t arg) -{ - assert(arg); - switch (type) { - case GPGME_CONF_NONE: - if (list) { - // return the count (number of times set): - return arg->value.count; - } else { - return none; - } - case GPGME_CONF_INT32: - if (list) { - std::vector result; - for (gpgme_conf_arg_t a = arg ; a ; a = a->next) { - result.push_back(a->value.int32); - } - return result; - } else { - return arg->value.int32; - } - case GPGME_CONF_UINT32: - if (list) { - std::vector result; - for (gpgme_conf_arg_t a = arg ; a ; a = a->next) { - result.push_back(a->value.uint32); - } - return result; - } else { - return arg->value.uint32; - } - case GPGME_CONF_FILENAME: - case GPGME_CONF_LDAP_SERVER: - case GPGME_CONF_KEY_FPR: - case GPGME_CONF_PUB_KEY: - case GPGME_CONF_SEC_KEY: - case GPGME_CONF_ALIAS_LIST: - // these should not happen in alt_type, but fall through - case GPGME_CONF_STRING: - if (list) { - std::vector result; - for (gpgme_conf_arg_t a = arg ; a ; a = a->next) { - result.push_back(a->value.string); - } - return result; - } else { - return arg->value.string; - } - } - assert(!"Option: unknown alt_type!"); - return Option::Variant(); -} - -namespace -{ -inline const void *to_void_star(const char *s) -{ - return s; -} -inline const void *to_void_star(const std::string &s) -{ - return s.c_str(); -} -inline const void *to_void_star(const int &i) -{ - return &i; // const-&: sic! -} -inline const void *to_void_star(const unsigned int &i) -{ - return &i; // const-&: sic! -} - -struct VariantToArgumentVisitor : boost::static_visitor { - static gpgme_conf_arg_t make_argument(gpgme_conf_type_t type, const void *value) - { - gpgme_conf_arg_t arg = 0; -#ifdef HAVE_GPGME_CONF_ARG_NEW_WITH_CONST_VALUE - if (const gpgme_error_t err = gpgme_conf_arg_new(&arg, type, value)) { - return 0; - } -#else - if (const gpgme_error_t err = gpgme_conf_arg_new(&arg, type, const_cast(value))) { - return 0; - } -#endif - else { - return arg; - } - } - - gpgme_conf_arg_t operator()(bool v) const - { - return v ? make_argument(0) : 0 ; - } - - gpgme_conf_arg_t operator()(const char *s) const - { - return make_argument(s ? s : ""); - } - - gpgme_conf_arg_t operator()(const std::string &s) const - { - return operator()(s.c_str()); - } - - gpgme_conf_arg_t operator()(int i) const - { - return make_argument(&i); - } - - gpgme_conf_arg_t operator()(unsigned int i) const - { - return make_argument(&i); - } - - template - gpgme_conf_arg_t operator()(const std::vector &value) const - { - gpgme_conf_arg_t result = 0; - gpgme_conf_arg_t last = 0; - for (typename std::vector::const_iterator it = value.begin(), end = value.end() ; it != end ; ++it) { - if (gpgme_conf_arg_t arg = make_argument(to_void_star(*it))) { - if (last) { - last = last->next = arg; - } else { - result = last = arg; - } - } - } - return result; - } - -}; -} - -static gpgme_conf_arg_t variant_to_argument(const Option::Variant &value) -{ - VariantToArgumentVisitor v; - return apply_visitor(v, value); -} - -optional Option::defaultValue() const -{ - if (isNull()) { - return optional(); - } else { - return argument_to_variant(opt->alt_type, opt->flags & GPGME_CONF_LIST, opt->default_value); - } -} -#endif - Argument Option::defaultValue() const { if (isNull()) { diff --git a/lang/cpp/src/context.cpp b/lang/cpp/src/context.cpp index 57f92394..99e354df 100644 --- a/lang/cpp/src/context.cpp +++ b/lang/cpp/src/context.cpp @@ -147,11 +147,7 @@ bool Error::isCanceled() const int Error::toErrno() const { -//#ifdef HAVE_GPGME_GPG_ERROR_WRAPPERS return gpgme_err_code_to_errno(static_cast(code())); -//#else -// return gpg_err_code_to_errno( static_cast( code() ) ); -//#endif } // static