Skip to content

Commit

Permalink
Various fixes on microsoft#866 which broke building for iOS and Mac
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Lee committed Oct 7, 2018
1 parent 74da372 commit 09714d9
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 77 deletions.
8 changes: 4 additions & 4 deletions Release/include/cpprest/http_compression.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class decompress_factory
{
public:
virtual const utility::string_t& algorithm() const = 0;
virtual const uint16_t weight() const = 0;
virtual uint16_t weight() const = 0;
virtual std::unique_ptr<decompress_provider> make_decompressor() const = 0;
virtual ~decompress_factory() = default;
};
Expand All @@ -117,9 +117,9 @@ _ASYNCRTIMP bool supported();
/// </summary>
namespace algorithm
{
constexpr utility::char_t *GZIP = _XPLATSTR("gzip");
constexpr utility::char_t *DEFLATE = _XPLATSTR("deflate");
constexpr utility::char_t *BROTLI = _XPLATSTR("br");
constexpr utility::char_t *GZIP = const_cast<utility::char_t *>(_XPLATSTR("gzip"));
constexpr utility::char_t *DEFLATE = const_cast<utility::char_t *>(_XPLATSTR("deflate"));
constexpr utility::char_t *BROTLI = const_cast<utility::char_t *>(_XPLATSTR("br"));

/// <summary>
/// Test whether cpprestsdk was built with built-in compression support and
Expand Down
64 changes: 32 additions & 32 deletions Release/include/cpprest/http_headers.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,37 @@
#include "cpprest/asyncrt_utils.h"

namespace web { namespace http {

namespace details
{
template<typename key_type, typename _t>
bool bind_impl(const key_type &text, _t &ref)
{
utility::istringstream_t iss(text);
iss.imbue(std::locale::classic());
iss >> ref;
if (iss.fail() || !iss.eof())
{
return false;
}

return true;
}

template<typename key_type>
bool bind_impl(const key_type &text, utf16string &ref)
{
ref = utility::conversions::to_utf16string(text);
return true;
}

template<typename key_type>
bool bind_impl(const key_type &text, std::string &ref)
{
ref = utility::conversions::to_utf8string(text);
return true;
}
}

/// <summary>
/// Binds an individual reference to a string value.
/// </summary>
Expand Down Expand Up @@ -219,7 +249,7 @@ class http_headers
return false;
}

return details::bind_impl(iter->second, value) || iter->second.empty();
return web::http::details::bind_impl(iter->second, value) || iter->second.empty();
}

/// <summary>
Expand Down Expand Up @@ -289,34 +319,4 @@ class http_headers
inner_container m_headers;
};

namespace details
{
template<typename key_type, typename _t>
bool bind_impl(const key_type &text, _t &ref)
{
utility::istringstream_t iss(text);
iss.imbue(std::locale::classic());
iss >> ref;
if (iss.fail() || !iss.eof())
{
return false;
}

return true;
}

template<typename key_type>
bool bind_impl(const key_type &text, utf16string &ref)
{
ref = utility::conversions::to_utf16string(text);
return true;
}

template<typename key_type>
bool bind_impl(const key_type &text, std::string &ref)
{
ref = utility::conversions::to_utf8string(text);
return true;
}
}
}}
36 changes: 18 additions & 18 deletions Release/src/http/common/http_compression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class zlib_compressor_base : public compress_provider

private:
int m_state{Z_BUF_ERROR};
z_stream m_stream{0};
z_stream m_stream{};
const utility::string_t& m_algorithm;
};

Expand Down Expand Up @@ -263,7 +263,7 @@ class zlib_decompressor_base : public decompress_provider

private:
int m_state{Z_BUF_ERROR};
z_stream m_stream{0};
z_stream m_stream{};
const utility::string_t& m_algorithm;
};

Expand All @@ -283,7 +283,7 @@ class gzip_compressor : public zlib_compressor_base
class gzip_decompressor : public zlib_decompressor_base
{
public:
gzip_decompressor::gzip_decompressor() : zlib_decompressor_base(16) // gzip auto-detect
gzip_decompressor() : zlib_decompressor_base(16) // gzip auto-detect
{
}
};
Expand Down Expand Up @@ -620,7 +620,7 @@ class generic_decompress_factory : public decompress_factory

const utility::string_t& algorithm() const { return m_algorithm; }

const uint16_t weight() const { return m_weight; }
uint16_t weight() const { return m_weight; }

std::unique_ptr<decompress_provider> make_decompressor() const { return _make_decompressor(); }

