mirror of
https://github.com/boostorg/redis.git
synced 2026-01-19 04:42:09 +00:00
Progresses removing the dependency on std::string.
This commit is contained in:
@@ -112,7 +112,6 @@ nobase_include_HEADERS =\
|
||||
$(top_srcdir)/aedis/resp3/read.hpp\
|
||||
$(top_srcdir)/aedis/impl/command.ipp\
|
||||
$(top_srcdir)/aedis/resp3/detail/impl/parser.ipp\
|
||||
$(top_srcdir)/aedis/resp3/detail/impl/composer.ipp\
|
||||
$(top_srcdir)/aedis/resp3/impl/type.ipp\
|
||||
$(top_srcdir)/aedis/resp3/impl/client.ipp\
|
||||
$(top_srcdir)/aedis/resp3/impl/node.ipp
|
||||
@@ -156,6 +155,5 @@ deb: dist
|
||||
cd tmp &&\
|
||||
ln $(distdir)-1.tar.gz $(PACKAGE)_$(VERSION).orig.tar.gz &&\
|
||||
tar -xvvzf $(distdir)-1.tar.gz &&\
|
||||
mkdir -p debian
|
||||
cd $(distdir)/debian; debuild --no-sign -j1
|
||||
|
||||
|
||||
@@ -31,11 +31,34 @@ struct needs_to_string<char[N]> : std::false_type {};
|
||||
template <std::size_t N>
|
||||
struct needs_to_string<char const[N]> : std::false_type {};
|
||||
|
||||
void add_header(std::string& to, int size);
|
||||
void add_bulk(std::string& to, std::string_view param);
|
||||
template <class Storage>
|
||||
void add_header(Storage& to, int size)
|
||||
{
|
||||
// std::string does not support allocators.
|
||||
using std::to_string;
|
||||
auto const str = to_string(size);
|
||||
|
||||
template <class T>
|
||||
void add_bulk(std::string& to, T const& data, typename std::enable_if<needs_to_string<T>::value, bool>::type = false)
|
||||
to += "*";
|
||||
to.append(std::cbegin(str), std::cend(str));
|
||||
to += "\r\n";
|
||||
}
|
||||
|
||||
template <class Storage>
|
||||
void add_bulk(Storage& to, std::string_view data)
|
||||
{
|
||||
// std::string does not support allocators.
|
||||
using std::to_string;
|
||||
auto const str = to_string(std::size(data));
|
||||
|
||||
to += "$";
|
||||
to.append(std::cbegin(str), std::cend(str));
|
||||
to += "\r\n";
|
||||
to += data;
|
||||
to += "\r\n";
|
||||
}
|
||||
|
||||
template <class Storage, class T>
|
||||
void add_bulk(Storage& to, T const& data, typename std::enable_if<needs_to_string<T>::value, bool>::type = false)
|
||||
{
|
||||
using std::to_string;
|
||||
auto const s = to_string(data);
|
||||
@@ -44,8 +67,8 @@ void add_bulk(std::string& to, T const& data, typename std::enable_if<needs_to_s
|
||||
|
||||
// Overload for pairs.
|
||||
// TODO: Overload for tuples.
|
||||
template <class T1, class T2>
|
||||
void add_bulk(std::string& to, std::pair<T1, T2> const& pair)
|
||||
template <class Storage, class T1, class T2>
|
||||
void add_bulk(Storage& to, std::pair<T1, T2> const& pair)
|
||||
{
|
||||
add_bulk(to, pair.first);
|
||||
add_bulk(to, pair.second);
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
/* Copyright (c) 2019 - 2021 Marcelo Zimbres Silva (mzimbres at gmail dot com)
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include <aedis/resp3/detail/composer.hpp>
|
||||
|
||||
namespace aedis {
|
||||
namespace resp3 {
|
||||
namespace detail {
|
||||
|
||||
void add_header(std::string& to, int size)
|
||||
{
|
||||
to += "*";
|
||||
to += std::to_string(size);
|
||||
to += "\r\n";
|
||||
}
|
||||
|
||||
void add_bulk(std::string& to, std::string_view data)
|
||||
{
|
||||
to += "$";
|
||||
to += std::to_string(std::size(data));
|
||||
to += "\r\n";
|
||||
to += data;
|
||||
to += "\r\n";
|
||||
}
|
||||
|
||||
} // detail
|
||||
} // resp3
|
||||
} // aedis
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2019 - 2021 Marcelo Zimbres Silva (mzimbres at gmail dot com)
|
||||
/* Copyright (c) 2019 Marcelo Zimbres Silva (mzimbres@gmail.com)
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@@ -7,16 +7,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <queue>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <ostream>
|
||||
#include <iterator>
|
||||
|
||||
#include <aedis/resp3/detail/composer.hpp>
|
||||
#include <aedis/command.hpp>
|
||||
#include <aedis/resp3/detail/composer.hpp>
|
||||
|
||||
namespace aedis {
|
||||
namespace resp3 {
|
||||
@@ -38,14 +32,14 @@ namespace resp3 {
|
||||
* co_await async_write(socket, buffer(sr.request()));
|
||||
* @endcode
|
||||
*/
|
||||
template <class Container, class Command>
|
||||
template <class Storage, class Command>
|
||||
class serializer {
|
||||
private:
|
||||
Container* request_;
|
||||
Storage* request_;
|
||||
|
||||
public:
|
||||
/// Constructor
|
||||
serializer(Container& container) : request_(&container) {}
|
||||
serializer(Storage& storage) : request_(&storage) {}
|
||||
|
||||
/** @brief Appends a new command to the end of the request.
|
||||
*
|
||||
@@ -132,14 +126,14 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/** \brief Creates a serializer from a container.
|
||||
/** \brief Creates a serializer for a \c std::string.
|
||||
* \ingroup functions
|
||||
* TODO: Add the string template parameters.
|
||||
* \param storage The string.
|
||||
*/
|
||||
template <class Command>
|
||||
auto make_serializer(std::string& container)
|
||||
template<class Command>
|
||||
auto make_serializer(std::string& storage)
|
||||
{
|
||||
return serializer<std::string, Command>(container);
|
||||
return serializer<std::string, Command>(storage);
|
||||
}
|
||||
|
||||
} // resp3
|
||||
|
||||
@@ -11,5 +11,4 @@
|
||||
#include <aedis/resp3/impl/type.ipp>
|
||||
#include <aedis/resp3/impl/node.ipp>
|
||||
#include <aedis/resp3/impl/client.ipp>
|
||||
#include <aedis/resp3/detail/impl/composer.ipp>
|
||||
#include <aedis/resp3/detail/impl/parser.ipp>
|
||||
|
||||
@@ -44,7 +44,7 @@ PROJECT_NUMBER = 1.0.0
|
||||
# for a project that appears at the top of each page and should give viewer a
|
||||
# quick idea about the purpose of the project. Keep the description short.
|
||||
|
||||
PROJECT_BRIEF = "Reference guide"
|
||||
PROJECT_BRIEF = "Redis client library"
|
||||
|
||||
# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
|
||||
# in the documentation. The maximum height of the logo should not exceed 55
|
||||
@@ -823,7 +823,7 @@ WARN_LOGFILE =
|
||||
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
|
||||
# Note: If this tag is empty the current directory is searched.
|
||||
|
||||
INPUT = include examples
|
||||
INPUT = aedis examples
|
||||
|
||||
# This tag can be used to specify the character encoding of the source files
|
||||
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
</div>
|
||||
<!--END GENERATE_TREEVIEW-->
|
||||
<!--BEGIN !GENERATE_TREEVIEW-->
|
||||
<hr class="footer"/><address class="footer"><small>
|
||||
Aedis 1.0.0 - Reference Guide generated on $datetime using Doxygen $doxygenversion   
|
||||
</small></address>
|
||||
<hr class="footer"/><address class="footer">
|
||||
Author: Marcelo Zimbres Silva.
|
||||
</address>
|
||||
<!--END !GENERATE_TREEVIEW-->
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user