1
0
Fork 0

attempt to fix clang build

This commit is contained in:
jsteemann 2017-03-06 15:40:03 +01:00
parent d20444d183
commit f7b819579d
7 changed files with 45 additions and 43 deletions

View File

@ -50,6 +50,8 @@ struct HexDump {
static std::string toHex(uint8_t value);
friend std::ostream& operator<<(std::ostream&, HexDump const&);
Slice const slice;
int valuesPerLine;
std::string separator;
@ -58,8 +60,4 @@ struct HexDump {
} // namespace arangodb::velocypack
} // namespace arangodb
std::ostream& operator<<(std::ostream&, arangodb::velocypack::HexDump const*);
std::ostream& operator<<(std::ostream&, arangodb::velocypack::HexDump const&);
#endif

View File

@ -42,14 +42,17 @@ std::string HexDump::toHex(uint8_t value) {
return result;
}
std::ostream& operator<<(std::ostream& stream, HexDump const* hexdump) {
namespace arangodb {
namespace velocypack {
std::ostream& operator<<(std::ostream& stream, HexDump const& hexdump) {
int current = 0;
for (uint8_t it : hexdump->slice) {
for (uint8_t it : hexdump.slice) {
if (current != 0) {
stream << hexdump->separator;
stream << hexdump.separator;
if (hexdump->valuesPerLine > 0 && current == hexdump->valuesPerLine) {
if (hexdump.valuesPerLine > 0 && current == hexdump.valuesPerLine) {
stream << std::endl;
current = 0;
}
@ -62,6 +65,5 @@ std::ostream& operator<<(std::ostream& stream, HexDump const* hexdump) {
return stream;
}
std::ostream& operator<<(std::ostream& stream, HexDump const& hexdump) {
return operator<<(stream, &hexdump);
}
}

View File

@ -27,6 +27,7 @@
#include <limits>
#include <stdexcept>
#include <velocypack/HexDump.h>
#include <velocypack/velocypack-aliases.h>
#include <boost/optional.hpp>
@ -52,6 +53,38 @@ using namespace arangodb;
using namespace arangodb::basics;
using namespace arangodb::rest;
inline std::size_t validateAndCount(char const* vpStart,
char const* vpEnd) {
VPackOptions validationOptions = VPackOptions::Defaults;
validationOptions.validateUtf8Strings = true;
VPackValidator validator(&validationOptions);
std::size_t numPayloads = 0;
try {
// check for slice start to the end of Chunk
// isSubPart allows the slice to be shorter than the checked buffer.
do {
validator.validate(vpStart, std::distance(vpStart, vpEnd),
/*isSubPart =*/true);
// get offset to next
VPackSlice tmp(vpStart);
vpStart += tmp.byteSize();
numPayloads++;
} while (vpStart != vpEnd);
return numPayloads - 1;
} catch (std::exception const& e) {
VPackSlice slice(vpStart);
VPackHexDump dump(slice);
LOG_TOPIC(DEBUG, Logger::COMMUNICATION)
<< "len: " << std::distance(vpStart, vpEnd) << " - " << dump ;
throw std::runtime_error(
std::string("error during validation of incoming VPack: ") + e.what());
}
}
VppCommTask::VppCommTask(EventLoop loop, GeneralServer* server,
std::unique_ptr<Socket> socket, ConnectionInfo&& info,
double timeout, bool skipInit)

View File

@ -31,7 +31,6 @@
#include <velocypack/Options.h>
#include <velocypack/Slice.h>
#include <velocypack/Validator.h>
#include <velocypack/HexDump.h>
#include <velocypack/velocypack-aliases.h>
#include <memory>
@ -39,37 +38,6 @@
namespace arangodb {
inline std::size_t validateAndCount(char const* vpStart,
char const* vpEnd) {
VPackOptions validationOptions = VPackOptions::Defaults;
validationOptions.validateUtf8Strings = true;
VPackValidator validator(&validationOptions);
std::size_t numPayloads = 0;
try {
// check for slice start to the end of Chunk
// isSubPart allows the slice to be shorter than the checked buffer.
do {
validator.validate(vpStart, std::distance(vpStart, vpEnd),
/*isSubPart =*/true);
// get offset to next
VPackSlice tmp(vpStart);
vpStart += tmp.byteSize();
numPayloads++;
} while (vpStart != vpEnd);
return numPayloads - 1;
} catch (std::exception const& e) {
VPackSlice slice(vpStart);
VPackHexDump dump(slice);
LOG_TOPIC(DEBUG, Logger::COMMUNICATION)
<< "len: " << std::distance(vpStart, vpEnd) << " - " << dump ;
throw std::runtime_error(
std::string("error during validation of incoming VPack: ") + e.what());
}
}
template <typename T>
std::size_t appendToBuffer(basics::StringBuffer* buffer, T& value) {
constexpr std::size_t len = sizeof(T);

View File

@ -26,7 +26,6 @@
#include "Basics/Common.h"
#include "Basics/Exceptions.h"
#include "Logger/Logger.h"
#include "Zip/zip.h"
#include <sstream>

View File

@ -31,6 +31,7 @@
#include "Basics/StringUtils.h"
#include "GeneralRequest.h"
#include "Endpoint/Endpoint.h"
#include "Logger/Logger.h"
#include "Rest/CommonDefines.h"
namespace arangodb {

View File

@ -35,6 +35,7 @@
#include <openssl/ssl.h>
#include <openssl/err.h>
#include "Basics/socket-utils.h"
#include "Logger/Logger.h"
#include "Ssl/ssl-helper.h"
#undef TRACE_SSL_CONNECTIONS