~ubuntu-branches/debian/squeeze/protobuf/squeeze

« back to all changes in this revision

Viewing changes to src/google/protobuf/wire_format.h

  • Committer: Bazaar Package Importer
  • Author(s): Julien Cristau
  • Date: 2009-06-02 16:19:00 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090602161900-vm176i3ryt35yk91
Tags: 2.0.3-2.2
* Non-maintainer upload.
* Fix FTBFS from -2.1: don't fail when we can't clean up the java build,
  such as when openjdk isn't installed.
* Disable parallel builds, because libtool is made of fail (if binary-arch
  and build-indep run concurrently, we relink a library while it's being
  used; that doesn't work so well).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// Protocol Buffers - Google's data interchange format
2
 
// Copyright 2008 Google Inc.
 
2
// Copyright 2008 Google Inc.  All rights reserved.
3
3
// http://code.google.com/p/protobuf/
4
4
//
5
 
// Licensed under the Apache License, Version 2.0 (the "License");
6
 
// you may not use this file except in compliance with the License.
7
 
// You may obtain a copy of the License at
8
 
//
9
 
//      http://www.apache.org/licenses/LICENSE-2.0
10
 
//
11
 
// Unless required by applicable law or agreed to in writing, software
12
 
// distributed under the License is distributed on an "AS IS" BASIS,
13
 
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 
// See the License for the specific language governing permissions and
15
 
// limitations under the License.
 
5
// Redistribution and use in source and binary forms, with or without
 
6
// modification, are permitted provided that the following conditions are
 
7
// met:
 
8
//
 
9
//     * Redistributions of source code must retain the above copyright
 
10
// notice, this list of conditions and the following disclaimer.
 
11
//     * Redistributions in binary form must reproduce the above
 
12
// copyright notice, this list of conditions and the following disclaimer
 
13
// in the documentation and/or other materials provided with the
 
14
// distribution.
 
15
//     * Neither the name of Google Inc. nor the names of its
 
16
// contributors may be used to endorse or promote products derived from
 
17
// this software without specific prior written permission.
 
18
//
 
19
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 
20
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 
21
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 
22
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 
23
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 
24
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 
25
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 
26
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 
27
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
28
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 
29
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16
30
 
17
31
// Author: kenton@google.com (Kenton Varda)
18
32
//         atenasio@google.com (Chris Atenasio) (ZigZag transform)
26
40
#define GOOGLE_PROTOBUF_WIRE_FORMAT_H__
27
41
 
28
42
#include <string>
29
 
#include <google/protobuf/message.h>  // Message::Reflection
 
43
#include <google/protobuf/message.h>
30
44
#include <google/protobuf/descriptor.h>
31
45
 
32
46
namespace google {
55
69
 public:
56
70
  // These procedures can be used to implement the methods of Message which
57
71
  // handle parsing and serialization of the protocol buffer wire format
58
 
  // using only the Message::Reflection interface.  When you ask the protocol
 
72
  // using only the Reflection interface.  When you ask the protocol
59
73
  // compiler to optimize for code size rather than speed, it will implement
60
74
  // those methods in terms of these procedures.  Of course, these are much
61
75
  // slower than the specialized implementations which the protocol compiler
69
83
  //
70
84
  // Required fields are NOT checked by this method.  You must call
71
85
  // IsInitialized() on the resulting message yourself.
72
 
  static bool ParseAndMergePartial(const Descriptor* descriptor,
73
 
                                   io::CodedInputStream* input,
74
 
                                   Message::Reflection* message_reflection);
 
86
  static bool ParseAndMergePartial(io::CodedInputStream* input,
 
87
                                   Message* message);
75
88
 
76
89
  // Serialize a message in protocol buffer wire format.
77
90
  //
81
94
  //
82
95
  // These return false iff the underlying stream returns a write error.
83
96
  static bool SerializeWithCachedSizes(
84
 
      const Descriptor* descriptor,
85
 
      const Message::Reflection* message_reflection,
 
97
      const Message& message,
86
98
      int size, io::CodedOutputStream* output);
87
99
 
88
100
  // Implements Message::ByteSize() via reflection.  WARNING:  The result
90
102
  // will have their ByteSize() methods called, so their sizes will be cached.
91
103
  // Therefore, calling this method is sufficient to allow you to call
92
104
  // WireFormat::SerializeWithCachedSizes() on the same object.
93
 
  static int ByteSize(const Descriptor* descriptor,
94
 
                      const Message::Reflection* message_reflection);
 
105
  static int ByteSize(const Message& message);
95
106
 
96
107
  // -----------------------------------------------------------------
97
108
  // Helpers for dealing with unknown fields
188
199
  static bool ParseAndMergeField(
189
200
      uint32 tag,
190
201
      const FieldDescriptor* field,        // May be NULL for unknown
191
 
      Message::Reflection* message_reflection,
 
202
      Message* message,
192
203
      io::CodedInputStream* input);
193
204
 
194
205
  // Serialize a single field.
195
206
  static bool SerializeFieldWithCachedSizes(
196
207
      const FieldDescriptor* field,        // Cannot be NULL
197
 
      const Message::Reflection* message_reflection,
 
208
      const Message& message,
198
209
      io::CodedOutputStream* output);
199
210
 
200
211
  // Compute size of a single field.  If the field is a message type, this
202
213
  // its size.
203
214
  static int FieldByteSize(
204
215
      const FieldDescriptor* field,        // Cannot be NULL
205
 
      const Message::Reflection* message_reflection);
 
216
      const Message& message);
206
217
 
207
218
  // =================================================================
208
219
  // Methods for reading/writing individual field.  The implementations
335
346
  // opion message_set_wire_format = true.
336
347
  static bool ParseAndMergeMessageSetItem(
337
348
      io::CodedInputStream* input,
338
 
      Message::Reflection* message_reflection);
 
349
      Message* message);
339
350
  static bool SerializeMessageSetItemWithCachedSizes(
340
351
      const FieldDescriptor* field,
341
 
      const Message::Reflection* message_reflection,
 
352
      const Message& message,
342
353
      io::CodedOutputStream* output);
343
354
  static int MessageSetItemByteSize(
344
355
      const FieldDescriptor* field,
345
 
      const Message::Reflection* message_reflection);
 
356
      const Message& message);
346
357
 
347
358
  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(WireFormat);
348
359
};