From 1589fdbd4c01c5ef41d31f0a6e6942d4c2b97631 Mon Sep 17 00:00:00 2001 From: Marco De Marco Date: Tue, 14 Jan 2014 12:14:46 +0100 Subject: [PATCH] Protocol class modified --- proto/Response.proto | 2 +- src/FileWrapper.cpp | 8 +++--- src/FileWrapper.h | 6 ++--- src/ProtocolManager.cpp | 2 +- src/ProtocolManager.h | 2 +- src/Response.pb.cc | 54 ++++++++++++++++++++--------------------- src/Response.pb.h | 42 ++++++++++++++++---------------- 7 files changed, 58 insertions(+), 58 deletions(-) diff --git a/proto/Response.proto b/proto/Response.proto index 216a990..f65204c 100644 --- a/proto/Response.proto +++ b/proto/Response.proto @@ -19,5 +19,5 @@ message Response optional string file_path = 3; optional int32 file_version = 4; optional string file_name = 5; - optional uint64 size = 6; + optional uint64 file_size = 6; } diff --git a/src/FileWrapper.cpp b/src/FileWrapper.cpp index e2b49f8..62a5642 100644 --- a/src/FileWrapper.cpp +++ b/src/FileWrapper.cpp @@ -61,17 +61,17 @@ bool FileWrapper::isBad() //============================================================================== bool FileWrapper::isCompleted() { - return m_inputFileStream.tellg() >= m_inputFileSize; + return (boost::uint64_t)m_inputFileStream.tellg() >= m_inputFileSize; } //============================================================================== // FileWrapper::read() //============================================================================== -void FileWrapper::read(std::vector& writeBuff) throw(std::runtime_error) +void FileWrapper::read(std::vector& writeBuff) { - int leftToRead = m_inputFileSize - m_inputFileStream.tellg(); + boost::uint64_t leftToRead = m_inputFileSize - m_inputFileStream.tellg(); - int bufferSize = 0; + boost::uint64_t bufferSize = 0; if(leftToRead < BUFFER_SIZE) bufferSize = leftToRead; diff --git a/src/FileWrapper.h b/src/FileWrapper.h index 46c711d..4c79cfc 100644 --- a/src/FileWrapper.h +++ b/src/FileWrapper.h @@ -49,20 +49,20 @@ public: virtual bool isCompleted(); - virtual void read(std::vector&) throw(std::runtime_error); + virtual void read(std::vector&); protected: //------------------------------------------------------------------------------ // [Protected] Class variables //------------------------------------------------------------------------------ //Input file size - int m_inputFileSize; + boost::uint64_t m_inputFileSize; //Input file stream std::ifstream m_inputFileStream; //Read buffer size - const int BUFFER_SIZE = 1024; + const boost::uint64_t BUFFER_SIZE = 40960; }; } //End of namespace diff --git a/src/ProtocolManager.cpp b/src/ProtocolManager.cpp index 1254e2e..b1f7e0e 100644 --- a/src/ProtocolManager.cpp +++ b/src/ProtocolManager.cpp @@ -108,7 +108,7 @@ ResponseSP ProtocolManager::prepareResponse(RequestSP request_sp) response_sp->set_file_path(filePath); response_sp->set_file_version(fileVersion); response_sp->set_file_name(fileName); - response_sp->set_size(fileSize); + response_sp->set_file_size(fileSize); } else { diff --git a/src/ProtocolManager.h b/src/ProtocolManager.h index 6f8d00d..e8da5e6 100644 --- a/src/ProtocolManager.h +++ b/src/ProtocolManager.h @@ -71,7 +71,7 @@ public: protected: //------------------------------------------------------------------------------ -// [Protected] +// [Protected] File path method //------------------------------------------------------------------------------ virtual boost::filesystem::path composePath(std::string, std::string, int, std::string); diff --git a/src/Response.pb.cc b/src/Response.pb.cc index e1f94d6..40a6cf0 100644 --- a/src/Response.pb.cc +++ b/src/Response.pb.cc @@ -41,7 +41,7 @@ void protobuf_AssignDesc_Response_2eproto() { GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Response, file_path_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Response, file_version_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Response, file_name_), - GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Response, size_), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Response, file_size_), }; Response_reflection_ = new ::google::protobuf::internal::GeneratedMessageReflection( @@ -85,15 +85,15 @@ void protobuf_AddDesc_Response_2eproto() { GOOGLE_PROTOBUF_VERIFY_VERSION; ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( - "\n\016Response.proto\022\017DataExporter_ns\"\265\002\n\010Re" + "\n\016Response.proto\022\017DataExporter_ns\"\272\002\n\010Re" "sponse\022.\n\005state\030\001 \002(\0162\037.DataExporter_ns." "Response.State\022\016\n\006status\030\002 \002(\t\022\021\n\tfile_p" "ath\030\003 \001(\t\022\024\n\014file_version\030\004 \001(\005\022\021\n\tfile_" - "name\030\005 \001(\t\022\014\n\004size\030\006 \001(\004\"\236\001\n\005State\022\024\n\020RE" - "QUEST_ACCEPTED\020\000\022\017\n\013ACCESS_DENY\020\001\022\026\n\022TAB" - "LE_NOT_EXPORTED\020\002\022\026\n\022METADATA_NOT_FOUND\020" - "\003\022\027\n\023FILE_NOT_DOWNLOADED\020\004\022\022\n\016FILE_NOT_F" - "OUND\020\005\022\021\n\rGENERIC_ERROR\020\006", 345); + "name\030\005 \001(\t\022\021\n\tfile_size\030\006 \001(\004\"\236\001\n\005State\022" + "\024\n\020REQUEST_ACCEPTED\020\000\022\017\n\013ACCESS_DENY\020\001\022\026" + "\n\022TABLE_NOT_EXPORTED\020\002\022\026\n\022METADATA_NOT_F" + "OUND\020\003\022\027\n\023FILE_NOT_DOWNLOADED\020\004\022\022\n\016FILE_" + "NOT_FOUND\020\005\022\021\n\rGENERIC_ERROR\020\006", 350); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "Response.proto", &protobuf_RegisterTypes); Response::default_instance_ = new Response(); @@ -147,7 +147,7 @@ const int Response::kStatusFieldNumber; const int Response::kFilePathFieldNumber; const int Response::kFileVersionFieldNumber; const int Response::kFileNameFieldNumber; -const int Response::kSizeFieldNumber; +const int Response::kFileSizeFieldNumber; #endif // !_MSC_VER Response::Response() @@ -171,7 +171,7 @@ void Response::SharedCtor() { file_path_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); file_version_ = 0; file_name_ = const_cast< ::std::string*>(&::google::protobuf::internal::kEmptyString); - size_ = GOOGLE_ULONGLONG(0); + file_size_ = GOOGLE_ULONGLONG(0); ::memset(_has_bits_, 0, sizeof(_has_bits_)); } @@ -233,7 +233,7 @@ void Response::Clear() { file_name_->clear(); } } - size_ = GOOGLE_ULONGLONG(0); + file_size_ = GOOGLE_ULONGLONG(0); } ::memset(_has_bits_, 0, sizeof(_has_bits_)); mutable_unknown_fields()->Clear(); @@ -328,19 +328,19 @@ bool Response::MergePartialFromCodedStream( } else { goto handle_uninterpreted; } - if (input->ExpectTag(48)) goto parse_size; + if (input->ExpectTag(48)) goto parse_file_size; break; } - // optional uint64 size = 6; + // optional uint64 file_size = 6; case 6: { if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { - parse_size: + parse_file_size: DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>( - input, &size_))); - set_has_size(); + input, &file_size_))); + set_has_file_size(); } else { goto handle_uninterpreted; } @@ -404,9 +404,9 @@ void Response::SerializeWithCachedSizes( 5, this->file_name(), output); } - // optional uint64 size = 6; - if (has_size()) { - ::google::protobuf::internal::WireFormatLite::WriteUInt64(6, this->size(), output); + // optional uint64 file_size = 6; + if (has_file_size()) { + ::google::protobuf::internal::WireFormatLite::WriteUInt64(6, this->file_size(), output); } if (!unknown_fields().empty()) { @@ -458,9 +458,9 @@ void Response::SerializeWithCachedSizes( 5, this->file_name(), target); } - // optional uint64 size = 6; - if (has_size()) { - target = ::google::protobuf::internal::WireFormatLite::WriteUInt64ToArray(6, this->size(), target); + // optional uint64 file_size = 6; + if (has_file_size()) { + target = ::google::protobuf::internal::WireFormatLite::WriteUInt64ToArray(6, this->file_size(), target); } if (!unknown_fields().empty()) { @@ -508,11 +508,11 @@ int Response::ByteSize() const { this->file_name()); } - // optional uint64 size = 6; - if (has_size()) { + // optional uint64 file_size = 6; + if (has_file_size()) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::UInt64Size( - this->size()); + this->file_size()); } } @@ -557,8 +557,8 @@ void Response::MergeFrom(const Response& from) { if (from.has_file_name()) { set_file_name(from.file_name()); } - if (from.has_size()) { - set_size(from.size()); + if (from.has_file_size()) { + set_file_size(from.file_size()); } } mutable_unknown_fields()->MergeFrom(from.unknown_fields()); @@ -589,7 +589,7 @@ void Response::Swap(Response* other) { std::swap(file_path_, other->file_path_); std::swap(file_version_, other->file_version_); std::swap(file_name_, other->file_name_); - std::swap(size_, other->size_); + std::swap(file_size_, other->file_size_); std::swap(_has_bits_[0], other->_has_bits_[0]); _unknown_fields_.Swap(&other->_unknown_fields_); std::swap(_cached_size_, other->_cached_size_); diff --git a/src/Response.pb.h b/src/Response.pb.h index c810e04..945e8a0 100644 --- a/src/Response.pb.h +++ b/src/Response.pb.h @@ -195,12 +195,12 @@ class Response : public ::google::protobuf::Message { inline ::std::string* release_file_name(); inline void set_allocated_file_name(::std::string* file_name); - // optional uint64 size = 6; - inline bool has_size() const; - inline void clear_size(); - static const int kSizeFieldNumber = 6; - inline ::google::protobuf::uint64 size() const; - inline void set_size(::google::protobuf::uint64 value); + // optional uint64 file_size = 6; + inline bool has_file_size() const; + inline void clear_file_size(); + static const int kFileSizeFieldNumber = 6; + inline ::google::protobuf::uint64 file_size() const; + inline void set_file_size(::google::protobuf::uint64 value); // @@protoc_insertion_point(class_scope:DataExporter_ns.Response) private: @@ -214,8 +214,8 @@ class Response : public ::google::protobuf::Message { inline void clear_has_file_version(); inline void set_has_file_name(); inline void clear_has_file_name(); - inline void set_has_size(); - inline void clear_has_size(); + inline void set_has_file_size(); + inline void clear_has_file_size(); ::google::protobuf::UnknownFieldSet _unknown_fields_; @@ -224,7 +224,7 @@ class Response : public ::google::protobuf::Message { ::google::protobuf::int32 file_version_; ::std::string* file_path_; ::std::string* file_name_; - ::google::protobuf::uint64 size_; + ::google::protobuf::uint64 file_size_; mutable int _cached_size_; ::google::protobuf::uint32 _has_bits_[(6 + 31) / 32]; @@ -498,26 +498,26 @@ inline void Response::set_allocated_file_name(::std::string* file_name) { } } -// optional uint64 size = 6; -inline bool Response::has_size() const { +// optional uint64 file_size = 6; +inline bool Response::has_file_size() const { return (_has_bits_[0] & 0x00000020u) != 0; } -inline void Response::set_has_size() { +inline void Response::set_has_file_size() { _has_bits_[0] |= 0x00000020u; } -inline void Response::clear_has_size() { +inline void Response::clear_has_file_size() { _has_bits_[0] &= ~0x00000020u; } -inline void Response::clear_size() { - size_ = GOOGLE_ULONGLONG(0); - clear_has_size(); +inline void Response::clear_file_size() { + file_size_ = GOOGLE_ULONGLONG(0); + clear_has_file_size(); } -inline ::google::protobuf::uint64 Response::size() const { - return size_; +inline ::google::protobuf::uint64 Response::file_size() const { + return file_size_; } -inline void Response::set_size(::google::protobuf::uint64 value) { - set_has_size(); - size_ = value; +inline void Response::set_file_size(::google::protobuf::uint64 value) { + set_has_file_size(); + file_size_ = value; } -- GitLab