Expand All @@ -634,14 +634,14 @@ class generic_decompress_factory : public decompress_factory
static const std::vector<std::shared_ptr<compress_factory>> g_compress_factories
#if defined(CPPREST_HTTP_COMPRESSION)
= {std::make_shared<generic_compress_factory>(
algorithm::GZIP, []() -> std::unique_ptr<compress_provider> { return std::make_unique<gzip_compressor>(); }),
algorithm::GZIP, []() -> std::unique_ptr<compress_provider> { return utility::details::make_unique<gzip_compressor>(); }),
std::make_shared<generic_compress_factory>(
algorithm::DEFLATE,
[]() -> std::unique_ptr<compress_provider> { return std::make_unique<deflate_compressor>(); }),
[]() -> std::unique_ptr<compress_provider> { return utility::details::make_unique<deflate_compressor>(); }),
#if defined(CPPREST_BROTLI_COMPRESSION)
std::make_shared<generic_compress_factory>(
algorithm::BROTLI,
[]() -> std::unique_ptr<compress_provider> { return std::make_unique<brotli_compressor>(); })
[]() -> std::unique_ptr<compress_provider> { return utility::details::make_unique<brotli_compressor>(); })
#endif // CPPREST_BROTLI_COMPRESSION
};
#else // CPPREST_HTTP_COMPRESSION
Expand All @@ -653,16 +653,16 @@ static const std::vector<std::shared_ptr<decompress_factory>> g_decompress_facto
= {std::make_shared<generic_decompress_factory>(
algorithm::GZIP,
500,
[]() -> std::unique_ptr<decompress_provider> { return std::make_unique<gzip_decompressor>(); }),
[]() -> std::unique_ptr<decompress_provider> { return utility::details::make_unique<gzip_decompressor>(); }),
std::make_shared<generic_decompress_factory>(
algorithm::DEFLATE,
500,
[]() -> std::unique_ptr<decompress_provider> { return std::make_unique<deflate_decompressor>(); }),
[]() -> std::unique_ptr<decompress_provider> { return utility::details::make_unique<deflate_decompressor>(); }),
#if defined(CPPREST_BROTLI_COMPRESSION)
std::make_shared<generic_decompress_factory>(
algorithm::BROTLI,
500,
[]() -> std::unique_ptr<decompress_provider> { return std::make_unique<brotli_decompressor>(); })
[]() -> std::unique_ptr<decompress_provider> { return utility::details::make_unique<brotli_decompressor>(); })
#endif // CPPREST_BROTLI_COMPRESSION
};
#else // CPPREST_HTTP_COMPRESSION
Expand Down Expand Up @@ -751,7 +751,7 @@ std::shared_ptr<decompress_factory> get_decompress_factory(const utility::string
std::unique_ptr<compress_provider> make_gzip_compressor(int compressionLevel, int method, int strategy, int memLevel)
{
#if defined(CPPREST_HTTP_COMPRESSION)
return std::move(std::make_unique<gzip_compressor>(compressionLevel, method, strategy, memLevel));
return utility::details::make_unique<gzip_compressor>(compressionLevel, method, strategy, memLevel);
#else // CPPREST_HTTP_COMPRESSION
return std::unique_ptr<compress_provider>();
#endif // CPPREST_HTTP_COMPRESSION
Expand All @@ -760,7 +760,7 @@ std::unique_ptr<compress_provider> make_gzip_compressor(int compressionLevel, in
std::unique_ptr<compress_provider> make_deflate_compressor(int compressionLevel, int method, int strategy, int memLevel)
{
#if defined(CPPREST_HTTP_COMPRESSION)
return std::move(std::make_unique<deflate_compressor>(compressionLevel, method, strategy, memLevel));
return utility::details::make_unique<deflate_compressor>(compressionLevel, method, strategy, memLevel);
#else // CPPREST_HTTP_COMPRESSION
return std::unique_ptr<compress_provider>();
#endif // CPPREST_HTTP_COMPRESSION
Expand All @@ -769,7 +769,7 @@ std::unique_ptr<compress_provider> make_deflate_compressor(int compressionLevel,
std::unique_ptr<compress_provider> make_brotli_compressor(uint32_t window, uint32_t quality, uint32_t mode)
{
#if defined(CPPREST_HTTP_COMPRESSION) && defined(CPPREST_BROTLI_COMPRESSION)
return std::move(std::make_unique<brotli_compressor>(window, quality, mode));
return utility::details::make_unique<brotli_compressor>(window, quality, mode);
#else // CPPREST_BROTLI_COMPRESSION
return std::unique_ptr<compress_provider>();
#endif // CPPREST_BROTLI_COMPRESSION
Expand Down Expand Up @@ -951,7 +951,7 @@ std::unique_ptr<compress_provider> get_compressor_from_header(

if (compressor)
{
return std::move(compressor);
return compressor;
}

// If we're here, we didn't match the caller's compressor above;
Expand All @@ -965,7 +965,7 @@ std::unique_ptr<compress_provider> get_compressor_from_header(
auto compressor = web::http::compression::builtin::_make_compressor(f, coding);
if (compressor)
{
return std::move(compressor);
return compressor;
}
if (type == header_types::accept_encoding && utility::details::str_iequal(coding, _XPLATSTR("identity")))
{
Expand Down Expand Up @@ -1068,7 +1068,7 @@ std::unique_ptr<decompress_provider> get_decompressor_from_header(

// Either the response is compressed and we have a decompressor that can handle it, or
// built-in compression is not enabled and we don't have an alternate set of decompressors
return std::move(decompressor);
return decompressor;
}

utility::string_t build_supported_header(header_types type,
Expand All @@ -1084,7 +1084,7 @@ utility::string_t build_supported_header(header_types type,
// Add all specified algorithms and their weights to the header
start = true;
os.imbue(std::locale::classic());
for each (auto& factory in f)
for (auto& factory : f)
{
if (factory)
{
Expand All @@ -1109,7 +1109,7 @@ utility::string_t build_supported_header(header_types type,
os << _XPLATSTR("identity;q=1, *;q=0");
}

return std::move(os.str());
return os.str();
}
} // namespace details
} // namespace compression
Expand Down
2 changes: 1 addition & 1 deletion Release/src/http/common/internal_http_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ bool validate_method(const utility::string_t& method);

namespace web { namespace http { namespace compression {

class compression::decompress_factory;
class decompress_factory;

namespace details { namespace builtin {

Expand Down
Loading

0 comments on commit 09714d9

Please sign in to comment.