1
0
Fork 0

added protobuf to json converter

This commit is contained in:
Jan Steemann 2012-09-20 18:14:00 +02:00
parent c546aaf4bf
commit 18cd515737
10 changed files with 1474 additions and 28 deletions

View File

@ -147,7 +147,7 @@ namespace triagens {
const char * ptr = this->_readBuffer->c_str() + this->_readPosition;
const char * end = this->_readBuffer->end();
if (end - ptr >= BinaryMessage::getHeaderLength()) {
if (end - ptr >= (ptrdiff_t) BinaryMessage::getHeaderLength()) {
this->_readPosition = BinaryMessage::getHeaderLength();
LOGGER_TRACE << "BINARY READ FOR " << static_cast<Task*>(this);

View File

@ -30,6 +30,7 @@
#include "BasicsC/strings.h"
#include "Basics/StringUtils.h"
#include "ProtocolBuffers/JsonConverterProtobuf.h"
using namespace triagens::basics;
using namespace triagens::rest;
@ -118,6 +119,19 @@ HttpRequestProtobuf::~HttpRequestProtobuf () {
/// {@inheritDoc}
////////////////////////////////////////////////////////////////////////////////
TRI_json_t* HttpRequestProtobuf::toJson (char*& errmsg) {
if (_request->contenttype() != PB_JSON_CONTENT) {
return 0;
}
TRI_json_t* json = JsonConverterProtobuf::ParseObject(TRI_UNKNOWN_MEM_ZONE, _request->json());
return json;
}
////////////////////////////////////////////////////////////////////////////////
/// {@inheritDoc}
////////////////////////////////////////////////////////////////////////////////
char const* HttpRequestProtobuf::requestPath () const {
return _request->url().c_str();
}

View File

@ -30,7 +30,6 @@
#define TRIAGENS_REST_HTTP_REQUEST_PROTOBUF_H 1
#include "Rest/HttpRequest.h"
#include "ProtocolBuffers/arangodb.pb.h"
// -----------------------------------------------------------------------------
@ -100,6 +99,12 @@ namespace triagens {
public:
////////////////////////////////////////////////////////////////////////////////
/// {@inheritDoc}
////////////////////////////////////////////////////////////////////////////////
virtual TRI_json_t* toJson (char*&);
////////////////////////////////////////////////////////////////////////////////
/// {@inheritDoc}
////////////////////////////////////////////////////////////////////////////////

View File

@ -0,0 +1,177 @@
////////////////////////////////////////////////////////////////////////////////
/// @brief protobuf to json converter helper functions
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 2004-2012 triAGENS GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is triAGENS GmbH, Cologne, Germany
///
/// @author Jan Steemann
/// @author Copyright 2012, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
#ifndef TRIAGENS_PROTOCOL_BUFFERS_JSON_CONVERTER_PROTOBUF_H
#define TRIAGENS_PROTOCOL_BUFFERS_JSON_CONVERTER_PROTOBUF_H 1
#include "BasicsC/json.h"
#include "Logger/Logger.h"
#include "ProtocolBuffers/arangodb.pb.h"
// -----------------------------------------------------------------------------
// --SECTION-- class JsonConverterProtobuf
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Rest
/// @{
////////////////////////////////////////////////////////////////////////////////
namespace triagens {
namespace rest {
////////////////////////////////////////////////////////////////////////////////
/// @brief json to protobuf and vice versa conversion functions
////////////////////////////////////////////////////////////////////////////////
class JsonConverterProtobuf {
private:
JsonConverterProtobuf (JsonConverterProtobuf const&);
JsonConverterProtobuf& operator= (JsonConverterProtobuf const&);
JsonConverterProtobuf ();
~JsonConverterProtobuf ();
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- public static methods
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Rest
/// @{
////////////////////////////////////////////////////////////////////////////////
public:
////////////////////////////////////////////////////////////////////////////////
/// @brief convert a protobuf json list object into a TRI_json_t*
////////////////////////////////////////////////////////////////////////////////
static TRI_json_t* ParseList (TRI_memory_zone_t* zone,
const PB_ArangoJsonValue& object) {
TRI_json_t* result = TRI_CreateListJson(zone);
for (int i = 0; i < object.objects_size(); ++i) {
const PB_ArangoJsonContent& atom = object.objects(i);
TRI_json_t* json = ParseObject(zone, atom);
TRI_PushBack3ListJson(zone, result, json);
}
return result;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief convert a protobuf json array object into a TRI_json_t*
////////////////////////////////////////////////////////////////////////////////
static TRI_json_t* ParseArray (TRI_memory_zone_t* zone,
const PB_ArangoJsonValue& object) {
TRI_json_t* result = TRI_CreateArrayJson(zone);
for (int i = 0; i < object.objects_size(); ) {
const PB_ArangoJsonContent& key = object.objects(i);
const PB_ArangoJsonContent& value = object.objects(i + 1);
i += 2;
if (key.type() != PB_REQUEST_TYPE_STRING) {
LOGGER_WARNING << "invalid json contained in protobuf message";
return 0;
}
TRI_json_t* json = ParseObject(zone, value);
TRI_InsertArrayJson(zone, result, key.value().stringvalue().c_str(), json);
}
return result;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief convert a protobuf json object into a TRI_json_t*
////////////////////////////////////////////////////////////////////////////////
static TRI_json_t* ParseObject (TRI_memory_zone_t* zone,
const PB_ArangoJsonContent& object) {
TRI_json_t* result;
switch (object.type()) {
case PB_REQUEST_TYPE_NULL: {
result = TRI_CreateNullJson(zone);
break;
}
case PB_REQUEST_TYPE_BOOLEAN: {
result = TRI_CreateBooleanJson(zone, object.value().booleanvalue());
break;
}
case PB_REQUEST_TYPE_NUMBER: {
result = TRI_CreateNumberJson(zone, object.value().numbervalue());
break;
}
case PB_REQUEST_TYPE_STRING: {
result = TRI_CreateString2CopyJson(zone, (char*) object.value().stringvalue().c_str(), object.value().stringvalue().size());
break;
}
case PB_REQUEST_TYPE_ARRAY: {
result = ParseArray(zone, object.value());
break;
}
case PB_REQUEST_TYPE_LIST: {
result = ParseList(zone, object.value());
break;
}
}
return result;
}
};
}
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
#endif
// -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE
// -----------------------------------------------------------------------------
// Local Variables:
// mode: outline-minor
// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}\\)"
// End:

View File

@ -24,6 +24,12 @@ const ::google::protobuf::internal::GeneratedMessageReflection*
const ::google::protobuf::Descriptor* PB_ArangoBatchMessage_descriptor_ = NULL;
const ::google::protobuf::internal::GeneratedMessageReflection*
PB_ArangoBatchMessage_reflection_ = NULL;
const ::google::protobuf::Descriptor* PB_ArangoJsonValue_descriptor_ = NULL;
const ::google::protobuf::internal::GeneratedMessageReflection*
PB_ArangoJsonValue_reflection_ = NULL;
const ::google::protobuf::Descriptor* PB_ArangoJsonContent_descriptor_ = NULL;
const ::google::protobuf::internal::GeneratedMessageReflection*
PB_ArangoJsonContent_reflection_ = NULL;
const ::google::protobuf::Descriptor* PB_ArangoBlobRequest_descriptor_ = NULL;
const ::google::protobuf::internal::GeneratedMessageReflection*
PB_ArangoBlobRequest_reflection_ = NULL;
@ -36,6 +42,7 @@ const ::google::protobuf::internal::GeneratedMessageReflection*
const ::google::protobuf::EnumDescriptor* PB_ArangoMessageType_descriptor_ = NULL;
const ::google::protobuf::EnumDescriptor* PB_ArangoMessageContentType_descriptor_ = NULL;
const ::google::protobuf::EnumDescriptor* PB_ArangoRequestType_descriptor_ = NULL;
const ::google::protobuf::EnumDescriptor* PB_ArangoJsonType_descriptor_ = NULL;
} // namespace
@ -95,14 +102,49 @@ void protobuf_AssignDesc_lib_2fProtocolBuffers_2farangodb_2eproto() {
::google::protobuf::DescriptorPool::generated_pool(),
::google::protobuf::MessageFactory::generated_factory(),
sizeof(PB_ArangoBatchMessage));
PB_ArangoBlobRequest_descriptor_ = file->message_type(3);
static const int PB_ArangoBlobRequest_offsets_[6] = {
PB_ArangoJsonValue_descriptor_ = file->message_type(3);
static const int PB_ArangoJsonValue_offsets_[4] = {
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PB_ArangoJsonValue, booleanvalue_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PB_ArangoJsonValue, numbervalue_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PB_ArangoJsonValue, stringvalue_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PB_ArangoJsonValue, objects_),
};
PB_ArangoJsonValue_reflection_ =
new ::google::protobuf::internal::GeneratedMessageReflection(
PB_ArangoJsonValue_descriptor_,
PB_ArangoJsonValue::default_instance_,
PB_ArangoJsonValue_offsets_,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PB_ArangoJsonValue, _has_bits_[0]),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PB_ArangoJsonValue, _unknown_fields_),
-1,
::google::protobuf::DescriptorPool::generated_pool(),
::google::protobuf::MessageFactory::generated_factory(),
sizeof(PB_ArangoJsonValue));
PB_ArangoJsonContent_descriptor_ = file->message_type(4);
static const int PB_ArangoJsonContent_offsets_[2] = {
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PB_ArangoJsonContent, type_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PB_ArangoJsonContent, value_),
};
PB_ArangoJsonContent_reflection_ =
new ::google::protobuf::internal::GeneratedMessageReflection(
PB_ArangoJsonContent_descriptor_,
PB_ArangoJsonContent::default_instance_,
PB_ArangoJsonContent_offsets_,
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PB_ArangoJsonContent, _has_bits_[0]),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PB_ArangoJsonContent, _unknown_fields_),
-1,
::google::protobuf::DescriptorPool::generated_pool(),
::google::protobuf::MessageFactory::generated_factory(),
sizeof(PB_ArangoJsonContent));
PB_ArangoBlobRequest_descriptor_ = file->message_type(5);
static const int PB_ArangoBlobRequest_offsets_[7] = {
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PB_ArangoBlobRequest, requesttype_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PB_ArangoBlobRequest, url_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PB_ArangoBlobRequest, values_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PB_ArangoBlobRequest, headers_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PB_ArangoBlobRequest, contenttype_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PB_ArangoBlobRequest, content_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PB_ArangoBlobRequest, json_),
};
PB_ArangoBlobRequest_reflection_ =
new ::google::protobuf::internal::GeneratedMessageReflection(
@ -115,7 +157,7 @@ void protobuf_AssignDesc_lib_2fProtocolBuffers_2farangodb_2eproto() {
::google::protobuf::DescriptorPool::generated_pool(),
::google::protobuf::MessageFactory::generated_factory(),
sizeof(PB_ArangoBlobRequest));
PB_ArangoBlobResponse_descriptor_ = file->message_type(4);
PB_ArangoBlobResponse_descriptor_ = file->message_type(6);
static const int PB_ArangoBlobResponse_offsets_[5] = {
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PB_ArangoBlobResponse, status_),
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PB_ArangoBlobResponse, headers_),
@ -134,7 +176,7 @@ void protobuf_AssignDesc_lib_2fProtocolBuffers_2farangodb_2eproto() {
::google::protobuf::DescriptorPool::generated_pool(),
::google::protobuf::MessageFactory::generated_factory(),
sizeof(PB_ArangoBlobResponse));
PB_ArangoErrorResponse_descriptor_ = file->message_type(5);
PB_ArangoErrorResponse_descriptor_ = file->message_type(7);
static const int PB_ArangoErrorResponse_offsets_[1] = {
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PB_ArangoErrorResponse, message_),
};
@ -152,6 +194,7 @@ void protobuf_AssignDesc_lib_2fProtocolBuffers_2farangodb_2eproto() {
PB_ArangoMessageType_descriptor_ = file->enum_type(0);
PB_ArangoMessageContentType_descriptor_ = file->enum_type(1);
PB_ArangoRequestType_descriptor_ = file->enum_type(2);
PB_ArangoJsonType_descriptor_ = file->enum_type(3);
}
namespace {
@ -170,6 +213,10 @@ void protobuf_RegisterTypes(const ::std::string&) {
PB_ArangoMessage_descriptor_, &PB_ArangoMessage::default_instance());
::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
PB_ArangoBatchMessage_descriptor_, &PB_ArangoBatchMessage::default_instance());
::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
PB_ArangoJsonValue_descriptor_, &PB_ArangoJsonValue::default_instance());
::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
PB_ArangoJsonContent_descriptor_, &PB_ArangoJsonContent::default_instance());
::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
PB_ArangoBlobRequest_descriptor_, &PB_ArangoBlobRequest::default_instance());
::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
@ -187,6 +234,10 @@ void protobuf_ShutdownFile_lib_2fProtocolBuffers_2farangodb_2eproto() {
delete PB_ArangoMessage_reflection_;
delete PB_ArangoBatchMessage::default_instance_;
delete PB_ArangoBatchMessage_reflection_;
delete PB_ArangoJsonValue::default_instance_;
delete PB_ArangoJsonValue_reflection_;
delete PB_ArangoJsonContent::default_instance_;
delete PB_ArangoJsonContent_reflection_;
delete PB_ArangoBlobRequest::default_instance_;
delete PB_ArangoBlobRequest_reflection_;
delete PB_ArangoBlobResponse::default_instance_;
@ -210,38 +261,53 @@ void protobuf_AddDesc_lib_2fProtocolBuffers_2farangodb_2eproto() {
"essageType\022*\n\013blobRequest\030\002 \001(\0132\025.PB_Ara"
"ngoBlobRequest\022,\n\014blobResponse\030\003 \001(\0132\026.P"
"B_ArangoBlobResponse\022.\n\rerrorResponse\030\004 "
"\001(\0132\027.PB_ArangoErrorResponse\"\334\001\n\024PB_Aran"
"goBlobRequest\022*\n\013requestType\030\001 \002(\0162\025.PB_"
"ArangoRequestType\022\013\n\003url\030\002 \002(\t\022\"\n\006values"
"\030\003 \003(\0132\022.PB_ArangoKeyValue\022#\n\007headers\030\004 "
"\003(\0132\022.PB_ArangoKeyValue\0221\n\013contentType\030\005"
" \002(\0162\034.PB_ArangoMessageContentType\022\017\n\007co"
"ntent\030\007 \001(\t\"\247\001\n\025PB_ArangoBlobResponse\022\016\n"
"\006status\030\001 \002(\005\022#\n\007headers\030\002 \003(\0132\022.PB_Aran"
"goKeyValue\0221\n\013contentType\030\003 \002(\0162\034.PB_Ara"
"ngoMessageContentType\022\025\n\rcontentLength\030\006"
" \002(\005\022\017\n\007content\030\004 \001(\t\")\n\026PB_ArangoErrorR"
"esponse\022\017\n\007message\030\001 \002(\t*X\n\024PB_ArangoMes"
"sageType\022\023\n\017PB_BLOB_REQUEST\020\000\022\024\n\020PB_BLOB"
"_RESPONSE\020\001\022\025\n\021PB_ERROR_RESPONSE\020\002*Z\n\033PB"
"_ArangoMessageContentType\022\021\n\rPB_NO_CONTE"
"NT\020\000\022\023\n\017PB_TEXT_CONTENT\020\001\022\023\n\017PB_JSON_CON"
"TENT\020\002*\263\001\n\024PB_ArangoRequestType\022\032\n\026PB_RE"
"QUEST_TYPE_DELETE\020\000\022\027\n\023PB_REQUEST_TYPE_G"
"ET\020\001\022\030\n\024PB_REQUEST_TYPE_HEAD\020\002\022\030\n\024PB_REQ"
"UEST_TYPE_POST\020\003\022\027\n\023PB_REQUEST_TYPE_PUT\020"
"\004\022\031\n\025PB_REQUEST_TYPE_PATCH\020\005", 1148);
"\001(\0132\027.PB_ArangoErrorResponse\"|\n\022PB_Arang"
"oJsonValue\022\024\n\014booleanValue\030\001 \001(\010\022\023\n\013numb"
"erValue\030\002 \001(\001\022\023\n\013stringValue\030\003 \001(\t\022&\n\007ob"
"jects\030\004 \003(\0132\025.PB_ArangoJsonContent\"\\\n\024PB"
"_ArangoJsonContent\022 \n\004type\030\001 \002(\0162\022.PB_Ar"
"angoJsonType\022\"\n\005value\030\002 \001(\0132\023.PB_ArangoJ"
"sonValue\"\201\002\n\024PB_ArangoBlobRequest\022*\n\013req"
"uestType\030\001 \002(\0162\025.PB_ArangoRequestType\022\013\n"
"\003url\030\002 \002(\t\022\"\n\006values\030\003 \003(\0132\022.PB_ArangoKe"
"yValue\022#\n\007headers\030\004 \003(\0132\022.PB_ArangoKeyVa"
"lue\0221\n\013contentType\030\005 \002(\0162\034.PB_ArangoMess"
"ageContentType\022\017\n\007content\030\007 \001(\t\022#\n\004json\030"
"\010 \001(\0132\025.PB_ArangoJsonContent\"\247\001\n\025PB_Aran"
"goBlobResponse\022\016\n\006status\030\001 \002(\005\022#\n\007header"
"s\030\002 \003(\0132\022.PB_ArangoKeyValue\0221\n\013contentTy"
"pe\030\003 \002(\0162\034.PB_ArangoMessageContentType\022\025"
"\n\rcontentLength\030\006 \002(\005\022\017\n\007content\030\004 \001(\t\")"
"\n\026PB_ArangoErrorResponse\022\017\n\007message\030\001 \002("
"\t*X\n\024PB_ArangoMessageType\022\023\n\017PB_BLOB_REQ"
"UEST\020\000\022\024\n\020PB_BLOB_RESPONSE\020\001\022\025\n\021PB_ERROR"
"_RESPONSE\020\002*Z\n\033PB_ArangoMessageContentTy"
"pe\022\021\n\rPB_NO_CONTENT\020\000\022\023\n\017PB_TEXT_CONTENT"
"\020\001\022\023\n\017PB_JSON_CONTENT\020\002*\263\001\n\024PB_ArangoReq"
"uestType\022\032\n\026PB_REQUEST_TYPE_DELETE\020\000\022\027\n\023"
"PB_REQUEST_TYPE_GET\020\001\022\030\n\024PB_REQUEST_TYPE"
"_HEAD\020\002\022\030\n\024PB_REQUEST_TYPE_POST\020\003\022\027\n\023PB_"
"REQUEST_TYPE_PUT\020\004\022\031\n\025PB_REQUEST_TYPE_PA"
"TCH\020\005*\267\001\n\021PB_ArangoJsonType\022\030\n\024PB_REQUES"
"T_TYPE_NULL\020\000\022\033\n\027PB_REQUEST_TYPE_BOOLEAN"
"\020\001\022\032\n\026PB_REQUEST_TYPE_NUMBER\020\002\022\032\n\026PB_REQ"
"UEST_TYPE_STRING\020\003\022\031\n\025PB_REQUEST_TYPE_AR"
"RAY\020\004\022\030\n\024PB_REQUEST_TYPE_LIST\020\005", 1591);
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
"lib/ProtocolBuffers/arangodb.proto", &protobuf_RegisterTypes);
PB_ArangoKeyValue::default_instance_ = new PB_ArangoKeyValue();
PB_ArangoMessage::default_instance_ = new PB_ArangoMessage();
PB_ArangoBatchMessage::default_instance_ = new PB_ArangoBatchMessage();
PB_ArangoJsonValue::default_instance_ = new PB_ArangoJsonValue();
PB_ArangoJsonContent::default_instance_ = new PB_ArangoJsonContent();
PB_ArangoBlobRequest::default_instance_ = new PB_ArangoBlobRequest();
PB_ArangoBlobResponse::default_instance_ = new PB_ArangoBlobResponse();
PB_ArangoErrorResponse::default_instance_ = new PB_ArangoErrorResponse();
PB_ArangoKeyValue::default_instance_->InitAsDefaultInstance();
PB_ArangoMessage::default_instance_->InitAsDefaultInstance();
PB_ArangoBatchMessage::default_instance_->InitAsDefaultInstance();
PB_ArangoJsonValue::default_instance_->InitAsDefaultInstance();
PB_ArangoJsonContent::default_instance_->InitAsDefaultInstance();
PB_ArangoBlobRequest::default_instance_->InitAsDefaultInstance();
PB_ArangoBlobResponse::default_instance_->InitAsDefaultInstance();
PB_ArangoErrorResponse::default_instance_->InitAsDefaultInstance();
@ -303,6 +369,24 @@ bool PB_ArangoRequestType_IsValid(int value) {
}
}
const ::google::protobuf::EnumDescriptor* PB_ArangoJsonType_descriptor() {
protobuf_AssignDescriptorsOnce();
return PB_ArangoJsonType_descriptor_;
}
bool PB_ArangoJsonType_IsValid(int value) {
switch(value) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
return true;
default:
return false;
}
}
// ===================================================================
@ -1149,6 +1233,611 @@ void PB_ArangoBatchMessage::Swap(PB_ArangoBatchMessage* other) {
}
// ===================================================================
#ifndef _MSC_VER
const int PB_ArangoJsonValue::kBooleanValueFieldNumber;
const int PB_ArangoJsonValue::kNumberValueFieldNumber;
const int PB_ArangoJsonValue::kStringValueFieldNumber;
const int PB_ArangoJsonValue::kObjectsFieldNumber;
#endif // !_MSC_VER
PB_ArangoJsonValue::PB_ArangoJsonValue()
: ::google::protobuf::Message() {
SharedCtor();
}
void PB_ArangoJsonValue::InitAsDefaultInstance() {
}
PB_ArangoJsonValue::PB_ArangoJsonValue(const PB_ArangoJsonValue& from)
: ::google::protobuf::Message() {
SharedCtor();
MergeFrom(from);
}
void PB_ArangoJsonValue::SharedCtor() {
_cached_size_ = 0;
booleanvalue_ = false;
numbervalue_ = 0;
stringvalue_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
::memset(_has_bits_, 0, sizeof(_has_bits_));
}
PB_ArangoJsonValue::~PB_ArangoJsonValue() {
SharedDtor();
}
void PB_ArangoJsonValue::SharedDtor() {
if (stringvalue_ != &::google::protobuf::internal::kEmptyString) {
delete stringvalue_;
}
if (this != default_instance_) {
}
}
void PB_ArangoJsonValue::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* PB_ArangoJsonValue::descriptor() {
protobuf_AssignDescriptorsOnce();
return PB_ArangoJsonValue_descriptor_;
}
const PB_ArangoJsonValue& PB_ArangoJsonValue::default_instance() {
if (default_instance_ == NULL) protobuf_AddDesc_lib_2fProtocolBuffers_2farangodb_2eproto(); return *default_instance_;
}
PB_ArangoJsonValue* PB_ArangoJsonValue::default_instance_ = NULL;
PB_ArangoJsonValue* PB_ArangoJsonValue::New() const {
return new PB_ArangoJsonValue;
}
void PB_ArangoJsonValue::Clear() {
if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
booleanvalue_ = false;
numbervalue_ = 0;
if (has_stringvalue()) {
if (stringvalue_ != &::google::protobuf::internal::kEmptyString) {
stringvalue_->clear();
}
}
}
objects_.Clear();
::memset(_has_bits_, 0, sizeof(_has_bits_));
mutable_unknown_fields()->Clear();
}
bool PB_ArangoJsonValue::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!(EXPRESSION)) return false
::google::protobuf::uint32 tag;
while ((tag = input->ReadTag()) != 0) {
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// optional bool booleanValue = 1;
case 1: {
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
input, &booleanvalue_)));
set_has_booleanvalue();
} else {
goto handle_uninterpreted;
}
if (input->ExpectTag(17)) goto parse_numberValue;
break;
}
// optional double numberValue = 2;
case 2: {
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED64) {
parse_numberValue:
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>(
input, &numbervalue_)));
set_has_numbervalue();
} else {
goto handle_uninterpreted;
}
if (input->ExpectTag(26)) goto parse_stringValue;
break;
}
// optional string stringValue = 3;
case 3: {
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
parse_stringValue:
DO_(::google::protobuf::internal::WireFormatLite::ReadString(
input, this->mutable_stringvalue()));
::google::protobuf::internal::WireFormat::VerifyUTF8String(
this->stringvalue().data(), this->stringvalue().length(),
::google::protobuf::internal::WireFormat::PARSE);
} else {
goto handle_uninterpreted;
}
if (input->ExpectTag(34)) goto parse_objects;
break;
}
// repeated .PB_ArangoJsonContent objects = 4;
case 4: {
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
parse_objects:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, add_objects()));
} else {
goto handle_uninterpreted;
}
if (input->ExpectTag(34)) goto parse_objects;
if (input->ExpectAtEnd()) return true;
break;
}
default: {
handle_uninterpreted:
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
return true;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, mutable_unknown_fields()));
break;
}
}
}
return true;
#undef DO_
}
void PB_ArangoJsonValue::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// optional bool booleanValue = 1;
if (has_booleanvalue()) {
::google::protobuf::internal::WireFormatLite::WriteBool(1, this->booleanvalue(), output);
}
// optional double numberValue = 2;
if (has_numbervalue()) {
::google::protobuf::internal::WireFormatLite::WriteDouble(2, this->numbervalue(), output);
}
// optional string stringValue = 3;
if (has_stringvalue()) {
::google::protobuf::internal::WireFormat::VerifyUTF8String(
this->stringvalue().data(), this->stringvalue().length(),
::google::protobuf::internal::WireFormat::SERIALIZE);
::google::protobuf::internal::WireFormatLite::WriteString(
3, this->stringvalue(), output);
}
// repeated .PB_ArangoJsonContent objects = 4;
for (int i = 0; i < this->objects_size(); i++) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
4, this->objects(i), output);
}
if (!unknown_fields().empty()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
unknown_fields(), output);
}
}
::google::protobuf::uint8* PB_ArangoJsonValue::SerializeWithCachedSizesToArray(
::google::protobuf::uint8* target) const {
// optional bool booleanValue = 1;
if (has_booleanvalue()) {
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(1, this->booleanvalue(), target);
}
// optional double numberValue = 2;
if (has_numbervalue()) {
target = ::google::protobuf::internal::WireFormatLite::WriteDoubleToArray(2, this->numbervalue(), target);
}
// optional string stringValue = 3;
if (has_stringvalue()) {
::google::protobuf::internal::WireFormat::VerifyUTF8String(
this->stringvalue().data(), this->stringvalue().length(),
::google::protobuf::internal::WireFormat::SERIALIZE);
target =
::google::protobuf::internal::WireFormatLite::WriteStringToArray(
3, this->stringvalue(), target);
}
// repeated .PB_ArangoJsonContent objects = 4;
for (int i = 0; i < this->objects_size(); i++) {
target = ::google::protobuf::internal::WireFormatLite::
WriteMessageNoVirtualToArray(
4, this->objects(i), target);
}
if (!unknown_fields().empty()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
unknown_fields(), target);
}
return target;
}
int PB_ArangoJsonValue::ByteSize() const {
int total_size = 0;
if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
// optional bool booleanValue = 1;
if (has_booleanvalue()) {
total_size += 1 + 1;
}
// optional double numberValue = 2;
if (has_numbervalue()) {
total_size += 1 + 8;
}
// optional string stringValue = 3;
if (has_stringvalue()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->stringvalue());
}
}
// repeated .PB_ArangoJsonContent objects = 4;
total_size += 1 * this->objects_size();
for (int i = 0; i < this->objects_size(); i++) {
total_size +=
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
this->objects(i));
}
if (!unknown_fields().empty()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
unknown_fields());
}
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = total_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void PB_ArangoJsonValue::MergeFrom(const ::google::protobuf::Message& from) {
GOOGLE_CHECK_NE(&from, this);
const PB_ArangoJsonValue* source =
::google::protobuf::internal::dynamic_cast_if_available<const PB_ArangoJsonValue*>(
&from);
if (source == NULL) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
MergeFrom(*source);
}
}
void PB_ArangoJsonValue::MergeFrom(const PB_ArangoJsonValue& from) {
GOOGLE_CHECK_NE(&from, this);
objects_.MergeFrom(from.objects_);
if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
if (from.has_booleanvalue()) {
set_booleanvalue(from.booleanvalue());
}
if (from.has_numbervalue()) {
set_numbervalue(from.numbervalue());
}
if (from.has_stringvalue()) {
set_stringvalue(from.stringvalue());
}
}
mutable_unknown_fields()->MergeFrom(from.unknown_fields());
}
void PB_ArangoJsonValue::CopyFrom(const ::google::protobuf::Message& from) {
if (&from == this) return;
Clear();
MergeFrom(from);
}
void PB_ArangoJsonValue::CopyFrom(const PB_ArangoJsonValue& from) {
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool PB_ArangoJsonValue::IsInitialized() const {
for (int i = 0; i < objects_size(); i++) {
if (!this->objects(i).IsInitialized()) return false;
}
return true;
}
void PB_ArangoJsonValue::Swap(PB_ArangoJsonValue* other) {
if (other != this) {
std::swap(booleanvalue_, other->booleanvalue_);
std::swap(numbervalue_, other->numbervalue_);
std::swap(stringvalue_, other->stringvalue_);
objects_.Swap(&other->objects_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_unknown_fields_.Swap(&other->_unknown_fields_);
std::swap(_cached_size_, other->_cached_size_);
}
}
::google::protobuf::Metadata PB_ArangoJsonValue::GetMetadata() const {
protobuf_AssignDescriptorsOnce();
::google::protobuf::Metadata metadata;
metadata.descriptor = PB_ArangoJsonValue_descriptor_;
metadata.reflection = PB_ArangoJsonValue_reflection_;
return metadata;
}
// ===================================================================
#ifndef _MSC_VER
const int PB_ArangoJsonContent::kTypeFieldNumber;
const int PB_ArangoJsonContent::kValueFieldNumber;
#endif // !_MSC_VER
PB_ArangoJsonContent::PB_ArangoJsonContent()
: ::google::protobuf::Message() {
SharedCtor();
}
void PB_ArangoJsonContent::InitAsDefaultInstance() {
value_ = const_cast< ::PB_ArangoJsonValue*>(&::PB_ArangoJsonValue::default_instance());
}
PB_ArangoJsonContent::PB_ArangoJsonContent(const PB_ArangoJsonContent& from)
: ::google::protobuf::Message() {
SharedCtor();
MergeFrom(from);
}
void PB_ArangoJsonContent::SharedCtor() {
_cached_size_ = 0;
type_ = 0;
value_ = NULL;
::memset(_has_bits_, 0, sizeof(_has_bits_));
}
PB_ArangoJsonContent::~PB_ArangoJsonContent() {
SharedDtor();
}
void PB_ArangoJsonContent::SharedDtor() {
if (this != default_instance_) {
delete value_;
}
}
void PB_ArangoJsonContent::SetCachedSize(int size) const {
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* PB_ArangoJsonContent::descriptor() {
protobuf_AssignDescriptorsOnce();
return PB_ArangoJsonContent_descriptor_;
}
const PB_ArangoJsonContent& PB_ArangoJsonContent::default_instance() {
if (default_instance_ == NULL) protobuf_AddDesc_lib_2fProtocolBuffers_2farangodb_2eproto(); return *default_instance_;
}
PB_ArangoJsonContent* PB_ArangoJsonContent::default_instance_ = NULL;
PB_ArangoJsonContent* PB_ArangoJsonContent::New() const {
return new PB_ArangoJsonContent;
}
void PB_ArangoJsonContent::Clear() {
if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
type_ = 0;
if (has_value()) {
if (value_ != NULL) value_->::PB_ArangoJsonValue::Clear();
}
}
::memset(_has_bits_, 0, sizeof(_has_bits_));
mutable_unknown_fields()->Clear();
}
bool PB_ArangoJsonContent::MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!(EXPRESSION)) return false
::google::protobuf::uint32 tag;
while ((tag = input->ReadTag()) != 0) {
switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
// required .PB_ArangoJsonType type = 1;
case 1: {
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
int value;
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
input, &value)));
if (PB_ArangoJsonType_IsValid(value)) {
set_type(static_cast< PB_ArangoJsonType >(value));
} else {
mutable_unknown_fields()->AddVarint(1, value);
}
} else {
goto handle_uninterpreted;
}
if (input->ExpectTag(18)) goto parse_value;
break;
}
// optional .PB_ArangoJsonValue value = 2;
case 2: {
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
parse_value:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, mutable_value()));
} else {
goto handle_uninterpreted;
}
if (input->ExpectAtEnd()) return true;
break;
}
default: {
handle_uninterpreted:
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {
return true;
}
DO_(::google::protobuf::internal::WireFormat::SkipField(
input, tag, mutable_unknown_fields()));
break;
}
}
}
return true;
#undef DO_
}
void PB_ArangoJsonContent::SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const {
// required .PB_ArangoJsonType type = 1;
if (has_type()) {
::google::protobuf::internal::WireFormatLite::WriteEnum(
1, this->type(), output);
}
// optional .PB_ArangoJsonValue value = 2;
if (has_value()) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
2, this->value(), output);
}
if (!unknown_fields().empty()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
unknown_fields(), output);
}
}
::google::protobuf::uint8* PB_ArangoJsonContent::SerializeWithCachedSizesToArray(
::google::protobuf::uint8* target) const {
// required .PB_ArangoJsonType type = 1;
if (has_type()) {
target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
1, this->type(), target);
}
// optional .PB_ArangoJsonValue value = 2;
if (has_value()) {
target = ::google::protobuf::internal::WireFormatLite::
WriteMessageNoVirtualToArray(
2, this->value(), target);
}
if (!unknown_fields().empty()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
unknown_fields(), target);
}
return target;
}
int PB_ArangoJsonContent::ByteSize() const {
int total_size = 0;
if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
// required .PB_ArangoJsonType type = 1;
if (has_type()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::EnumSize(this->type());
}
// optional .PB_ArangoJsonValue value = 2;
if (has_value()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
this->value());
}
}
if (!unknown_fields().empty()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
unknown_fields());
}
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = total_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
}
void PB_ArangoJsonContent::MergeFrom(const ::google::protobuf::Message& from) {
GOOGLE_CHECK_NE(&from, this);
const PB_ArangoJsonContent* source =
::google::protobuf::internal::dynamic_cast_if_available<const PB_ArangoJsonContent*>(
&from);
if (source == NULL) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
MergeFrom(*source);
}
}
void PB_ArangoJsonContent::MergeFrom(const PB_ArangoJsonContent& from) {
GOOGLE_CHECK_NE(&from, this);
if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
if (from.has_type()) {
set_type(from.type());
}
if (from.has_value()) {
mutable_value()->::PB_ArangoJsonValue::MergeFrom(from.value());
}
}
mutable_unknown_fields()->MergeFrom(from.unknown_fields());
}
void PB_ArangoJsonContent::CopyFrom(const ::google::protobuf::Message& from) {
if (&from == this) return;
Clear();
MergeFrom(from);
}
void PB_ArangoJsonContent::CopyFrom(const PB_ArangoJsonContent& from) {
if (&from == this) return;
Clear();
MergeFrom(from);
}
bool PB_ArangoJsonContent::IsInitialized() const {
if ((_has_bits_[0] & 0x00000001) != 0x00000001) return false;
if (has_value()) {
if (!this->value().IsInitialized()) return false;
}
return true;
}
void PB_ArangoJsonContent::Swap(PB_ArangoJsonContent* other) {
if (other != this) {
std::swap(type_, other->type_);
std::swap(value_, other->value_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_unknown_fields_.Swap(&other->_unknown_fields_);
std::swap(_cached_size_, other->_cached_size_);
}
}
::google::protobuf::Metadata PB_ArangoJsonContent::GetMetadata() const {
protobuf_AssignDescriptorsOnce();
::google::protobuf::Metadata metadata;
metadata.descriptor = PB_ArangoJsonContent_descriptor_;
metadata.reflection = PB_ArangoJsonContent_reflection_;
return metadata;
}
// ===================================================================
#ifndef _MSC_VER
@ -1158,6 +1847,7 @@ const int PB_ArangoBlobRequest::kValuesFieldNumber;
const int PB_ArangoBlobRequest::kHeadersFieldNumber;
const int PB_ArangoBlobRequest::kContentTypeFieldNumber;
const int PB_ArangoBlobRequest::kContentFieldNumber;
const int PB_ArangoBlobRequest::kJsonFieldNumber;
#endif // !_MSC_VER
PB_ArangoBlobRequest::PB_ArangoBlobRequest()
@ -1166,6 +1856,7 @@ PB_ArangoBlobRequest::PB_ArangoBlobRequest()
}
void PB_ArangoBlobRequest::InitAsDefaultInstance() {
json_ = const_cast< ::PB_ArangoJsonContent*>(&::PB_ArangoJsonContent::default_instance());
}
PB_ArangoBlobRequest::PB_ArangoBlobRequest(const PB_ArangoBlobRequest& from)
@ -1180,6 +1871,7 @@ void PB_ArangoBlobRequest::SharedCtor() {
url_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
contenttype_ = 0;
content_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
json_ = NULL;
::memset(_has_bits_, 0, sizeof(_has_bits_));
}
@ -1195,6 +1887,7 @@ void PB_ArangoBlobRequest::SharedDtor() {
delete content_;
}
if (this != default_instance_) {
delete json_;
}
}
@ -1232,6 +1925,9 @@ void PB_ArangoBlobRequest::Clear() {
content_->clear();
}
}
if (has_json()) {
if (json_ != NULL) json_->::PB_ArangoJsonContent::Clear();
}
}
values_.Clear();
headers_.Clear();
@ -1346,6 +2042,20 @@ bool PB_ArangoBlobRequest::MergePartialFromCodedStream(
} else {
goto handle_uninterpreted;
}
if (input->ExpectTag(66)) goto parse_json;
break;
}
// optional .PB_ArangoJsonContent json = 8;
case 8: {
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
parse_json:
DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
input, mutable_json()));
} else {
goto handle_uninterpreted;
}
if (input->ExpectAtEnd()) return true;
break;
}
@ -1410,6 +2120,12 @@ void PB_ArangoBlobRequest::SerializeWithCachedSizes(
7, this->content(), output);
}
// optional .PB_ArangoJsonContent json = 8;
if (has_json()) {
::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
8, this->json(), output);
}
if (!unknown_fields().empty()) {
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
unknown_fields(), output);
@ -1464,6 +2180,13 @@ void PB_ArangoBlobRequest::SerializeWithCachedSizes(
7, this->content(), target);
}
// optional .PB_ArangoJsonContent json = 8;
if (has_json()) {
target = ::google::protobuf::internal::WireFormatLite::
WriteMessageNoVirtualToArray(
8, this->json(), target);
}
if (!unknown_fields().empty()) {
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
unknown_fields(), target);
@ -1501,6 +2224,13 @@ int PB_ArangoBlobRequest::ByteSize() const {
this->content());
}
// optional .PB_ArangoJsonContent json = 8;
if (has_json()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
this->json());
}
}
// repeated .PB_ArangoKeyValue values = 3;
total_size += 1 * this->values_size();
@ -1558,6 +2288,9 @@ void PB_ArangoBlobRequest::MergeFrom(const PB_ArangoBlobRequest& from) {
if (from.has_content()) {
set_content(from.content());
}
if (from.has_json()) {
mutable_json()->::PB_ArangoJsonContent::MergeFrom(from.json());
}
}
mutable_unknown_fields()->MergeFrom(from.unknown_fields());
}
@ -1583,6 +2316,9 @@ bool PB_ArangoBlobRequest::IsInitialized() const {
for (int i = 0; i < headers_size(); i++) {
if (!this->headers(i).IsInitialized()) return false;
}
if (has_json()) {
if (!this->json().IsInitialized()) return false;
}
return true;
}
@ -1594,6 +2330,7 @@ void PB_ArangoBlobRequest::Swap(PB_ArangoBlobRequest* other) {
headers_.Swap(&other->headers_);
std::swap(contenttype_, other->contenttype_);
std::swap(content_, other->content_);
std::swap(json_, other->json_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
_unknown_fields_.Swap(&other->_unknown_fields_);
std::swap(_cached_size_, other->_cached_size_);

View File

@ -33,6 +33,8 @@ void protobuf_ShutdownFile_lib_2fProtocolBuffers_2farangodb_2eproto();
class PB_ArangoKeyValue;
class PB_ArangoMessage;
class PB_ArangoBatchMessage;
class PB_ArangoJsonValue;
class PB_ArangoJsonContent;
class PB_ArangoBlobRequest;
class PB_ArangoBlobResponse;
class PB_ArangoErrorResponse;
@ -100,6 +102,29 @@ inline bool PB_ArangoRequestType_Parse(
return ::google::protobuf::internal::ParseNamedEnum<PB_ArangoRequestType>(
PB_ArangoRequestType_descriptor(), name, value);
}
enum PB_ArangoJsonType {
PB_REQUEST_TYPE_NULL = 0,
PB_REQUEST_TYPE_BOOLEAN = 1,
PB_REQUEST_TYPE_NUMBER = 2,
PB_REQUEST_TYPE_STRING = 3,
PB_REQUEST_TYPE_ARRAY = 4,
PB_REQUEST_TYPE_LIST = 5
};
bool PB_ArangoJsonType_IsValid(int value);
const PB_ArangoJsonType PB_ArangoJsonType_MIN = PB_REQUEST_TYPE_NULL;
const PB_ArangoJsonType PB_ArangoJsonType_MAX = PB_REQUEST_TYPE_LIST;
const int PB_ArangoJsonType_ARRAYSIZE = PB_ArangoJsonType_MAX + 1;
const ::google::protobuf::EnumDescriptor* PB_ArangoJsonType_descriptor();
inline const ::std::string& PB_ArangoJsonType_Name(PB_ArangoJsonType value) {
return ::google::protobuf::internal::NameOfEnum(
PB_ArangoJsonType_descriptor(), value);
}
inline bool PB_ArangoJsonType_Parse(
const ::std::string& name, PB_ArangoJsonType* value) {
return ::google::protobuf::internal::ParseNamedEnum<PB_ArangoJsonType>(
PB_ArangoJsonType_descriptor(), name, value);
}
// ===================================================================
class PB_ArangoKeyValue : public ::google::protobuf::Message {
@ -402,6 +427,218 @@ class PB_ArangoBatchMessage : public ::google::protobuf::Message {
};
// -------------------------------------------------------------------
class PB_ArangoJsonValue : public ::google::protobuf::Message {
public:
PB_ArangoJsonValue();
virtual ~PB_ArangoJsonValue();
PB_ArangoJsonValue(const PB_ArangoJsonValue& from);
inline PB_ArangoJsonValue& operator=(const PB_ArangoJsonValue& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const PB_ArangoJsonValue& default_instance();
void Swap(PB_ArangoJsonValue* other);
// implements Message ----------------------------------------------
PB_ArangoJsonValue* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const PB_ArangoJsonValue& from);
void MergeFrom(const PB_ArangoJsonValue& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// optional bool booleanValue = 1;
inline bool has_booleanvalue() const;
inline void clear_booleanvalue();
static const int kBooleanValueFieldNumber = 1;
inline bool booleanvalue() const;
inline void set_booleanvalue(bool value);
// optional double numberValue = 2;
inline bool has_numbervalue() const;
inline void clear_numbervalue();
static const int kNumberValueFieldNumber = 2;
inline double numbervalue() const;
inline void set_numbervalue(double value);
// optional string stringValue = 3;
inline bool has_stringvalue() const;
inline void clear_stringvalue();
static const int kStringValueFieldNumber = 3;
inline const ::std::string& stringvalue() const;
inline void set_stringvalue(const ::std::string& value);
inline void set_stringvalue(const char* value);
inline void set_stringvalue(const char* value, size_t size);
inline ::std::string* mutable_stringvalue();
inline ::std::string* release_stringvalue();
// repeated .PB_ArangoJsonContent objects = 4;
inline int objects_size() const;
inline void clear_objects();
static const int kObjectsFieldNumber = 4;
inline const ::PB_ArangoJsonContent& objects(int index) const;
inline ::PB_ArangoJsonContent* mutable_objects(int index);
inline ::PB_ArangoJsonContent* add_objects();
inline const ::google::protobuf::RepeatedPtrField< ::PB_ArangoJsonContent >&
objects() const;
inline ::google::protobuf::RepeatedPtrField< ::PB_ArangoJsonContent >*
mutable_objects();
// @@protoc_insertion_point(class_scope:PB_ArangoJsonValue)
private:
inline void set_has_booleanvalue();
inline void clear_has_booleanvalue();
inline void set_has_numbervalue();
inline void clear_has_numbervalue();
inline void set_has_stringvalue();
inline void clear_has_stringvalue();
::google::protobuf::UnknownFieldSet _unknown_fields_;
double numbervalue_;
::std::string* stringvalue_;
::google::protobuf::RepeatedPtrField< ::PB_ArangoJsonContent > objects_;
bool booleanvalue_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(4 + 31) / 32];
friend void protobuf_AddDesc_lib_2fProtocolBuffers_2farangodb_2eproto();
friend void protobuf_AssignDesc_lib_2fProtocolBuffers_2farangodb_2eproto();
friend void protobuf_ShutdownFile_lib_2fProtocolBuffers_2farangodb_2eproto();
void InitAsDefaultInstance();
static PB_ArangoJsonValue* default_instance_;
};
// -------------------------------------------------------------------
class PB_ArangoJsonContent : public ::google::protobuf::Message {
public:
PB_ArangoJsonContent();
virtual ~PB_ArangoJsonContent();
PB_ArangoJsonContent(const PB_ArangoJsonContent& from);
inline PB_ArangoJsonContent& operator=(const PB_ArangoJsonContent& from) {
CopyFrom(from);
return *this;
}
inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {
return _unknown_fields_;
}
inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {
return &_unknown_fields_;
}
static const ::google::protobuf::Descriptor* descriptor();
static const PB_ArangoJsonContent& default_instance();
void Swap(PB_ArangoJsonContent* other);
// implements Message ----------------------------------------------
PB_ArangoJsonContent* New() const;
void CopyFrom(const ::google::protobuf::Message& from);
void MergeFrom(const ::google::protobuf::Message& from);
void CopyFrom(const PB_ArangoJsonContent& from);
void MergeFrom(const PB_ArangoJsonContent& from);
void Clear();
bool IsInitialized() const;
int ByteSize() const;
bool MergePartialFromCodedStream(
::google::protobuf::io::CodedInputStream* input);
void SerializeWithCachedSizes(
::google::protobuf::io::CodedOutputStream* output) const;
::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const;
int GetCachedSize() const { return _cached_size_; }
private:
void SharedCtor();
void SharedDtor();
void SetCachedSize(int size) const;
public:
::google::protobuf::Metadata GetMetadata() const;
// nested types ----------------------------------------------------
// accessors -------------------------------------------------------
// required .PB_ArangoJsonType type = 1;
inline bool has_type() const;
inline void clear_type();
static const int kTypeFieldNumber = 1;
inline PB_ArangoJsonType type() const;
inline void set_type(PB_ArangoJsonType value);
// optional .PB_ArangoJsonValue value = 2;
inline bool has_value() const;
inline void clear_value();
static const int kValueFieldNumber = 2;
inline const ::PB_ArangoJsonValue& value() const;
inline ::PB_ArangoJsonValue* mutable_value();
inline ::PB_ArangoJsonValue* release_value();
// @@protoc_insertion_point(class_scope:PB_ArangoJsonContent)
private:
inline void set_has_type();
inline void clear_has_type();
inline void set_has_value();
inline void clear_has_value();
::google::protobuf::UnknownFieldSet _unknown_fields_;
::PB_ArangoJsonValue* value_;
int type_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(2 + 31) / 32];
friend void protobuf_AddDesc_lib_2fProtocolBuffers_2farangodb_2eproto();
friend void protobuf_AssignDesc_lib_2fProtocolBuffers_2farangodb_2eproto();
friend void protobuf_ShutdownFile_lib_2fProtocolBuffers_2farangodb_2eproto();
void InitAsDefaultInstance();
static PB_ArangoJsonContent* default_instance_;
};
// -------------------------------------------------------------------
class PB_ArangoBlobRequest : public ::google::protobuf::Message {
public:
PB_ArangoBlobRequest();
@ -516,6 +753,14 @@ class PB_ArangoBlobRequest : public ::google::protobuf::Message {
inline ::std::string* mutable_content();
inline ::std::string* release_content();
// optional .PB_ArangoJsonContent json = 8;
inline bool has_json() const;
inline void clear_json();
static const int kJsonFieldNumber = 8;
inline const ::PB_ArangoJsonContent& json() const;
inline ::PB_ArangoJsonContent* mutable_json();
inline ::PB_ArangoJsonContent* release_json();
// @@protoc_insertion_point(class_scope:PB_ArangoBlobRequest)
private:
inline void set_has_requesttype();
@ -526,6 +771,8 @@ class PB_ArangoBlobRequest : public ::google::protobuf::Message {
inline void clear_has_contenttype();
inline void set_has_content();
inline void clear_has_content();
inline void set_has_json();
inline void clear_has_json();
::google::protobuf::UnknownFieldSet _unknown_fields_;
@ -535,9 +782,10 @@ class PB_ArangoBlobRequest : public ::google::protobuf::Message {
int contenttype_;
::google::protobuf::RepeatedPtrField< ::PB_ArangoKeyValue > headers_;
::std::string* content_;
::PB_ArangoJsonContent* json_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(6 + 31) / 32];
::google::protobuf::uint32 _has_bits_[(7 + 31) / 32];
friend void protobuf_AddDesc_lib_2fProtocolBuffers_2farangodb_2eproto();
friend void protobuf_AssignDesc_lib_2fProtocolBuffers_2farangodb_2eproto();
@ -1029,6 +1277,193 @@ inline ::PB_ArangoErrorResponse* PB_ArangoBatchMessage::release_errorresponse()
// -------------------------------------------------------------------
// PB_ArangoJsonValue
// optional bool booleanValue = 1;
inline bool PB_ArangoJsonValue::has_booleanvalue() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void PB_ArangoJsonValue::set_has_booleanvalue() {
_has_bits_[0] |= 0x00000001u;
}
inline void PB_ArangoJsonValue::clear_has_booleanvalue() {
_has_bits_[0] &= ~0x00000001u;
}
inline void PB_ArangoJsonValue::clear_booleanvalue() {
booleanvalue_ = false;
clear_has_booleanvalue();
}
inline bool PB_ArangoJsonValue::booleanvalue() const {
return booleanvalue_;
}
inline void PB_ArangoJsonValue::set_booleanvalue(bool value) {
set_has_booleanvalue();
booleanvalue_ = value;
}
// optional double numberValue = 2;
inline bool PB_ArangoJsonValue::has_numbervalue() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void PB_ArangoJsonValue::set_has_numbervalue() {
_has_bits_[0] |= 0x00000002u;
}
inline void PB_ArangoJsonValue::clear_has_numbervalue() {
_has_bits_[0] &= ~0x00000002u;
}
inline void PB_ArangoJsonValue::clear_numbervalue() {
numbervalue_ = 0;
clear_has_numbervalue();
}
inline double PB_ArangoJsonValue::numbervalue() const {
return numbervalue_;
}
inline void PB_ArangoJsonValue::set_numbervalue(double value) {
set_has_numbervalue();
numbervalue_ = value;
}
// optional string stringValue = 3;
inline bool PB_ArangoJsonValue::has_stringvalue() const {
return (_has_bits_[0] & 0x00000004u) != 0;
}
inline void PB_ArangoJsonValue::set_has_stringvalue() {
_has_bits_[0] |= 0x00000004u;
}
inline void PB_ArangoJsonValue::clear_has_stringvalue() {
_has_bits_[0] &= ~0x00000004u;
}
inline void PB_ArangoJsonValue::clear_stringvalue() {
if (stringvalue_ != &::google::protobuf::internal::kEmptyString) {
stringvalue_->clear();
}
clear_has_stringvalue();
}
inline const ::std::string& PB_ArangoJsonValue::stringvalue() const {
return *stringvalue_;
}
inline void PB_ArangoJsonValue::set_stringvalue(const ::std::string& value) {
set_has_stringvalue();
if (stringvalue_ == &::google::protobuf::internal::kEmptyString) {
stringvalue_ = new ::std::string;
}
stringvalue_->assign(value);
}
inline void PB_ArangoJsonValue::set_stringvalue(const char* value) {
set_has_stringvalue();
if (stringvalue_ == &::google::protobuf::internal::kEmptyString) {
stringvalue_ = new ::std::string;
}
stringvalue_->assign(value);
}
inline void PB_ArangoJsonValue::set_stringvalue(const char* value, size_t size) {
set_has_stringvalue();
if (stringvalue_ == &::google::protobuf::internal::kEmptyString) {
stringvalue_ = new ::std::string;
}
stringvalue_->assign(reinterpret_cast<const char*>(value), size);
}
inline ::std::string* PB_ArangoJsonValue::mutable_stringvalue() {
set_has_stringvalue();
if (stringvalue_ == &::google::protobuf::internal::kEmptyString) {
stringvalue_ = new ::std::string;
}
return stringvalue_;
}
inline ::std::string* PB_ArangoJsonValue::release_stringvalue() {
clear_has_stringvalue();
if (stringvalue_ == &::google::protobuf::internal::kEmptyString) {
return NULL;
} else {
::std::string* temp = stringvalue_;
stringvalue_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString);
return temp;
}
}
// repeated .PB_ArangoJsonContent objects = 4;
inline int PB_ArangoJsonValue::objects_size() const {
return objects_.size();
}
inline void PB_ArangoJsonValue::clear_objects() {
objects_.Clear();
}
inline const ::PB_ArangoJsonContent& PB_ArangoJsonValue::objects(int index) const {
return objects_.Get(index);
}
inline ::PB_ArangoJsonContent* PB_ArangoJsonValue::mutable_objects(int index) {
return objects_.Mutable(index);
}
inline ::PB_ArangoJsonContent* PB_ArangoJsonValue::add_objects() {
return objects_.Add();
}
inline const ::google::protobuf::RepeatedPtrField< ::PB_ArangoJsonContent >&
PB_ArangoJsonValue::objects() const {
return objects_;
}
inline ::google::protobuf::RepeatedPtrField< ::PB_ArangoJsonContent >*
PB_ArangoJsonValue::mutable_objects() {
return &objects_;
}
// -------------------------------------------------------------------
// PB_ArangoJsonContent
// required .PB_ArangoJsonType type = 1;
inline bool PB_ArangoJsonContent::has_type() const {
return (_has_bits_[0] & 0x00000001u) != 0;
}
inline void PB_ArangoJsonContent::set_has_type() {
_has_bits_[0] |= 0x00000001u;
}
inline void PB_ArangoJsonContent::clear_has_type() {
_has_bits_[0] &= ~0x00000001u;
}
inline void PB_ArangoJsonContent::clear_type() {
type_ = 0;
clear_has_type();
}
inline PB_ArangoJsonType PB_ArangoJsonContent::type() const {
return static_cast< PB_ArangoJsonType >(type_);
}
inline void PB_ArangoJsonContent::set_type(PB_ArangoJsonType value) {
GOOGLE_DCHECK(PB_ArangoJsonType_IsValid(value));
set_has_type();
type_ = value;
}
// optional .PB_ArangoJsonValue value = 2;
inline bool PB_ArangoJsonContent::has_value() const {
return (_has_bits_[0] & 0x00000002u) != 0;
}
inline void PB_ArangoJsonContent::set_has_value() {
_has_bits_[0] |= 0x00000002u;
}
inline void PB_ArangoJsonContent::clear_has_value() {
_has_bits_[0] &= ~0x00000002u;
}
inline void PB_ArangoJsonContent::clear_value() {
if (value_ != NULL) value_->::PB_ArangoJsonValue::Clear();
clear_has_value();
}
inline const ::PB_ArangoJsonValue& PB_ArangoJsonContent::value() const {
return value_ != NULL ? *value_ : *default_instance_->value_;
}
inline ::PB_ArangoJsonValue* PB_ArangoJsonContent::mutable_value() {
set_has_value();
if (value_ == NULL) value_ = new ::PB_ArangoJsonValue;
return value_;
}
inline ::PB_ArangoJsonValue* PB_ArangoJsonContent::release_value() {
clear_has_value();
::PB_ArangoJsonValue* temp = value_;
value_ = NULL;
return temp;
}
// -------------------------------------------------------------------
// PB_ArangoBlobRequest
// required .PB_ArangoRequestType requestType = 1;
@ -1243,6 +1678,35 @@ inline ::std::string* PB_ArangoBlobRequest::release_content() {
}
}
// optional .PB_ArangoJsonContent json = 8;
inline bool PB_ArangoBlobRequest::has_json() const {
return (_has_bits_[0] & 0x00000040u) != 0;
}
inline void PB_ArangoBlobRequest::set_has_json() {
_has_bits_[0] |= 0x00000040u;
}
inline void PB_ArangoBlobRequest::clear_has_json() {
_has_bits_[0] &= ~0x00000040u;
}
inline void PB_ArangoBlobRequest::clear_json() {
if (json_ != NULL) json_->::PB_ArangoJsonContent::Clear();
clear_has_json();
}
inline const ::PB_ArangoJsonContent& PB_ArangoBlobRequest::json() const {
return json_ != NULL ? *json_ : *default_instance_->json_;
}
inline ::PB_ArangoJsonContent* PB_ArangoBlobRequest::mutable_json() {
set_has_json();
if (json_ == NULL) json_ = new ::PB_ArangoJsonContent;
return json_;
}
inline ::PB_ArangoJsonContent* PB_ArangoBlobRequest::release_json() {
clear_has_json();
::PB_ArangoJsonContent* temp = json_;
json_ = NULL;
return temp;
}
// -------------------------------------------------------------------
// PB_ArangoBlobResponse
@ -1478,6 +1942,10 @@ template <>
inline const EnumDescriptor* GetEnumDescriptor< PB_ArangoRequestType>() {
return PB_ArangoRequestType_descriptor();
}
template <>
inline const EnumDescriptor* GetEnumDescriptor< PB_ArangoJsonType>() {
return PB_ArangoJsonType_descriptor();
}
} // namespace google
} // namespace protobuf

View File

@ -50,6 +50,15 @@ enum PB_ArangoRequestType {
PB_REQUEST_TYPE_PATCH = 5;
}
enum PB_ArangoJsonType {
PB_REQUEST_TYPE_NULL = 0;
PB_REQUEST_TYPE_BOOLEAN = 1;
PB_REQUEST_TYPE_NUMBER = 2;
PB_REQUEST_TYPE_STRING = 3;
PB_REQUEST_TYPE_ARRAY = 4;
PB_REQUEST_TYPE_LIST = 5;
}
// -----------------------------------------------------------------------------
// --SECTION-- general
// -----------------------------------------------------------------------------
@ -70,6 +79,26 @@ message PB_ArangoBatchMessage {
optional PB_ArangoErrorResponse errorResponse = 4;
}
// -----------------------------------------------------------------------------
// --SECTION-- json value
// -----------------------------------------------------------------------------
message PB_ArangoJsonValue {
optional bool booleanValue = 1;
optional double numberValue = 2;
optional string stringValue = 3;
repeated PB_ArangoJsonContent objects = 4;
}
// -----------------------------------------------------------------------------
// --SECTION-- json content
// -----------------------------------------------------------------------------
message PB_ArangoJsonContent {
required PB_ArangoJsonType type = 1;
optional PB_ArangoJsonValue value = 2;
}
// -----------------------------------------------------------------------------
// --SECTION-- blob request
// -----------------------------------------------------------------------------
@ -81,6 +110,7 @@ message PB_ArangoBlobRequest {
repeated PB_ArangoKeyValue headers = 4; // key must be lowercase
required PB_ArangoMessageContentType contentType = 5;
optional string content = 7;
optional PB_ArangoJsonContent json = 8;
}
// -----------------------------------------------------------------------------

View File

@ -31,6 +31,7 @@
#include "Basics/Common.h"
#include "BasicsC/json.h"
#include "BasicsC/string-buffer.h"
#include "Rest/ConnectionInfo.h"
@ -142,6 +143,12 @@ namespace triagens {
public:
////////////////////////////////////////////////////////////////////////////////
/// @brief get the request body as TRI_json_t*
////////////////////////////////////////////////////////////////////////////////
virtual TRI_json_t* toJson (char*&) = 0;
////////////////////////////////////////////////////////////////////////////////
/// @brief returns the server IP
////////////////////////////////////////////////////////////////////////////////

View File

@ -117,6 +117,12 @@ HttpRequestPlain::~HttpRequestPlain () {
/// @{
////////////////////////////////////////////////////////////////////////////////
TRI_json_t* HttpRequestPlain::toJson (char*& errmsg) {
TRI_json_t* json = TRI_Json2String(TRI_UNKNOWN_MEM_ZONE, body(), &errmsg);
return json;
}
////////////////////////////////////////////////////////////////////////////////
/// {@inheritDoc}
////////////////////////////////////////////////////////////////////////////////

View File

@ -115,6 +115,8 @@ namespace triagens {
////////////////////////////////////////////////////////////////////////////////
public:
virtual TRI_json_t* toJson (char*&);
////////////////////////////////////////////////////////////////////////////////
/// {@inheritDoc}