~ubuntu-branches/ubuntu/trusty/protobuf/trusty-proposed

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2011-05-31 14:41:47 UTC
  • mfrom: (2.2.8 sid)
  • Revision ID: james.westby@ubuntu.com-20110531144147-s41g5fozgvyo462l
Tags: 2.4.0a-2ubuntu1
* Merge with Debian; remaining changes:
  - Fix linking with -lpthread.

Show diffs side-by-side

added added

removed removed

Lines of Context:
90
90
    ~Printer();
91
91
 
92
92
    // Like TextFormat::Print
93
 
    bool Print(const Message& message, io::ZeroCopyOutputStream* output);
 
93
    bool Print(const Message& message, io::ZeroCopyOutputStream* output) const;
94
94
    // Like TextFormat::PrintUnknownFields
95
95
    bool PrintUnknownFields(const UnknownFieldSet& unknown_fields,
96
 
                            io::ZeroCopyOutputStream* output);
 
96
                            io::ZeroCopyOutputStream* output) const;
97
97
    // Like TextFormat::PrintToString
98
 
    bool PrintToString(const Message& message, string* output);
 
98
    bool PrintToString(const Message& message, string* output) const;
99
99
    // Like TextFormat::PrintUnknownFieldsToString
100
100
    bool PrintUnknownFieldsToString(const UnknownFieldSet& unknown_fields,
101
 
                                    string* output);
 
101
                                    string* output) const;
102
102
    // Like TextFormat::PrintFieldValueToString
103
103
    void PrintFieldValueToString(const Message& message,
104
104
                                 const FieldDescriptor* field,
105
105
                                 int index,
106
 
                                 string* output);
 
106
                                 string* output) const;
107
107
 
108
108
    // Adjust the initial indent level of all output.  Each indent level is
109
109
    // equal to two spaces.
121
121
    //   field_name: [1, 2, 3, 4]
122
122
    // instead of printing each value on its own line.  Short format applies
123
123
    // only to primitive values -- i.e. everything except strings and
124
 
    // sub-messages/groups.  Note that at present this format is not recognized
125
 
    // by the parser.
 
124
    // sub-messages/groups.
126
125
    void SetUseShortRepeatedPrimitives(bool use_short_repeated_primitives) {
127
126
      use_short_repeated_primitives_ = use_short_repeated_primitives;
128
127
    }
143
142
    // Internal Print method, used for writing to the OutputStream via
144
143
    // the TextGenerator class.
145
144
    void Print(const Message& message,
146
 
               TextGenerator& generator);
 
145
               TextGenerator& generator) const;
147
146
 
148
147
    // Print a single field.
149
148
    void PrintField(const Message& message,
150
149
                    const Reflection* reflection,
151
150
                    const FieldDescriptor* field,
152
 
                    TextGenerator& generator);
 
151
                    TextGenerator& generator) const;
153
152
 
154
153
    // Print a repeated primitive field in short form.
155
154
    void PrintShortRepeatedField(const Message& message,
156
155
                                 const Reflection* reflection,
157
156
                                 const FieldDescriptor* field,
158
 
                                 TextGenerator& generator);
 
157
                                 TextGenerator& generator) const;
159
158
 
160
159
    // Print the name of a field -- i.e. everything that comes before the
161
160
    // ':' for a single name/value pair.
162
161
    void PrintFieldName(const Message& message,
163
162
                        const Reflection* reflection,
164
163
                        const FieldDescriptor* field,
165
 
                        TextGenerator& generator);
 
164
                        TextGenerator& generator) const;
166
165
 
167
166
    // Outputs a textual representation of the value of the field supplied on
168
167
    // the message supplied or the default value if not set.
170
169
                         const Reflection* reflection,
171
170
                         const FieldDescriptor* field,
172
171
                         int index,
173
 
                         TextGenerator& generator);
 
172
                         TextGenerator& generator) const;
174
173
 
175
174
    // Print the fields in an UnknownFieldSet.  They are printed by tag number
176
175
    // only.  Embedded messages are heuristically identified by attempting to
177
176
    // parse them.
178
177
    void PrintUnknownFields(const UnknownFieldSet& unknown_fields,
179
 
                            TextGenerator& generator);
 
178
                            TextGenerator& generator) const;
180
179
 
181
180
    int initial_indent_level_;
182
181
 
207
206
                                        const FieldDescriptor* field,
208
207
                                        Message* message);
209
208
 
 
209
  // Interface that TextFormat::Parser can use to find extensions.
 
210
  // This class may be extended in the future to find more information
 
211
  // like fields, etc.
 
212
  class LIBPROTOBUF_EXPORT Finder {
 
213
   public:
 
214
    virtual ~Finder();
 
215
 
 
216
    // Try to find an extension of *message by fully-qualified field
 
217
    // name.  Returns NULL if no extension is known for this name or number.
 
218
    virtual const FieldDescriptor* FindExtension(
 
219
        Message* message,
 
220
        const string& name) const = 0;
 
221
  };
 
222
 
210
223
  // For more control over parsing, use this class.
211
224
  class LIBPROTOBUF_EXPORT Parser {
212
225
   public:
228
241
      error_collector_ = error_collector;
229
242
    }
230
243
 
 
244
    // Set how parser finds extensions.  If NULL (the default), the
 
245
    // parser will use the standard Reflection object associated with
 
246
    // the message being parsed.
 
247
    void SetFinder(Finder* finder) {
 
248
      finder_ = finder;
 
249
    }
 
250
 
231
251
    // Normally parsing fails if, after parsing, output->IsInitialized()
232
252
    // returns false.  Call AllowPartialMessage(true) to skip this check.
233
253
    void AllowPartialMessage(bool allow) {
251
271
                        ParserImpl* parser_impl);
252
272
 
253
273
    io::ErrorCollector* error_collector_;
 
274
    Finder* finder_;
254
275
    bool allow_partial_;
255
276
  };
256
277