Add VS2013 support back.

master
Chunting Gu 6 years ago
parent ee435f84c3
commit ba705e930e

@ -72,12 +72,12 @@ static const char kInverse[] = {
};
// Return max chars needed to encode a base64 string.
inline std::size_t constexpr EncodedSize(std::size_t n) {
inline std::size_t EncodedSize(std::size_t n) {
return 4 * ((n + 2) / 3);
}
// Return max bytes needed to decode a base64 string.
inline std::size_t constexpr DecodedSize(std::size_t n) {
inline std::size_t DecodedSize(std::size_t n) {
// return 3 * n / 4;
return n / 4 * 3; // requires n&3==0, smaller
}

@ -1,7 +1,7 @@
#ifndef WEBCC_BASE64_H_
#define WEBCC_BASE64_H_
#include <cctype>
#include <cstdint>
#include <string>
namespace webcc {

@ -19,7 +19,7 @@ static bool ReadFile(const std::string& path, std::string* output) {
}
auto size = ifs.tellg();
output->resize(size, '\0');
output->resize((std::size_t)size, '\0');
ifs.seekg(0);
ifs.read(&(*output)[0], size); // TODO: Error handling

@ -5,6 +5,37 @@
#include <exception>
#include <string>
// -----------------------------------------------------------------------------
// Macros
#ifdef _MSC_VER
#if _MSC_VER <= 1800 // VS 2013
// Does the compiler support "= default" for move copy constructor and
// move assignment operator?
#define WEBCC_DEFAULT_MOVE_COPY_ASSIGN 0
#define WEBCC_NOEXCEPT
#else
#define WEBCC_DEFAULT_MOVE_COPY_ASSIGN 1
#define WEBCC_NOEXCEPT noexcept
#endif // _MSC_VER <= 1800
#else
// GCC, Clang, etc.
#define WEBCC_DEFAULT_MOVE_COPY_ASSIGN 1
#define WEBCC_NOEXCEPT noexcept
#endif // _MSC_VER
namespace webcc {
// -----------------------------------------------------------------------------
@ -183,7 +214,7 @@ public:
Error error() const { return error_; }
// Note that `noexcept` is required by GCC.
const char* what() const noexcept override {
const char* what() const WEBCC_NOEXCEPT override{
return msg_.c_str();
}

@ -46,9 +46,30 @@ public:
as_cdata_(false) {
}
#if WEBCC_DEFAULT_MOVE_COPY_ASSIGN
SoapParameter(SoapParameter&&) = default;
SoapParameter& operator=(SoapParameter&&) = default;
#else
SoapParameter(SoapParameter&& rhs)
: key_(std::move(rhs.key_)),
value_(std::move(rhs.value_)),
as_cdata_(rhs.as_cdata_) {
}
SoapParameter& operator=(SoapParameter&& rhs) {
if (&rhs != this) {
key_ = std::move(rhs.key_);
value_ = std::move(rhs.value_);
as_cdata_ = rhs.as_cdata_;
}
return *this;
}
#endif // WEBCC_DEFAULT_MOVE_COPY_ASSIGN
const std::string& key() const { return key_; }
const std::string& value() const { return value_; }

@ -61,9 +61,34 @@ public:
explicit Url(const std::string& str, bool decode = true);
#if WEBCC_DEFAULT_MOVE_COPY_ASSIGN
Url(Url&&) = default;
Url& operator=(Url&&) = default;
#else
Url(Url&& rhs)
: scheme_(std::move(rhs.scheme_)),
host_(std::move(rhs.host_)),
port_(std::move(rhs.port_)),
path_(std::move(rhs.path_)),
query_(std::move(rhs.query_)) {
}
Url& operator=(Url&& rhs) {
if (&rhs != this) {
scheme_ = std::move(rhs.scheme_);
host_ = std::move(rhs.host_);
port_ = std::move(rhs.port_);
path_ = std::move(rhs.path_);
query_ = std::move(rhs.query_);
}
return *this;
}
#endif // WEBCC_DEFAULT_MOVE_COPY_ASSIGN
void Init(const std::string& str, bool decode = true, bool clear = true);
const std::string& scheme() const {

Loading…
Cancel
Save