~ubuntu-branches/debian/sid/protobuf/sid

« back to all changes in this revision

Viewing changes to src/google/protobuf/text_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: jschorr@google.com (Joseph Schorr)
18
32
//  Based on original Protocol Buffers design by
25
39
#define GOOGLE_PROTOBUF_TEXT_FORMAT_H__
26
40
 
27
41
#include <string>
28
 
#include <google/protobuf/message.h>  // Message, Message::Reflection
 
42
#include <google/protobuf/message.h>
29
43
#include <google/protobuf/descriptor.h>
30
44
 
31
45
namespace google {
45
59
  // Outputs a textual representation of the given message to the given
46
60
  // output stream.
47
61
  static bool Print(const Message& message, io::ZeroCopyOutputStream* output);
 
62
 
 
63
  // Print the fields in an UnknownFieldSet.  They are printed by tag number
 
64
  // only.  Embedded messages are heuristically identified by attempting to
 
65
  // parse them.
 
66
  static bool PrintUnknownFields(const UnknownFieldSet& unknown_fields,
 
67
                                 io::ZeroCopyOutputStream* output);
 
68
 
48
69
  // Like Print(), but outputs directly to a string.
49
70
  static bool PrintToString(const Message& message, string* output);
50
71
 
 
72
  // Like PrintUnknownFields(), but outputs directly to a string.
 
73
  static bool PrintUnknownFieldsToString(const UnknownFieldSet& unknown_fields,
 
74
                                         string* output);
 
75
 
51
76
  // Outputs a textual representation of the value of the field supplied on
52
77
  // the message supplied. For non-repeated fields, an index of -1 must
53
78
  // be supplied. Note that this method will print the default value for a
98
123
    }
99
124
 
100
125
   private:
 
126
    // Forward declaration of an internal class used to parse text
 
127
    // representations (see text_format.cc for implementation).
 
128
    class ParserImpl;
 
129
 
 
130
    // Like TextFormat::Merge().  The provided implementation is used
 
131
    // to do the parsing.
 
132
    bool MergeUsingImpl(io::ZeroCopyInputStream* input,
 
133
                        Message* output,
 
134
                        ParserImpl* parser_impl);
 
135
 
101
136
    io::ErrorCollector* error_collector_;
102
137
    bool allow_partial_;
103
138
  };
107
142
  // output to the OutputStream (see text_format.cc for implementation).
108
143
  class TextGenerator;
109
144
 
110
 
  // Forward declaration of an internal class used to parse text
111
 
  // representations (see text_format.cc for implementation).
112
 
  class ParserImpl;
113
 
 
114
145
  // Internal Print method, used for writing to the OutputStream via
115
146
  // the TextGenerator class.
116
 
  static void Print(const Descriptor* descriptor,
117
 
                    const Message::Reflection* message,
 
147
  static void Print(const Message& message,
118
148
                    TextGenerator& generator);
119
149
 
120
150
  // Print a single field.
121
 
  static void PrintField(const FieldDescriptor* field,
122
 
                         const Message::Reflection* message,
 
151
  static void PrintField(const Message& message,
 
152
                         const Reflection* reflection,
 
153
                         const FieldDescriptor* field,
123
154
                         TextGenerator& generator);
124
155
 
125
156
  // Outputs a textual representation of the value of the field supplied on
126
157
  // the message supplied or the default value if not set.
127
 
  static void PrintFieldValue(const Message::Reflection* reflection,
 
158
  static void PrintFieldValue(const Message& message,
 
159
                              const Reflection* reflection,
128
160
                              const FieldDescriptor* field,
129
161
                              int index,
130
162
                              TextGenerator& generator);
131
163
 
132
164
  // Print the fields in an UnknownFieldSet.  They are printed by tag number
133
 
  // only.
 
165
  // only.  Embedded messages are heuristically identified by attempting to
 
166
  // parse them.
134
167
  static void PrintUnknownFields(const UnknownFieldSet& unknown_fields,
135
168
                                 TextGenerator& generator);
136
169