[Rprotobuf-commits] r330 - in pkg/inst/examples: . HighFrequencyFinance
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Jul 17 19:46:06 CEST 2010
Author: edd
Date: 2010-07-17 19:46:06 +0200 (Sat, 17 Jul 2010)
New Revision: 330
Added:
pkg/inst/examples/HighFrequencyFinance/
pkg/inst/examples/HighFrequencyFinance/Makefile
pkg/inst/examples/HighFrequencyFinance/README
pkg/inst/examples/HighFrequencyFinance/TradeData.pb.cc
pkg/inst/examples/HighFrequencyFinance/TradeData.pb.h
pkg/inst/examples/HighFrequencyFinance/TradeData.proto
pkg/inst/examples/HighFrequencyFinance/loadInR.r
pkg/inst/examples/HighFrequencyFinance/protoCreate.cpp
pkg/inst/examples/HighFrequencyFinance/protoDump.cpp
pkg/inst/examples/HighFrequencyFinance/protoLoadForR.cpp
pkg/inst/examples/HighFrequencyFinance/trades.pb
Log:
new example and benchmark
Added: pkg/inst/examples/HighFrequencyFinance/Makefile
===================================================================
--- pkg/inst/examples/HighFrequencyFinance/Makefile (rev 0)
+++ pkg/inst/examples/HighFrequencyFinance/Makefile 2010-07-17 17:46:06 UTC (rev 330)
@@ -0,0 +1,22 @@
+
+# Rmath is in /usr/include on my system
+CPPFLAGS= -I/usr/include -I. -Wall -O3
+
+# libRmath.so is in /usr/lib on my system, as are the proto library
+LDLIBS= -L/usr/lib -lprotobuf -lprotoc -lpthread
+
+RCPPINC= $(shell Rscript -e 'Rcpp:::CxxFlags()')
+RCPPLIB= $(shell Rscript -e 'Rcpp:::LdFlags()')
+
+protoCreate: protoCreate.cpp TradeData.pb.cc
+ $(CXX) $(CPPLFLAGS) -o protoCreate protoCreate.cpp TradeData.pb.cc -lRmath $(LDLIBS)
+
+protoDump: protoDump.cpp TradeData.pb.cc
+ $(CXX) $(CPPLFLAGS) -o protoDump protoDump.cpp TradeData.pb.cc $(LDLIBS)
+
+protoLoadForR.so: protoLoadForR.cpp TradeData.pb.cc
+ PKG_CXXFLAGS="$(CPPFLAGS) $(RCPPINC)" PKG_LIBS="$(LDLIBS) $(RCPPLIB)" \
+ R CMD SHLIB protoLoadForR.cpp TradeData.pb.cc
+
+TradeData.pb.cc: TradeData.proto
+ protoc --cpp_out=. TradeData.proto
\ No newline at end of file
Added: pkg/inst/examples/HighFrequencyFinance/README
===================================================================
--- pkg/inst/examples/HighFrequencyFinance/README (rev 0)
+++ pkg/inst/examples/HighFrequencyFinance/README 2010-07-17 17:46:06 UTC (rev 330)
@@ -0,0 +1,8 @@
+
+This is an entirely cooked-up example resembling some of the data you might
+encounter looking at trades on a tick-by-tick basis.
+
+It provides a good example for why ProtoBuffers rocks: they are concise, they
+are fast, they are extensible --- and they can be hooked up to several
+languages with C++, Java and Python supported by Google, and others by
+third-party projects such as this providing R.
Added: pkg/inst/examples/HighFrequencyFinance/TradeData.pb.cc
===================================================================
--- pkg/inst/examples/HighFrequencyFinance/TradeData.pb.cc (rev 0)
+++ pkg/inst/examples/HighFrequencyFinance/TradeData.pb.cc 2010-07-17 17:46:06 UTC (rev 330)
@@ -0,0 +1,653 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+
+#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION
+#include "TradeData.pb.h"
+#include <google/protobuf/stubs/once.h>
+#include <google/protobuf/io/coded_stream.h>
+#include <google/protobuf/wire_format_lite_inl.h>
+#include <google/protobuf/descriptor.h>
+#include <google/protobuf/reflection_ops.h>
+#include <google/protobuf/wire_format.h>
+
+namespace TradeData {
+
+namespace {
+
+const ::google::protobuf::Descriptor* Fill_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ Fill_reflection_ = NULL;
+const ::google::protobuf::Descriptor* Trades_descriptor_ = NULL;
+const ::google::protobuf::internal::GeneratedMessageReflection*
+ Trades_reflection_ = NULL;
+
+} // namespace
+
+
+void protobuf_AssignDesc_TradeData_2eproto() {
+ protobuf_AddDesc_TradeData_2eproto();
+ const ::google::protobuf::FileDescriptor* file =
+ ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
+ "TradeData.proto");
+ GOOGLE_CHECK(file != NULL);
+ Fill_descriptor_ = file->message_type(0);
+ static const int Fill_offsets_[4] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Fill, timestamp_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Fill, symbol_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Fill, price_),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Fill, size_),
+ };
+ Fill_reflection_ =
+ new ::google::protobuf::internal::GeneratedMessageReflection(
+ Fill_descriptor_,
+ Fill::default_instance_,
+ Fill_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Fill, _has_bits_[0]),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Fill, _unknown_fields_),
+ -1,
+ ::google::protobuf::DescriptorPool::generated_pool(),
+ ::google::protobuf::MessageFactory::generated_factory(),
+ sizeof(Fill));
+ Trades_descriptor_ = file->message_type(1);
+ static const int Trades_offsets_[1] = {
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Trades, fill_),
+ };
+ Trades_reflection_ =
+ new ::google::protobuf::internal::GeneratedMessageReflection(
+ Trades_descriptor_,
+ Trades::default_instance_,
+ Trades_offsets_,
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Trades, _has_bits_[0]),
+ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Trades, _unknown_fields_),
+ -1,
+ ::google::protobuf::DescriptorPool::generated_pool(),
+ ::google::protobuf::MessageFactory::generated_factory(),
+ sizeof(Trades));
+}
+
+namespace {
+
+GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);
+inline void protobuf_AssignDescriptorsOnce() {
+ ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,
+ &protobuf_AssignDesc_TradeData_2eproto);
+}
+
+void protobuf_RegisterTypes(const ::std::string&) {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ Fill_descriptor_, &Fill::default_instance());
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(
+ Trades_descriptor_, &Trades::default_instance());
+}
+
+} // namespace
+
+void protobuf_ShutdownFile_TradeData_2eproto() {
+ delete Fill::default_instance_;
+ delete Fill_reflection_;
+ delete Trades::default_instance_;
+ delete Trades_reflection_;
+}
+
+void protobuf_AddDesc_TradeData_2eproto() {
+ static bool already_here = false;
+ if (already_here) return;
+ already_here = true;
+ GOOGLE_PROTOBUF_VERIFY_VERSION;
+
+ ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
+ "\n\017TradeData.proto\022\tTradeData\"F\n\004Fill\022\021\n\t"
+ "timestamp\030\001 \002(\001\022\016\n\006symbol\030\002 \002(\t\022\r\n\005price"
+ "\030\003 \002(\001\022\014\n\004size\030\004 \002(\005\"\'\n\006Trades\022\035\n\004fill\030\001"
+ " \003(\0132\017.TradeData.Fill", 141);
+ ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
+ "TradeData.proto", &protobuf_RegisterTypes);
+ Fill::default_instance_ = new Fill();
+ Trades::default_instance_ = new Trades();
+ Fill::default_instance_->InitAsDefaultInstance();
+ Trades::default_instance_->InitAsDefaultInstance();
+ ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_TradeData_2eproto);
+}
+
+// Force AddDescriptors() to be called at static initialization time.
+struct StaticDescriptorInitializer_TradeData_2eproto {
+ StaticDescriptorInitializer_TradeData_2eproto() {
+ protobuf_AddDesc_TradeData_2eproto();
+ }
+} static_descriptor_initializer_TradeData_2eproto_;
+
+
+// ===================================================================
+
+const ::std::string Fill::_default_symbol_;
+#ifndef _MSC_VER
+const int Fill::kTimestampFieldNumber;
+const int Fill::kSymbolFieldNumber;
+const int Fill::kPriceFieldNumber;
+const int Fill::kSizeFieldNumber;
+#endif // !_MSC_VER
+
+Fill::Fill() {
+ SharedCtor();
+}
+
+void Fill::InitAsDefaultInstance() {
+}
+
+Fill::Fill(const Fill& from) {
+ SharedCtor();
+ MergeFrom(from);
+}
+
+void Fill::SharedCtor() {
+ _cached_size_ = 0;
+ timestamp_ = 0;
+ symbol_ = const_cast< ::std::string*>(&_default_symbol_);
+ price_ = 0;
+ size_ = 0;
+ ::memset(_has_bits_, 0, sizeof(_has_bits_));
+}
+
+Fill::~Fill() {
+ SharedDtor();
+}
+
+void Fill::SharedDtor() {
+ if (symbol_ != &_default_symbol_) {
+ delete symbol_;
+ }
+ if (this != default_instance_) {
+ }
+}
+
+const ::google::protobuf::Descriptor* Fill::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return Fill_descriptor_;
+}
+
+const Fill& Fill::default_instance() {
+ if (default_instance_ == NULL) protobuf_AddDesc_TradeData_2eproto(); return *default_instance_;
+}
+
+Fill* Fill::default_instance_ = NULL;
+
+Fill* Fill::New() const {
+ return new Fill;
+}
+
+void Fill::Clear() {
+ if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ timestamp_ = 0;
+ if (_has_bit(1)) {
+ if (symbol_ != &_default_symbol_) {
+ symbol_->clear();
+ }
+ }
+ price_ = 0;
+ size_ = 0;
+ }
+ ::memset(_has_bits_, 0, sizeof(_has_bits_));
+ mutable_unknown_fields()->Clear();
+}
+
+bool Fill::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 double timestamp = 1;
+ case 1: {
+ if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) !=
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED64) {
+ goto handle_uninterpreted;
+ }
+ DO_(::google::protobuf::internal::WireFormatLite::ReadDouble(
+ input, ×tamp_));
+ _set_bit(0);
+ if (input->ExpectTag(18)) goto parse_symbol;
+ break;
+ }
+
+ // required string symbol = 2;
+ case 2: {
+ if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) !=
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
+ goto handle_uninterpreted;
+ }
+ parse_symbol:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+ input, this->mutable_symbol()));
+ ::google::protobuf::internal::WireFormat::VerifyUTF8String(
+ this->symbol().data(), this->symbol().length(),
+ ::google::protobuf::internal::WireFormat::PARSE);
+ if (input->ExpectTag(25)) goto parse_price;
+ break;
+ }
+
+ // required double price = 3;
+ case 3: {
+ if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) !=
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_FIXED64) {
+ goto handle_uninterpreted;
+ }
+ parse_price:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadDouble(
+ input, &price_));
+ _set_bit(2);
+ if (input->ExpectTag(32)) goto parse_size;
+ break;
+ }
+
+ // required int32 size = 4;
+ case 4: {
+ if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) !=
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
+ goto handle_uninterpreted;
+ }
+ parse_size:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadInt32(
+ input, &size_));
+ _set_bit(3);
+ 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 Fill::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ ::google::protobuf::uint8* raw_buffer = output->GetDirectBufferForNBytesAndAdvance(_cached_size_);
+ if (raw_buffer != NULL) {
+ Fill::SerializeWithCachedSizesToArray(raw_buffer);
+ return;
+ }
+
+ // required double timestamp = 1;
+ if (_has_bit(0)) {
+ ::google::protobuf::internal::WireFormatLite::WriteDouble(1, this->timestamp(), output);
+ }
+
+ // required string symbol = 2;
+ if (_has_bit(1)) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8String(
+ this->symbol().data(), this->symbol().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE);
+ ::google::protobuf::internal::WireFormatLite::WriteString(
+ 2, this->symbol(), output);
+ }
+
+ // required double price = 3;
+ if (_has_bit(2)) {
+ ::google::protobuf::internal::WireFormatLite::WriteDouble(3, this->price(), output);
+ }
+
+ // required int32 size = 4;
+ if (_has_bit(3)) {
+ ::google::protobuf::internal::WireFormatLite::WriteInt32(4, this->size(), output);
+ }
+
+ if (!unknown_fields().empty()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+}
+
+::google::protobuf::uint8* Fill::SerializeWithCachedSizesToArray(
+ ::google::protobuf::uint8* target) const {
+ // required double timestamp = 1;
+ if (_has_bit(0)) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteDoubleToArray(1, this->timestamp(), target);
+ }
+
+ // required string symbol = 2;
+ if (_has_bit(1)) {
+ ::google::protobuf::internal::WireFormat::VerifyUTF8String(
+ this->symbol().data(), this->symbol().length(),
+ ::google::protobuf::internal::WireFormat::SERIALIZE);
+ target =
+ ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+ 2, this->symbol(), target);
+ }
+
+ // required double price = 3;
+ if (_has_bit(2)) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteDoubleToArray(3, this->price(), target);
+ }
+
+ // required int32 size = 4;
+ if (_has_bit(3)) {
+ target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(4, this->size(), target);
+ }
+
+ if (!unknown_fields().empty()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ return target;
+}
+
+int Fill::ByteSize() const {
+ int total_size = 0;
+
+ if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ // required double timestamp = 1;
+ if (has_timestamp()) {
+ total_size += 1 + 8;
+ }
+
+ // required string symbol = 2;
+ if (has_symbol()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::StringSize(
+ this->symbol());
+ }
+
+ // required double price = 3;
+ if (has_price()) {
+ total_size += 1 + 8;
+ }
+
+ // required int32 size = 4;
+ if (has_size()) {
+ total_size += 1 +
+ ::google::protobuf::internal::WireFormatLite::Int32Size(
+ this->size());
+ }
+
+ }
+ if (!unknown_fields().empty()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ _cached_size_ = total_size;
+ return total_size;
+}
+
+void Fill::MergeFrom(const ::google::protobuf::Message& from) {
+ GOOGLE_CHECK_NE(&from, this);
+ const Fill* source =
+ ::google::protobuf::internal::dynamic_cast_if_available<const Fill*>(
+ &from);
+ if (source == NULL) {
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ MergeFrom(*source);
+ }
+}
+
+void Fill::MergeFrom(const Fill& from) {
+ GOOGLE_CHECK_NE(&from, this);
+ if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
+ if (from._has_bit(0)) {
+ set_timestamp(from.timestamp());
+ }
+ if (from._has_bit(1)) {
+ set_symbol(from.symbol());
+ }
+ if (from._has_bit(2)) {
+ set_price(from.price());
+ }
+ if (from._has_bit(3)) {
+ set_size(from.size());
+ }
+ }
+ mutable_unknown_fields()->MergeFrom(from.unknown_fields());
+}
+
+void Fill::CopyFrom(const ::google::protobuf::Message& from) {
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void Fill::CopyFrom(const Fill& from) {
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+bool Fill::IsInitialized() const {
+ if ((_has_bits_[0] & 0x0000000f) != 0x0000000f) return false;
+
+ return true;
+}
+
+void Fill::Swap(Fill* other) {
+ if (other != this) {
+ std::swap(timestamp_, other->timestamp_);
+ std::swap(symbol_, other->symbol_);
+ std::swap(price_, other->price_);
+ std::swap(size_, other->size_);
+ 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 Fill::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = Fill_descriptor_;
+ metadata.reflection = Fill_reflection_;
+ return metadata;
+}
+
+
+// ===================================================================
+
+#ifndef _MSC_VER
+const int Trades::kFillFieldNumber;
+#endif // !_MSC_VER
+
+Trades::Trades() {
+ SharedCtor();
+}
+
+void Trades::InitAsDefaultInstance() {
+}
+
+Trades::Trades(const Trades& from) {
+ SharedCtor();
+ MergeFrom(from);
+}
+
+void Trades::SharedCtor() {
+ _cached_size_ = 0;
+ ::memset(_has_bits_, 0, sizeof(_has_bits_));
+}
+
+Trades::~Trades() {
+ SharedDtor();
+}
+
+void Trades::SharedDtor() {
+ if (this != default_instance_) {
+ }
+}
+
+const ::google::protobuf::Descriptor* Trades::descriptor() {
+ protobuf_AssignDescriptorsOnce();
+ return Trades_descriptor_;
+}
+
+const Trades& Trades::default_instance() {
+ if (default_instance_ == NULL) protobuf_AddDesc_TradeData_2eproto(); return *default_instance_;
+}
+
+Trades* Trades::default_instance_ = NULL;
+
+Trades* Trades::New() const {
+ return new Trades;
+}
+
+void Trades::Clear() {
+ fill_.Clear();
+ ::memset(_has_bits_, 0, sizeof(_has_bits_));
+ mutable_unknown_fields()->Clear();
+}
+
+bool Trades::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)) {
+ // repeated .TradeData.Fill fill = 1;
+ case 1: {
+ if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) !=
+ ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
+ goto handle_uninterpreted;
+ }
+ parse_fill:
+ DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(
+ input, add_fill()));
+ if (input->ExpectTag(10)) goto parse_fill;
+ 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 Trades::SerializeWithCachedSizes(
+ ::google::protobuf::io::CodedOutputStream* output) const {
+ ::google::protobuf::uint8* raw_buffer = output->GetDirectBufferForNBytesAndAdvance(_cached_size_);
+ if (raw_buffer != NULL) {
+ Trades::SerializeWithCachedSizesToArray(raw_buffer);
+ return;
+ }
+
+ // repeated .TradeData.Fill fill = 1;
+ for (int i = 0; i < this->fill_size(); i++) {
+ ::google::protobuf::internal::WireFormatLite::WriteMessageNoVirtual(
+ 1, this->fill(i), output);
+ }
+
+ if (!unknown_fields().empty()) {
+ ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+ unknown_fields(), output);
+ }
+}
+
+::google::protobuf::uint8* Trades::SerializeWithCachedSizesToArray(
+ ::google::protobuf::uint8* target) const {
+ // repeated .TradeData.Fill fill = 1;
+ for (int i = 0; i < this->fill_size(); i++) {
+ target = ::google::protobuf::internal::WireFormatLite::
+ WriteMessageNoVirtualToArray(
+ 1, this->fill(i), target);
+ }
+
+ if (!unknown_fields().empty()) {
+ target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+ unknown_fields(), target);
+ }
+ return target;
+}
+
+int Trades::ByteSize() const {
+ int total_size = 0;
+
+ // repeated .TradeData.Fill fill = 1;
+ total_size += 1 * this->fill_size();
+ for (int i = 0; i < this->fill_size(); i++) {
+ total_size +=
+ ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
+ this->fill(i));
+ }
+
+ if (!unknown_fields().empty()) {
+ total_size +=
+ ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+ unknown_fields());
+ }
+ _cached_size_ = total_size;
+ return total_size;
+}
+
+void Trades::MergeFrom(const ::google::protobuf::Message& from) {
+ GOOGLE_CHECK_NE(&from, this);
+ const Trades* source =
+ ::google::protobuf::internal::dynamic_cast_if_available<const Trades*>(
+ &from);
+ if (source == NULL) {
+ ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+ } else {
+ MergeFrom(*source);
+ }
+}
+
+void Trades::MergeFrom(const Trades& from) {
+ GOOGLE_CHECK_NE(&from, this);
+ fill_.MergeFrom(from.fill_);
+ mutable_unknown_fields()->MergeFrom(from.unknown_fields());
+}
+
+void Trades::CopyFrom(const ::google::protobuf::Message& from) {
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+void Trades::CopyFrom(const Trades& from) {
+ if (&from == this) return;
+ Clear();
+ MergeFrom(from);
+}
+
+bool Trades::IsInitialized() const {
+
+ for (int i = 0; i < fill_size(); i++) {
+ if (!this->fill(i).IsInitialized()) return false;
+ }
+ return true;
+}
+
+void Trades::Swap(Trades* other) {
+ if (other != this) {
+ fill_.Swap(&other->fill_);
+ 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 Trades::GetMetadata() const {
+ protobuf_AssignDescriptorsOnce();
+ ::google::protobuf::Metadata metadata;
+ metadata.descriptor = Trades_descriptor_;
+ metadata.reflection = Trades_reflection_;
+ return metadata;
+}
+
+
+} // namespace TradeData
Added: pkg/inst/examples/HighFrequencyFinance/TradeData.pb.h
===================================================================
--- pkg/inst/examples/HighFrequencyFinance/TradeData.pb.h (rev 0)
+++ pkg/inst/examples/HighFrequencyFinance/TradeData.pb.h 2010-07-17 17:46:06 UTC (rev 330)
@@ -0,0 +1,382 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+
+#ifndef PROTOBUF_TradeData_2eproto__INCLUDED
+#define PROTOBUF_TradeData_2eproto__INCLUDED
+
+#include <string>
+
+#include <google/protobuf/stubs/common.h>
+
+#if GOOGLE_PROTOBUF_VERSION < 2002000
+#error This file was generated by a newer version of protoc which is
+#error incompatible with your Protocol Buffer headers. Please update
+#error your headers.
+#endif
+#if 2002000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION
+#error This file was generated by an older version of protoc which is
+#error incompatible with your Protocol Buffer headers. Please
+#error regenerate this file with a newer version of protoc.
+#endif
+
+#include <google/protobuf/generated_message_util.h>
+#include <google/protobuf/repeated_field.h>
+#include <google/protobuf/extension_set.h>
+#include <google/protobuf/generated_message_reflection.h>
+
+namespace TradeData {
+
+// Internal implementation detail -- do not call these.
+void protobuf_AddDesc_TradeData_2eproto();
+void protobuf_AssignDesc_TradeData_2eproto();
+void protobuf_ShutdownFile_TradeData_2eproto();
+
+class Fill;
+class Trades;
+
+// ===================================================================
+
+class Fill : public ::google::protobuf::Message {
+ public:
+ Fill();
+ virtual ~Fill();
+
+ Fill(const Fill& from);
+
+ inline Fill& operator=(const Fill& 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 Fill& default_instance();
+ void Swap(Fill* other);
+
+ // implements Message ----------------------------------------------
+
+ Fill* New() const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const Fill& from);
+ void MergeFrom(const Fill& 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 { _cached_size_ = size; }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // required double timestamp = 1;
+ inline bool has_timestamp() const;
+ inline void clear_timestamp();
+ static const int kTimestampFieldNumber = 1;
+ inline double timestamp() const;
+ inline void set_timestamp(double value);
+
+ // required string symbol = 2;
+ inline bool has_symbol() const;
+ inline void clear_symbol();
+ static const int kSymbolFieldNumber = 2;
+ inline const ::std::string& symbol() const;
+ inline void set_symbol(const ::std::string& value);
+ inline void set_symbol(const char* value);
+ inline void set_symbol(const char* value, size_t size);
+ inline ::std::string* mutable_symbol();
+
+ // required double price = 3;
+ inline bool has_price() const;
+ inline void clear_price();
+ static const int kPriceFieldNumber = 3;
+ inline double price() const;
+ inline void set_price(double value);
+
+ // required int32 size = 4;
+ inline bool has_size() const;
+ inline void clear_size();
+ static const int kSizeFieldNumber = 4;
+ inline ::google::protobuf::int32 size() const;
+ inline void set_size(::google::protobuf::int32 value);
+
+ private:
+ ::google::protobuf::UnknownFieldSet _unknown_fields_;
+ mutable int _cached_size_;
+
+ double timestamp_;
+ ::std::string* symbol_;
+ static const ::std::string _default_symbol_;
+ double price_;
+ ::google::protobuf::int32 size_;
+ friend void protobuf_AddDesc_TradeData_2eproto();
+ friend void protobuf_AssignDesc_TradeData_2eproto();
+ friend void protobuf_ShutdownFile_TradeData_2eproto();
+
+ ::google::protobuf::uint32 _has_bits_[(4 + 31) / 32];
+
+ // WHY DOES & HAVE LOWER PRECEDENCE THAN != !?
+ inline bool _has_bit(int index) const {
+ return (_has_bits_[index / 32] & (1u << (index % 32))) != 0;
+ }
+ inline void _set_bit(int index) {
+ _has_bits_[index / 32] |= (1u << (index % 32));
+ }
+ inline void _clear_bit(int index) {
+ _has_bits_[index / 32] &= ~(1u << (index % 32));
+ }
+
+ void InitAsDefaultInstance();
+ static Fill* default_instance_;
+};
+// -------------------------------------------------------------------
+
+class Trades : public ::google::protobuf::Message {
+ public:
+ Trades();
+ virtual ~Trades();
+
+ Trades(const Trades& from);
+
+ inline Trades& operator=(const Trades& 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 Trades& default_instance();
+ void Swap(Trades* other);
+
+ // implements Message ----------------------------------------------
+
+ Trades* New() const;
+ void CopyFrom(const ::google::protobuf::Message& from);
+ void MergeFrom(const ::google::protobuf::Message& from);
+ void CopyFrom(const Trades& from);
+ void MergeFrom(const Trades& 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 { _cached_size_ = size; }
+ public:
+
+ ::google::protobuf::Metadata GetMetadata() const;
+
+ // nested types ----------------------------------------------------
+
+ // accessors -------------------------------------------------------
+
+ // repeated .TradeData.Fill fill = 1;
+ inline int fill_size() const;
+ inline void clear_fill();
+ static const int kFillFieldNumber = 1;
+ inline const ::google::protobuf::RepeatedPtrField< ::TradeData::Fill >& fill() const;
+ inline ::google::protobuf::RepeatedPtrField< ::TradeData::Fill >* mutable_fill();
+ inline const ::TradeData::Fill& fill(int index) const;
+ inline ::TradeData::Fill* mutable_fill(int index);
+ inline ::TradeData::Fill* add_fill();
+
+ private:
+ ::google::protobuf::UnknownFieldSet _unknown_fields_;
+ mutable int _cached_size_;
+
+ ::google::protobuf::RepeatedPtrField< ::TradeData::Fill > fill_;
+ friend void protobuf_AddDesc_TradeData_2eproto();
+ friend void protobuf_AssignDesc_TradeData_2eproto();
+ friend void protobuf_ShutdownFile_TradeData_2eproto();
+
+ ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32];
+
+ // WHY DOES & HAVE LOWER PRECEDENCE THAN != !?
+ inline bool _has_bit(int index) const {
+ return (_has_bits_[index / 32] & (1u << (index % 32))) != 0;
+ }
+ inline void _set_bit(int index) {
+ _has_bits_[index / 32] |= (1u << (index % 32));
+ }
+ inline void _clear_bit(int index) {
+ _has_bits_[index / 32] &= ~(1u << (index % 32));
+ }
+
+ void InitAsDefaultInstance();
+ static Trades* default_instance_;
+};
+// ===================================================================
+
+
+// ===================================================================
+
+
+// ===================================================================
+
+// Fill
+
+// required double timestamp = 1;
+inline bool Fill::has_timestamp() const {
+ return _has_bit(0);
+}
+inline void Fill::clear_timestamp() {
+ timestamp_ = 0;
+ _clear_bit(0);
+}
+inline double Fill::timestamp() const {
+ return timestamp_;
+}
+inline void Fill::set_timestamp(double value) {
+ _set_bit(0);
+ timestamp_ = value;
+}
+
+// required string symbol = 2;
+inline bool Fill::has_symbol() const {
+ return _has_bit(1);
+}
+inline void Fill::clear_symbol() {
+ if (symbol_ != &_default_symbol_) {
+ symbol_->clear();
+ }
+ _clear_bit(1);
+}
+inline const ::std::string& Fill::symbol() const {
+ return *symbol_;
+}
+inline void Fill::set_symbol(const ::std::string& value) {
+ _set_bit(1);
+ if (symbol_ == &_default_symbol_) {
+ symbol_ = new ::std::string;
+ }
+ symbol_->assign(value);
+}
+inline void Fill::set_symbol(const char* value) {
+ _set_bit(1);
+ if (symbol_ == &_default_symbol_) {
+ symbol_ = new ::std::string;
+ }
+ symbol_->assign(value);
+}
+inline void Fill::set_symbol(const char* value, size_t size) {
+ _set_bit(1);
+ if (symbol_ == &_default_symbol_) {
+ symbol_ = new ::std::string;
+ }
+ symbol_->assign(reinterpret_cast<const char*>(value), size);
+}
+inline ::std::string* Fill::mutable_symbol() {
+ _set_bit(1);
+ if (symbol_ == &_default_symbol_) {
+ symbol_ = new ::std::string;
+ }
+ return symbol_;
+}
+
+// required double price = 3;
+inline bool Fill::has_price() const {
+ return _has_bit(2);
+}
+inline void Fill::clear_price() {
+ price_ = 0;
+ _clear_bit(2);
+}
+inline double Fill::price() const {
+ return price_;
+}
+inline void Fill::set_price(double value) {
+ _set_bit(2);
+ price_ = value;
+}
+
+// required int32 size = 4;
+inline bool Fill::has_size() const {
+ return _has_bit(3);
+}
+inline void Fill::clear_size() {
+ size_ = 0;
+ _clear_bit(3);
+}
+inline ::google::protobuf::int32 Fill::size() const {
+ return size_;
+}
+inline void Fill::set_size(::google::protobuf::int32 value) {
+ _set_bit(3);
+ size_ = value;
+}
+
+// -------------------------------------------------------------------
+
+// Trades
+
+// repeated .TradeData.Fill fill = 1;
+inline int Trades::fill_size() const {
+ return fill_.size();
+}
+inline void Trades::clear_fill() {
+ fill_.Clear();
+}
+inline const ::google::protobuf::RepeatedPtrField< ::TradeData::Fill >&
+Trades::fill() const {
+ return fill_;
+}
+inline ::google::protobuf::RepeatedPtrField< ::TradeData::Fill >*
+Trades::mutable_fill() {
+ return &fill_;
+}
+inline const ::TradeData::Fill& Trades::fill(int index) const {
+ return fill_.Get(index);
+}
+inline ::TradeData::Fill* Trades::mutable_fill(int index) {
+ return fill_.Mutable(index);
+}
+inline ::TradeData::Fill* Trades::add_fill() {
+ return fill_.Add();
+}
+
+
+} // namespace TradeData
+
+#ifndef SWIG
+namespace google {
+namespace protobuf {
+
+
+} // namespace google
+} // namespace protobuf
+#endif // SWIG
+
+#endif // PROTOBUF_TradeData_2eproto__INCLUDED
Added: pkg/inst/examples/HighFrequencyFinance/TradeData.proto
===================================================================
[TRUNCATED]
To get the complete diff run:
svnlook diff /svnroot/rprotobuf -r 330
More information about the Rprotobuf-commits
mailing list