diff --git a/proto/Request.proto b/proto/Request.proto index 7676a35e5d599ba59d09f35f5d8a71f76030f3ab..14d2e8fe53bf74002feabc92d2999c18e4812f27 100644 --- a/proto/Request.proto +++ b/proto/Request.proto @@ -32,19 +32,9 @@ message Request message Column { - enum Type - { - DT_DOUBLE = 0; - DT_INTEGER = 1; - DT_UNSIGNED_LONG = 2; - DT_LONG_LONG = 3; - DT_STRING = 4; - DT_DATE = 5; - } - required string name = 1; - required Type type = 2; - required bool nullable = 3; + required string type = 2; + required string nullable = 3; } repeated Column columns = 3; diff --git a/src/DBManager.cpp b/src/DBManager.cpp index e8f9dc3acf6d64ee77e7f4be8d0e565ba0add7ab..ac0254dc8022512989ed27e9ba8e6afa8414553d 100644 --- a/src/DBManager.cpp +++ b/src/DBManager.cpp @@ -1,6 +1,7 @@ #include <DBManager.h> #include <soci/mysql/soci-mysql.h> +#include <soci/use.h> namespace MetadataExporter_ns { @@ -46,22 +47,24 @@ void DBManager::connect() throw(soci::soci_error) { DEBUG_STREAM << "DBManager::connect()" << endl; -// std::stringstream connection; -// connection << " host=" << m_configuration_sp->getDatabaseHost(); -// connection << " port=" << m_configuration_sp->getDatabasePort(); -// connection << " user=" << m_configuration_sp->getDatabaseUsername(); -// connection << " password=" << m_configuration_sp->getDatabasePassword(); -// -// unsigned int connectionNumber = m_configuration_sp->getDatabaseConnectionNumber(); -// -// for(unsigned int i=0; i<connectionNumber; ++i) -// { -// m_connectionPool_sp->at(i).open(soci::mysql, connection.str()); -// -// #ifdef VERBOSE_DEBUG -// INFO_STREAM << "CONNECTION: " << connection.str() << " -> OPEN" << endl; -// #endif -// } + boost::mutex::scoped_lock lock(m_connectionPoolMutex); + + std::stringstream connection; + connection << " host=" << m_configuration_sp->getDatabaseHost(); + connection << " port=" << m_configuration_sp->getDatabasePort(); + connection << " user=" << m_configuration_sp->getDatabaseUsername(); + connection << " password=" << m_configuration_sp->getDatabasePassword(); + + #ifdef VERBOSE_DEBUG + INFO_STREAM << "CONNECTION: " << connection.str() << endl; + #endif + + unsigned int connectionNumber = m_configuration_sp->getDatabaseConnectionNumber(); + + for(unsigned int i=0; i<connectionNumber; ++i) + { + m_connectionPool_sp->at(i).open(soci::mysql, connection.str()); + } } //============================================================================== @@ -71,22 +74,53 @@ void DBManager::disconnect() { DEBUG_STREAM << "DBManager::disconnect()" << endl; -// std::stringstream connection; -// connection << " host=" << m_configuration_sp->getDatabaseHost(); -// connection << " port=" << m_configuration_sp->getDatabasePort(); -// connection << " user=" << m_configuration_sp->getDatabaseUsername(); -// connection << " password=" << m_configuration_sp->getDatabasePassword(); -// -// unsigned int connectionNumber = m_configuration_sp->getDatabaseConnectionNumber(); -// -// for(unsigned int i=0; i<connectionNumber; ++i) -// { -// m_connectionPool_sp->at(i).close(); -// -// #ifdef VERBOSE_DEBUG -// INFO_STREAM << "CONNECTION: " << connection.str() << " -> CLOSE" << endl; -// #endif -// } + boost::mutex::scoped_lock lock(m_connectionPoolMutex); + + unsigned int connectionNumber = m_configuration_sp->getDatabaseConnectionNumber(); + + for(unsigned int i=0; i<connectionNumber; ++i) + { + m_connectionPool_sp->at(i).close(); + } +} + +//============================================================================== +// DBManager::retrieveInformation() +//============================================================================== +DBManager::InformationList DBManager::retrieveInformation(std::string schema, + std::string table) throw(soci::soci_error) +{ + DEBUG_STREAM << "DBManager::retrieveInformation()" << endl; + + soci::session session(*m_connectionPool_sp); + + soci::rowset<InformationTuple> rows = (session.prepare << "select " + "column_name, column_type, is_nullable from information_schema.columns " + "where table_schema like :schema and table_name like :table", + soci::use(schema, "schema"), soci::use(table, "table")); + + InformationList informationList; + + std::copy(rows.begin(), rows.end(), std::back_inserter(informationList)); + + return informationList; +} + +//============================================================================== +// DBManager::retrieveInformation() +//============================================================================== +soci::rowset<soci::row> DBManager::searchNewTuples(std::string schema, + std::string table, std::tm update_time) throw(soci::soci_error) +{ + DEBUG_STREAM << "DBManager::searchNewTuples()" << endl; + + soci::session session(*m_connectionPool_sp); + + soci::rowset<soci::row> rows = (session.prepare << "select * from " + << schema << "." << table << " where update_time>=:timestamp", + soci::use(update_time,"timestamp")); + + return rows; } } //namespace diff --git a/src/DBManager.h b/src/DBManager.h index c0c3ce4d4a929ea133392f5857c4a3f8a7f3497e..e1a5c4a8692e3d7431034029d474dbbb20b580df 100644 --- a/src/DBManager.h +++ b/src/DBManager.h @@ -5,10 +5,19 @@ #include <tango.h> +#include <ctime> + +#include <boost/tuple/tuple.hpp> +#include <boost/optional/optional.hpp> #include <boost/scoped_ptr.hpp> #include <boost/thread/mutex.hpp> +#include <soci/soci.h> #include <soci/error.h> +#include <soci/row.h> +#include <soci/rowset.h> +#include <soci/boost-tuple.h> +#include <soci/boost-optional.h> #include <soci/session.h> #include <soci/connection-pool.h> @@ -53,8 +62,21 @@ public: virtual void disconnect(); //------------------------------------------------------------------------------ -// [Public] Data access methods +// [Public] Retrieve information schema method +//------------------------------------------------------------------------------ + typedef boost::tuple< boost::optional<std::string>, boost::optional<std::string>, + boost::optional<std::string> > InformationTuple; + + typedef std::vector< InformationTuple > InformationList; + + virtual InformationList retrieveInformation(std::string, + std::string) throw(soci::soci_error); + +//------------------------------------------------------------------------------ +// [Public] Search new tuple method //------------------------------------------------------------------------------ + virtual soci::rowset<soci::row> searchNewTuples(std::string, std::string, + std::tm) throw(soci::soci_error); protected: //------------------------------------------------------------------------------ diff --git a/src/ProtocolManager.cpp b/src/ProtocolManager.cpp index 620286a406dce4eb31e355be482d9da97a31ef84..f1f27a6564e9762ef01c29b37baecd76730e0ae8 100644 --- a/src/ProtocolManager.cpp +++ b/src/ProtocolManager.cpp @@ -13,7 +13,7 @@ ProtocolManager::ProtocolManager(Tango::DeviceImpl* deviceImpl_p, { DEBUG_STREAM << "ProtocolManager::ProtocolManager()" << endl; - m_isAuthenticated = false; + m_isAuthorised = false; m_isValidated = false; } @@ -88,7 +88,7 @@ ResponseSP ProtocolManager::prepareAuthroisation(RequestSP request_sp) Response::Authorization* auth_resp = response_sp->mutable_authorization(); - if(!m_isAuthenticated) + if(!m_isAuthorised) { const Request::Authorization& auth_req = request_sp->authorization(); std::string username = auth_req.username(); @@ -99,7 +99,7 @@ ResponseSP ProtocolManager::prepareAuthroisation(RequestSP request_sp) INFO_STREAM << "ProtocolManager::prepareAuthroisation() " << "Authorization accepted" << endl; - m_isAuthenticated = true; + m_isAuthorised = true; auth_resp->set_state(Response::Authorization::ACCEPTED); auth_resp->set_status("Authorization accepted"); @@ -109,7 +109,7 @@ ResponseSP ProtocolManager::prepareAuthroisation(RequestSP request_sp) WARN_STREAM << "ProtocolManager::prepareAuthroisation() " << "Invalid username or password" << endl; - m_isAuthenticated = false; + m_isAuthorised = false; auth_resp->set_state(Response::Authorization::REJECTED); auth_resp->set_status("Invalid username or password"); @@ -139,25 +139,68 @@ ResponseSP ProtocolManager::prepareValidation(RequestSP request_sp) response_sp->set_type(Response::VALIDATION); - Response::Validation* validation = response_sp->mutable_validation(); + Response::Validation* validationRes = response_sp->mutable_validation(); - if(!m_isValidated) + if(m_isAuthorised) { - INFO_STREAM << "ProtocolManager::prepareValidation() " - << "Validation accepted" << endl; - - m_isValidated = true; + if(!m_isValidated) + { + const Request::Validation& validationReq = request_sp->validation(); + + const std::string& schema = validationReq.schema(); + const std::string& table = validationReq.table(); + + DBManager::InformationList informationList = + m_dBManager_sp->retrieveInformation(schema, table); + + if(validationReq.columns_size() == (int)informationList.size()) + { + const google::protobuf::RepeatedPtrField + < Request::Validation::Column >& columns = validationReq.columns(); + + google::protobuf::RepeatedPtrField + < Request::Validation::Column >::const_iterator it; + + try + { + for(it=columns.begin(); it!=columns.end();++it) + { + validateColumn(*it, informationList); + } + + m_isValidated = true; + + validationRes->set_state(Response::Validation::ACCEPTED); + validationRes->set_status("Table validated"); + } + catch(std::runtime_error& ex) + { + validationRes->set_state(Response::Validation::REJECTED); + validationRes->set_status(ex.what()); + } + } + else + { + validationRes->set_state(Response::Validation::REJECTED); + validationRes->set_status("Columns number does not match"); + } + } + else + { + WARN_STREAM << "ProtocolManager::prepareValidation() " + << "Already validated" << endl; - validation->set_state(Response::Validation::ACCEPTED); - validation->set_status("Validation accepted"); + validationRes->set_state(Response::Validation::REJECTED); + validationRes->set_status("Already validated"); + } } else { WARN_STREAM << "ProtocolManager::prepareValidation() " - << "Already validated" << endl; + << "Not authorised" << endl; - validation->set_state(Response::Validation::REJECTED); - validation->set_status("Already validated"); + validationRes->set_state(Response::Validation::REJECTED); + validationRes->set_status("Not authorised"); } return response_sp; @@ -177,12 +220,87 @@ ResponseSP ProtocolManager::prepareMetadata(RequestSP request_sp) Response::Metadata* metadata = response_sp->mutable_metadata(); - metadata->set_state(Response::Metadata::ACCEPTED); - metadata->set_status("Metadata ready"); - metadata->set_partial(1); - metadata->set_total(1); + if(m_isAuthorised) + { + if(m_isValidated) + { + metadata->set_state(Response::Metadata::ACCEPTED); + metadata->set_status("Metadata ready"); + metadata->set_partial(0); + metadata->set_total(0); + } + else + { + metadata->set_state(Response::Metadata::REJECTED); + metadata->set_status("Not validated"); + metadata->set_partial(0); + metadata->set_total(0); + } + } + else + { + metadata->set_state(Response::Metadata::REJECTED); + metadata->set_status("Not authorised"); + metadata->set_partial(0); + metadata->set_total(0); + } return response_sp; } +//============================================================================== +// ProtocolManager::validateColumn() +//============================================================================== +void ProtocolManager::validateColumn(const Request::Validation::Column& column, + DBManager::InformationList& informationList) throw(std::runtime_error) +{ + DEBUG_STREAM << "ProtocolManager::validateColumn()" << endl; + + bool found = false; + + DBManager::InformationList::const_iterator it; + for(it=informationList.begin(); it!=informationList.end(); ++it) + { + if(!it->get<0>()) + throw std::runtime_error("Empty column name"); + std::string columnName = it->get<0>().get(); + + if(column.name().compare(columnName)==0) + { + found = true; + + if(!it->get<1>()) + throw std::runtime_error("Empty column type"); + std::string columnType = it->get<1>().get(); + + if(column.type().compare(columnType)!=0) + { + std::stringstream errorStream; + errorStream << "Column " << column.name() << " type error " + << "server " << columnType << " client " << column.type(); + throw std::runtime_error(errorStream.str()); + } + + if(!it->get<2>()) + throw std::runtime_error("Empty is nullable"); + std::string isNullable = it->get<2>().get(); + + if(column.nullable().compare(isNullable)!=0) + { + std::stringstream errorStream; + errorStream << "Column " << column.name() << " nullable error " + << "server " << isNullable << " client " << column.nullable(); + throw std::runtime_error(errorStream.str()); + } + } + } + + if(!found) + { + std::stringstream errorStream; + errorStream << "Column " << column.name() << " not found on server"; + throw std::runtime_error(errorStream.str()); + } +} + } //namespace diff --git a/src/ProtocolManager.h b/src/ProtocolManager.h index abe99fb3e8022fa1e11d078ece421338ebc5cda3..9b713651f4958b0fb3646479f717a5d3cafd4848 100644 --- a/src/ProtocolManager.h +++ b/src/ProtocolManager.h @@ -67,6 +67,12 @@ protected: virtual ResponseSP prepareMetadata(RequestSP) throw(std::runtime_error); +//------------------------------------------------------------------------------ +// [Protected] Validation related methods +//------------------------------------------------------------------------------ + virtual void validateColumn(const Request::Validation::Column&, + DBManager::InformationList&) throw(std::runtime_error); + //------------------------------------------------------------------------------ // [Protected] Class variables //------------------------------------------------------------------------------ @@ -76,8 +82,8 @@ protected: //Database manger shared pointer DBManager::SP m_dBManager_sp; - //Client is authenticated - bool m_isAuthenticated; + //Client is authorised + bool m_isAuthorised; //Table structure is validated bool m_isValidated; diff --git a/src/Request.pb.cc b/src/Request.pb.cc index 6bed6b78b3ec4eb8ef00d8a3aff599cd0094115f..070cfa712aa20b074839b91428244fad5f37d9fc 100644 --- a/src/Request.pb.cc +++ b/src/Request.pb.cc @@ -32,7 +32,6 @@ const ::google::protobuf::internal::GeneratedMessageReflection* const ::google::protobuf::Descriptor* Request_Validation_Column_descriptor_ = NULL; const ::google::protobuf::internal::GeneratedMessageReflection* Request_Validation_Column_reflection_ = NULL; -const ::google::protobuf::EnumDescriptor* Request_Validation_Column_Type_descriptor_ = NULL; const ::google::protobuf::Descriptor* Request_Metadata_descriptor_ = NULL; const ::google::protobuf::internal::GeneratedMessageReflection* Request_Metadata_reflection_ = NULL; @@ -115,7 +114,6 @@ void protobuf_AssignDesc_Request_2eproto() { ::google::protobuf::DescriptorPool::generated_pool(), ::google::protobuf::MessageFactory::generated_factory(), sizeof(Request_Validation_Column)); - Request_Validation_Column_Type_descriptor_ = Request_Validation_Column_descriptor_->enum_type(0); Request_Metadata_descriptor_ = Request_descriptor_->nested_type(2); static const int Request_Metadata_offsets_[3] = { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Request_Metadata, schema_), @@ -180,7 +178,7 @@ void protobuf_AddDesc_Request_2eproto() { GOOGLE_PROTOBUF_VERIFY_VERSION; ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - "\n\rRequest.proto\022\023MetadataExporter_ns\"\347\005\n" + "\n\rRequest.proto\022\023MetadataExporter_ns\"\306\004\n" "\007Request\022/\n\004type\030\001 \002(\0162!.MetadataExporte" "r_ns.Request.Type\022A\n\rauthorization\030\002 \001(\013" "2*.MetadataExporter_ns.Request.Authoriza" @@ -188,18 +186,14 @@ void protobuf_AddDesc_Request_2eproto() { "ter_ns.Request.Validation\0227\n\010metadata\030\004 " "\001(\0132%.MetadataExporter_ns.Request.Metada" "ta\0323\n\rAuthorization\022\020\n\010username\030\001 \002(\t\022\020\n" - "\010password\030\002 \002(\t\032\305\002\n\nValidation\022\016\n\006schema" + "\010password\030\002 \002(\t\032\244\001\n\nValidation\022\016\n\006schema" "\030\001 \002(\t\022\r\n\005table\030\002 \002(\t\022\?\n\007columns\030\003 \003(\0132." ".MetadataExporter_ns.Request.Validation." - "Column\032\326\001\n\006Column\022\014\n\004name\030\001 \002(\t\022A\n\004type\030" - "\002 \002(\01623.MetadataExporter_ns.Request.Vali" - "dation.Column.Type\022\020\n\010nullable\030\003 \002(\010\"i\n\004" - "Type\022\r\n\tDT_DOUBLE\020\000\022\016\n\nDT_INTEGER\020\001\022\024\n\020D" - "T_UNSIGNED_LONG\020\002\022\020\n\014DT_LONG_LONG\020\003\022\r\n\tD" - "T_STRING\020\004\022\013\n\007DT_DATE\020\005\032<\n\010Metadata\022\016\n\006s" - "chema\030\001 \002(\t\022\r\n\005table\030\002 \002(\t\022\021\n\ttimestamp\030" - "\003 \002(\020\"7\n\004Type\022\021\n\rAUTHORIZATION\020\000\022\016\n\nVALI" - "DATION\020\001\022\014\n\010METADATA\020\002", 782); + "Column\0326\n\006Column\022\014\n\004name\030\001 \002(\t\022\014\n\004type\030\002" + " \002(\t\022\020\n\010nullable\030\003 \002(\t\032<\n\010Metadata\022\016\n\006sc" + "hema\030\001 \002(\t\022\r\n\005table\030\002 \002(\t\022\021\n\ttimestamp\030\003" + " \002(\020\"7\n\004Type\022\021\n\rAUTHORIZATION\020\000\022\016\n\nVALID" + "ATION\020\001\022\014\n\010METADATA\020\002", 621); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "Request.proto", &protobuf_RegisterTypes); Request::default_instance_ = new Request(); @@ -530,35 +524,6 @@ void Request_Authorization::Swap(Request_Authorization* other) { // ------------------------------------------------------------------- -const ::google::protobuf::EnumDescriptor* Request_Validation_Column_Type_descriptor() { - protobuf_AssignDescriptorsOnce(); - return Request_Validation_Column_Type_descriptor_; -} -bool Request_Validation_Column_Type_IsValid(int value) { - switch(value) { - case 0: - case 1: - case 2: - case 3: - case 4: - case 5: - return true; - default: - return false; - } -} - -#ifndef _MSC_VER -const Request_Validation_Column_Type Request_Validation_Column::DT_DOUBLE; -const Request_Validation_Column_Type Request_Validation_Column::DT_INTEGER; -const Request_Validation_Column_Type Request_Validation_Column::DT_UNSIGNED_LONG; -const Request_Validation_Column_Type Request_Validation_Column::DT_LONG_LONG; -const Request_Validation_Column_Type Request_Validation_Column::DT_STRING; -const Request_Validation_Column_Type Request_Validation_Column::DT_DATE; -const Request_Validation_Column_Type Request_Validation_Column::Type_MIN; -const Request_Validation_Column_Type Request_Validation_Column::Type_MAX; -const int Request_Validation_Column::Type_ARRAYSIZE; -#endif // _MSC_VER #ifndef _MSC_VER const int Request_Validation_Column::kNameFieldNumber; const int Request_Validation_Column::kTypeFieldNumber; @@ -582,8 +547,8 @@ Request_Validation_Column::Request_Validation_Column(const Request_Validation_Co void Request_Validation_Column::SharedCtor() { _cached_size_ = 0; name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - type_ = 0; - nullable_ = false; + type_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + nullable_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); ::memset(_has_bits_, 0, sizeof(_has_bits_)); } @@ -595,6 +560,12 @@ void Request_Validation_Column::SharedDtor() { if (name_ != &::google::protobuf::internal::kEmptyString) { delete name_; } + if (type_ != &::google::protobuf::internal::kEmptyString) { + delete type_; + } + if (nullable_ != &::google::protobuf::internal::kEmptyString) { + delete nullable_; + } if (this != default_instance_) { } } @@ -627,8 +598,16 @@ void Request_Validation_Column::Clear() { name_->clear(); } } - type_ = 0; - nullable_ = false; + if (has_type()) { + if (type_ != &::google::protobuf::internal::kEmptyString) { + type_->clear(); + } + } + if (has_nullable()) { + if (nullable_ != &::google::protobuf::internal::kEmptyString) { + nullable_->clear(); + } + } } ::memset(_has_bits_, 0, sizeof(_has_bits_)); mutable_unknown_fields()->Clear(); @@ -652,40 +631,37 @@ bool Request_Validation_Column::MergePartialFromCodedStream( } else { goto handle_uninterpreted; } - if (input->ExpectTag(16)) goto parse_type; + if (input->ExpectTag(18)) goto parse_type; break; } - // required .MetadataExporter_ns.Request.Validation.Column.Type type = 2; + // required string type = 2; case 2: { if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { parse_type: - int value; - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>( - input, &value))); - if (::MetadataExporter_ns::Request_Validation_Column_Type_IsValid(value)) { - set_type(static_cast< ::MetadataExporter_ns::Request_Validation_Column_Type >(value)); - } else { - mutable_unknown_fields()->AddVarint(2, value); - } + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_type())); + ::google::protobuf::internal::WireFormat::VerifyUTF8String( + this->type().data(), this->type().length(), + ::google::protobuf::internal::WireFormat::PARSE); } else { goto handle_uninterpreted; } - if (input->ExpectTag(24)) goto parse_nullable; + if (input->ExpectTag(26)) goto parse_nullable; break; } - // required bool nullable = 3; + // required string nullable = 3; case 3: { if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == - ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { parse_nullable: - DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< - bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>( - input, &nullable_))); - set_has_nullable(); + DO_(::google::protobuf::internal::WireFormatLite::ReadString( + input, this->mutable_nullable())); + ::google::protobuf::internal::WireFormat::VerifyUTF8String( + this->nullable().data(), this->nullable().length(), + ::google::protobuf::internal::WireFormat::PARSE); } else { goto handle_uninterpreted; } @@ -720,15 +696,22 @@ void Request_Validation_Column::SerializeWithCachedSizes( 1, this->name(), output); } - // required .MetadataExporter_ns.Request.Validation.Column.Type type = 2; + // required string type = 2; if (has_type()) { - ::google::protobuf::internal::WireFormatLite::WriteEnum( + ::google::protobuf::internal::WireFormat::VerifyUTF8String( + this->type().data(), this->type().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormatLite::WriteString( 2, this->type(), output); } - // required bool nullable = 3; + // required string nullable = 3; if (has_nullable()) { - ::google::protobuf::internal::WireFormatLite::WriteBool(3, this->nullable(), output); + ::google::protobuf::internal::WireFormat::VerifyUTF8String( + this->nullable().data(), this->nullable().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE); + ::google::protobuf::internal::WireFormatLite::WriteString( + 3, this->nullable(), output); } if (!unknown_fields().empty()) { @@ -749,15 +732,24 @@ void Request_Validation_Column::SerializeWithCachedSizes( 1, this->name(), target); } - // required .MetadataExporter_ns.Request.Validation.Column.Type type = 2; + // required string type = 2; if (has_type()) { - target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray( - 2, this->type(), target); + ::google::protobuf::internal::WireFormat::VerifyUTF8String( + this->type().data(), this->type().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 2, this->type(), target); } - // required bool nullable = 3; + // required string nullable = 3; if (has_nullable()) { - target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(3, this->nullable(), target); + ::google::protobuf::internal::WireFormat::VerifyUTF8String( + this->nullable().data(), this->nullable().length(), + ::google::protobuf::internal::WireFormat::SERIALIZE); + target = + ::google::protobuf::internal::WireFormatLite::WriteStringToArray( + 3, this->nullable(), target); } if (!unknown_fields().empty()) { @@ -778,15 +770,18 @@ int Request_Validation_Column::ByteSize() const { this->name()); } - // required .MetadataExporter_ns.Request.Validation.Column.Type type = 2; + // required string type = 2; if (has_type()) { total_size += 1 + - ::google::protobuf::internal::WireFormatLite::EnumSize(this->type()); + ::google::protobuf::internal::WireFormatLite::StringSize( + this->type()); } - // required bool nullable = 3; + // required string nullable = 3; if (has_nullable()) { - total_size += 1 + 1; + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::StringSize( + this->nullable()); } } diff --git a/src/Request.pb.h b/src/Request.pb.h index 0df5fd311f6eec19646b2a8af605c06821c3bd74..990c15ba51c3ba0a80cc8cf45afa5b03c57a674a 100644 --- a/src/Request.pb.h +++ b/src/Request.pb.h @@ -40,29 +40,6 @@ class Request_Validation; class Request_Validation_Column; class Request_Metadata; -enum Request_Validation_Column_Type { - Request_Validation_Column_Type_DT_DOUBLE = 0, - Request_Validation_Column_Type_DT_INTEGER = 1, - Request_Validation_Column_Type_DT_UNSIGNED_LONG = 2, - Request_Validation_Column_Type_DT_LONG_LONG = 3, - Request_Validation_Column_Type_DT_STRING = 4, - Request_Validation_Column_Type_DT_DATE = 5 -}; -bool Request_Validation_Column_Type_IsValid(int value); -const Request_Validation_Column_Type Request_Validation_Column_Type_Type_MIN = Request_Validation_Column_Type_DT_DOUBLE; -const Request_Validation_Column_Type Request_Validation_Column_Type_Type_MAX = Request_Validation_Column_Type_DT_DATE; -const int Request_Validation_Column_Type_Type_ARRAYSIZE = Request_Validation_Column_Type_Type_MAX + 1; - -const ::google::protobuf::EnumDescriptor* Request_Validation_Column_Type_descriptor(); -inline const ::std::string& Request_Validation_Column_Type_Name(Request_Validation_Column_Type value) { - return ::google::protobuf::internal::NameOfEnum( - Request_Validation_Column_Type_descriptor(), value); -} -inline bool Request_Validation_Column_Type_Parse( - const ::std::string& name, Request_Validation_Column_Type* value) { - return ::google::protobuf::internal::ParseNamedEnum<Request_Validation_Column_Type>( - Request_Validation_Column_Type_descriptor(), name, value); -} enum Request_Type { Request_Type_AUTHORIZATION = 0, Request_Type_VALIDATION = 1, @@ -239,34 +216,6 @@ class Request_Validation_Column : public ::google::protobuf::Message { // nested types ---------------------------------------------------- - typedef Request_Validation_Column_Type Type; - static const Type DT_DOUBLE = Request_Validation_Column_Type_DT_DOUBLE; - static const Type DT_INTEGER = Request_Validation_Column_Type_DT_INTEGER; - static const Type DT_UNSIGNED_LONG = Request_Validation_Column_Type_DT_UNSIGNED_LONG; - static const Type DT_LONG_LONG = Request_Validation_Column_Type_DT_LONG_LONG; - static const Type DT_STRING = Request_Validation_Column_Type_DT_STRING; - static const Type DT_DATE = Request_Validation_Column_Type_DT_DATE; - static inline bool Type_IsValid(int value) { - return Request_Validation_Column_Type_IsValid(value); - } - static const Type Type_MIN = - Request_Validation_Column_Type_Type_MIN; - static const Type Type_MAX = - Request_Validation_Column_Type_Type_MAX; - static const int Type_ARRAYSIZE = - Request_Validation_Column_Type_Type_ARRAYSIZE; - static inline const ::google::protobuf::EnumDescriptor* - Type_descriptor() { - return Request_Validation_Column_Type_descriptor(); - } - static inline const ::std::string& Type_Name(Type value) { - return Request_Validation_Column_Type_Name(value); - } - static inline bool Type_Parse(const ::std::string& name, - Type* value) { - return Request_Validation_Column_Type_Parse(name, value); - } - // accessors ------------------------------------------------------- // required string name = 1; @@ -281,19 +230,29 @@ class Request_Validation_Column : public ::google::protobuf::Message { inline ::std::string* release_name(); inline void set_allocated_name(::std::string* name); - // required .MetadataExporter_ns.Request.Validation.Column.Type type = 2; + // required string type = 2; inline bool has_type() const; inline void clear_type(); static const int kTypeFieldNumber = 2; - inline ::MetadataExporter_ns::Request_Validation_Column_Type type() const; - inline void set_type(::MetadataExporter_ns::Request_Validation_Column_Type value); - - // required bool nullable = 3; + inline const ::std::string& type() const; + inline void set_type(const ::std::string& value); + inline void set_type(const char* value); + inline void set_type(const char* value, size_t size); + inline ::std::string* mutable_type(); + inline ::std::string* release_type(); + inline void set_allocated_type(::std::string* type); + + // required string nullable = 3; inline bool has_nullable() const; inline void clear_nullable(); static const int kNullableFieldNumber = 3; - inline bool nullable() const; - inline void set_nullable(bool value); + inline const ::std::string& nullable() const; + inline void set_nullable(const ::std::string& value); + inline void set_nullable(const char* value); + inline void set_nullable(const char* value, size_t size); + inline ::std::string* mutable_nullable(); + inline ::std::string* release_nullable(); + inline void set_allocated_nullable(::std::string* nullable); // @@protoc_insertion_point(class_scope:MetadataExporter_ns.Request.Validation.Column) private: @@ -307,8 +266,8 @@ class Request_Validation_Column : public ::google::protobuf::Message { ::google::protobuf::UnknownFieldSet _unknown_fields_; ::std::string* name_; - int type_; - bool nullable_; + ::std::string* type_; + ::std::string* nullable_; mutable int _cached_size_; ::google::protobuf::uint32 _has_bits_[(3 + 31) / 32]; @@ -917,7 +876,7 @@ inline void Request_Validation_Column::set_allocated_name(::std::string* name) { } } -// required .MetadataExporter_ns.Request.Validation.Column.Type type = 2; +// required string type = 2; inline bool Request_Validation_Column::has_type() const { return (_has_bits_[0] & 0x00000002u) != 0; } @@ -928,19 +887,66 @@ inline void Request_Validation_Column::clear_has_type() { _has_bits_[0] &= ~0x00000002u; } inline void Request_Validation_Column::clear_type() { - type_ = 0; + if (type_ != &::google::protobuf::internal::kEmptyString) { + type_->clear(); + } clear_has_type(); } -inline ::MetadataExporter_ns::Request_Validation_Column_Type Request_Validation_Column::type() const { - return static_cast< ::MetadataExporter_ns::Request_Validation_Column_Type >(type_); +inline const ::std::string& Request_Validation_Column::type() const { + return *type_; } -inline void Request_Validation_Column::set_type(::MetadataExporter_ns::Request_Validation_Column_Type value) { - assert(::MetadataExporter_ns::Request_Validation_Column_Type_IsValid(value)); +inline void Request_Validation_Column::set_type(const ::std::string& value) { set_has_type(); - type_ = value; + if (type_ == &::google::protobuf::internal::kEmptyString) { + type_ = new ::std::string; + } + type_->assign(value); +} +inline void Request_Validation_Column::set_type(const char* value) { + set_has_type(); + if (type_ == &::google::protobuf::internal::kEmptyString) { + type_ = new ::std::string; + } + type_->assign(value); +} +inline void Request_Validation_Column::set_type(const char* value, size_t size) { + set_has_type(); + if (type_ == &::google::protobuf::internal::kEmptyString) { + type_ = new ::std::string; + } + type_->assign(reinterpret_cast<const char*>(value), size); +} +inline ::std::string* Request_Validation_Column::mutable_type() { + set_has_type(); + if (type_ == &::google::protobuf::internal::kEmptyString) { + type_ = new ::std::string; + } + return type_; +} +inline ::std::string* Request_Validation_Column::release_type() { + clear_has_type(); + if (type_ == &::google::protobuf::internal::kEmptyString) { + return NULL; + } else { + ::std::string* temp = type_; + type_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + return temp; + } +} +inline void Request_Validation_Column::set_allocated_type(::std::string* type) { + if (type_ != &::google::protobuf::internal::kEmptyString) { + delete type_; + } + if (type) { + set_has_type(); + type_ = type; + } else { + clear_has_type(); + type_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + } } -// required bool nullable = 3; +// required string nullable = 3; inline bool Request_Validation_Column::has_nullable() const { return (_has_bits_[0] & 0x00000004u) != 0; } @@ -951,15 +957,63 @@ inline void Request_Validation_Column::clear_has_nullable() { _has_bits_[0] &= ~0x00000004u; } inline void Request_Validation_Column::clear_nullable() { - nullable_ = false; + if (nullable_ != &::google::protobuf::internal::kEmptyString) { + nullable_->clear(); + } clear_has_nullable(); } -inline bool Request_Validation_Column::nullable() const { - return nullable_; +inline const ::std::string& Request_Validation_Column::nullable() const { + return *nullable_; +} +inline void Request_Validation_Column::set_nullable(const ::std::string& value) { + set_has_nullable(); + if (nullable_ == &::google::protobuf::internal::kEmptyString) { + nullable_ = new ::std::string; + } + nullable_->assign(value); +} +inline void Request_Validation_Column::set_nullable(const char* value) { + set_has_nullable(); + if (nullable_ == &::google::protobuf::internal::kEmptyString) { + nullable_ = new ::std::string; + } + nullable_->assign(value); } -inline void Request_Validation_Column::set_nullable(bool value) { +inline void Request_Validation_Column::set_nullable(const char* value, size_t size) { set_has_nullable(); - nullable_ = value; + if (nullable_ == &::google::protobuf::internal::kEmptyString) { + nullable_ = new ::std::string; + } + nullable_->assign(reinterpret_cast<const char*>(value), size); +} +inline ::std::string* Request_Validation_Column::mutable_nullable() { + set_has_nullable(); + if (nullable_ == &::google::protobuf::internal::kEmptyString) { + nullable_ = new ::std::string; + } + return nullable_; +} +inline ::std::string* Request_Validation_Column::release_nullable() { + clear_has_nullable(); + if (nullable_ == &::google::protobuf::internal::kEmptyString) { + return NULL; + } else { + ::std::string* temp = nullable_; + nullable_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + return temp; + } +} +inline void Request_Validation_Column::set_allocated_nullable(::std::string* nullable) { + if (nullable_ != &::google::protobuf::internal::kEmptyString) { + delete nullable_; + } + if (nullable) { + set_has_nullable(); + nullable_ = nullable; + } else { + clear_has_nullable(); + nullable_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); + } } // ------------------------------------------------------------------- @@ -1447,10 +1501,6 @@ inline void Request::set_allocated_metadata(::MetadataExporter_ns::Request_Metad namespace google { namespace protobuf { -template <> -inline const EnumDescriptor* GetEnumDescriptor< ::MetadataExporter_ns::Request_Validation_Column_Type>() { - return ::MetadataExporter_ns::Request_Validation_Column_Type_descriptor(); -} template <> inline const EnumDescriptor* GetEnumDescriptor< ::MetadataExporter_ns::Request_Type>() { return ::MetadataExporter_ns::Request_Type_descriptor();