~ubuntu-branches/ubuntu/oneiric/protobuf/oneiric

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Steve Kowalik
  • Date: 2009-11-16 10:41:33 UTC
  • mfrom: (2.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20091116104133-ykhy3deg5l4975tw
Tags: 2.1.0-1ubuntu1
* Merge from Debian testing.
* Remaining Ubuntu changes:
  - Disable the death tests on IA64, now as a quilt patch.
  - Don't use python2.4, also as a quilt patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
82
82
                                      int index,
83
83
                                      string* output);
84
84
 
 
85
  // Class for those users which require more fine-grained control over how
 
86
  // a protobuffer message is printed out.
 
87
  class LIBPROTOBUF_EXPORT Printer {
 
88
   public:
 
89
    Printer();
 
90
    ~Printer();
 
91
 
 
92
    // Like TextFormat::Print
 
93
    bool Print(const Message& message, io::ZeroCopyOutputStream* output);
 
94
    // Like TextFormat::PrintUnknownFields
 
95
    bool PrintUnknownFields(const UnknownFieldSet& unknown_fields,
 
96
                            io::ZeroCopyOutputStream* output);
 
97
    // Like TextFormat::PrintToString
 
98
    bool PrintToString(const Message& message, string* output);
 
99
    // Like TextFormat::PrintUnknownFieldsToString
 
100
    bool PrintUnknownFieldsToString(const UnknownFieldSet& unknown_fields,
 
101
                                    string* output);
 
102
    // Like TextFormat::PrintFieldValueToString
 
103
    void PrintFieldValueToString(const Message& message,
 
104
                                 const FieldDescriptor* field,
 
105
                                 int index,
 
106
                                 string* output);
 
107
 
 
108
    // Adjust the initial indent level of all output.  Each indent level is
 
109
    // equal to two spaces.
 
110
    void SetInitialIndentLevel(int indent_level) {
 
111
      initial_indent_level_ = indent_level;
 
112
    }
 
113
 
 
114
    // If printing in single line mode, then the entire message will be output
 
115
    // on a single line with no line breaks.
 
116
    void SetSingleLineMode(bool single_line_mode) {
 
117
      single_line_mode_ = single_line_mode;
 
118
    }
 
119
 
 
120
   private:
 
121
    // Forward declaration of an internal class used to print the text
 
122
    // output to the OutputStream (see text_format.cc for implementation).
 
123
    class TextGenerator;
 
124
 
 
125
    // Internal Print method, used for writing to the OutputStream via
 
126
    // the TextGenerator class.
 
127
    void Print(const Message& message,
 
128
               TextGenerator& generator);
 
129
 
 
130
    // Print a single field.
 
131
    void PrintField(const Message& message,
 
132
                    const Reflection* reflection,
 
133
                    const FieldDescriptor* field,
 
134
                    TextGenerator& generator);
 
135
 
 
136
    // Outputs a textual representation of the value of the field supplied on
 
137
    // the message supplied or the default value if not set.
 
138
    void PrintFieldValue(const Message& message,
 
139
                         const Reflection* reflection,
 
140
                         const FieldDescriptor* field,
 
141
                         int index,
 
142
                         TextGenerator& generator);
 
143
 
 
144
    // Print the fields in an UnknownFieldSet.  They are printed by tag number
 
145
    // only.  Embedded messages are heuristically identified by attempting to
 
146
    // parse them.
 
147
    void PrintUnknownFields(const UnknownFieldSet& unknown_fields,
 
148
                            TextGenerator& generator);
 
149
 
 
150
    int initial_indent_level_;
 
151
 
 
152
    bool single_line_mode_;
 
153
  };
 
154
 
85
155
  // Parses a text-format protocol message from the given input stream to
86
156
  // the given message object.  This function parses the format written
87
157
  // by Print().
138
208
  };
139
209
 
140
210
 private:
141
 
  // Forward declaration of an internal class used to print the text
142
 
  // output to the OutputStream (see text_format.cc for implementation).
143
 
  class TextGenerator;
144
 
 
145
 
  // Internal Print method, used for writing to the OutputStream via
146
 
  // the TextGenerator class.
147
 
  static void Print(const Message& message,
148
 
                    TextGenerator& generator);
149
 
 
150
 
  // Print a single field.
151
 
  static void PrintField(const Message& message,
152
 
                         const Reflection* reflection,
153
 
                         const FieldDescriptor* field,
154
 
                         TextGenerator& generator);
155
 
 
156
 
  // Outputs a textual representation of the value of the field supplied on
157
 
  // the message supplied or the default value if not set.
158
 
  static void PrintFieldValue(const Message& message,
159
 
                              const Reflection* reflection,
160
 
                              const FieldDescriptor* field,
161
 
                              int index,
162
 
                              TextGenerator& generator);
163
 
 
164
 
  // Print the fields in an UnknownFieldSet.  They are printed by tag number
165
 
  // only.  Embedded messages are heuristically identified by attempting to
166
 
  // parse them.
167
 
  static void PrintUnknownFields(const UnknownFieldSet& unknown_fields,
168
 
                                 TextGenerator& generator);
169
 
 
170
211
  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TextFormat);
171
212
};
172
213