1
0
Fork 0

ported velocypack compatibility fix from arangodb/velocypack

This commit is contained in:
jsteemann 2016-12-09 23:27:45 +01:00
parent b9545343d1
commit 5c868d05dc
1 changed files with 9 additions and 10 deletions

View File

@ -468,14 +468,14 @@ class Slice {
if (!isExternal()) { if (!isExternal()) {
throw Exception(Exception::InvalidValueType, "Expecting type External"); throw Exception(Exception::InvalidValueType, "Expecting type External");
} }
return extractValue<char const*>(); return extractPointer();
} }
// returns the Slice managed by an External or the Slice itself if it's not // returns the Slice managed by an External or the Slice itself if it's not
// an External // an External
Slice resolveExternal() const { Slice resolveExternal() const {
if (*_start == 0x1d) { if (*_start == 0x1d) {
return Slice(extractValue<char const*>()); return Slice(extractPointer());
} }
return *this; return *this;
} }
@ -485,7 +485,7 @@ class Slice {
Slice resolveExternals() const { Slice resolveExternals() const {
char const* current = reinterpret_cast<char const*>(_start); char const* current = reinterpret_cast<char const*>(_start);
while (*current == 0x1d) { while (*current == 0x1d) {
current = Slice(current).extractValue<char const*>(); current = Slice(current).extractPointer();
} }
return Slice(current); return Slice(current);
} }
@ -908,15 +908,14 @@ class Slice {
} }
#endif #endif
// extracts a value from the slice and converts it into a // extracts a pointer from the slice and converts it into a
// built-in type // built-in pointer type
template <typename T> char const* extractPointer() const {
T extractValue() const {
union { union {
T value; char const* value;
char binary[sizeof(T)]; char binary[sizeof(char const*)];
}; };
memcpy(&binary[0], _start + 1, sizeof(T)); memcpy(&binary[0], _start + 1, sizeof(char const*));
return value; return value;
} }
}; };