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/
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
9
// http://www.apache.org/licenses/LICENSE-2.0
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
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
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.
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.
17
31
// Author: jschorr@google.com (Joseph Schorr)
18
32
// Based on original Protocol Buffers design by
45
59
// Outputs a textual representation of the given message to the given
47
61
static bool Print(const Message& message, io::ZeroCopyOutputStream* output);
63
// Print the fields in an UnknownFieldSet. They are printed by tag number
64
// only. Embedded messages are heuristically identified by attempting to
66
static bool PrintUnknownFields(const UnknownFieldSet& unknown_fields,
67
io::ZeroCopyOutputStream* output);
48
69
// Like Print(), but outputs directly to a string.
49
70
static bool PrintToString(const Message& message, string* output);
72
// Like PrintUnknownFields(), but outputs directly to a string.
73
static bool PrintUnknownFieldsToString(const UnknownFieldSet& unknown_fields,
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
126
// Forward declaration of an internal class used to parse text
127
// representations (see text_format.cc for implementation).
130
// Like TextFormat::Merge(). The provided implementation is used
131
// to do the parsing.
132
bool MergeUsingImpl(io::ZeroCopyInputStream* input,
134
ParserImpl* parser_impl);
101
136
io::ErrorCollector* error_collector_;
102
137
bool allow_partial_;
107
142
// output to the OutputStream (see text_format.cc for implementation).
108
143
class TextGenerator;
110
// Forward declaration of an internal class used to parse text
111
// representations (see text_format.cc for implementation).
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);
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);
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,
130
162
TextGenerator& generator);
132
164
// Print the fields in an UnknownFieldSet. They are printed by tag number
165
// only. Embedded messages are heuristically identified by attempting to
134
167
static void PrintUnknownFields(const UnknownFieldSet& unknown_fields,
135
168
TextGenerator& generator);