~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/message/binary_log.cc

Extracted the LOAD command into its own class and implementation files.
Removed the corresponding case label from the switch statement.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 
4
4
#include <google/protobuf/io/coded_stream.h>
5
5
 
6
 
using namespace google;
 
6
using namespace google::protobuf;
 
7
using namespace google::protobuf::io;
7
8
 
8
9
bool
9
 
BinaryLog::Event::write(protobuf::io::CodedOutputStream* out) const
 
10
BinaryLog::Event::write(CodedOutputStream* out) const
10
11
{
11
12
  // We frame each event in a length encoded in a special manner, and
12
13
  // end it with a CRC-32 checksum.
37
38
 
38
39
 
39
40
bool
40
 
BinaryLog::Event::read(protobuf::io::CodedInputStream *in)
 
41
BinaryLog::Event::read(CodedInputStream *in)
41
42
{
42
43
  unsigned char buf[LENGTH_ENCODE_MAX_BYTES + 1];
43
44
 
58
59
 
59
60
  // Create the right event based on the type code (is there something
60
61
  // better in the protobuf library?)
61
 
  protobuf::Message *message= NULL;
 
62
  Message *message= NULL;
62
63
  switch (m_type) {
63
64
  case QUERY:
64
65
    message= new BinaryLog::Query;
91
92
  // Read the event body as length bytes. It is necessary to limit the
92
93
  // stream since otherwise ParseFromCodedStream reads all bytes of
93
94
  // the stream.
94
 
  protobuf::io::CodedInputStream::Limit limit= in->PushLimit(length);
 
95
  CodedInputStream::Limit limit= in->PushLimit(length);
95
96
  if (!message->ParseFromCodedStream(in))
96
97
    return false;
97
98
  in->PopLimit(limit);
115
116
void
116
117
BinaryLog::Event::print(std::ostream& out) const
117
118
{
 
119
  using namespace google::protobuf;
 
120
 
118
121
  switch (m_type) {
119
122
  case QUERY:
120
123
  {
121
124
    Query *event= static_cast<Query*>(m_message);
122
125
    print_common(out, event);
123
 
    for (protobuf::RepeatedPtrField<Query::Variable>::const_iterator ii=
124
 
           event->variable().begin() ;
 
126
    for (RepeatedPtrField<Query::Variable>::const_iterator ii= event->variable().begin() ;
125
127
         ii != event->variable().end() ;
126
128
         ++ii)
127
129
    {
167
169
    break;                                      /* Nothing */
168
170
  }
169
171
}
170