1// GENERATED FILE - DO NOT MODIFY
2
3#include <algorithm>
4
5#include "tensorflow/core/framework/resource_handle.pb_text-impl.h"
6
7using ::tensorflow::strings::ProtoSpaceAndComments;
8using ::tensorflow::strings::Scanner;
9using ::tensorflow::strings::StrCat;
10
11namespace tensorflow {
12
13string ProtoDebugString(
14 const ::tensorflow::ResourceHandleProto_DtypeAndShape& msg) {
15 string s;
16 ::tensorflow::strings::ProtoTextOutput o(&s, false);
17 internal::AppendProtoDebugString(&o, msg);
18 o.CloseTopMessage();
19 return s;
20}
21
22string ProtoShortDebugString(
23 const ::tensorflow::ResourceHandleProto_DtypeAndShape& msg) {
24 string s;
25 ::tensorflow::strings::ProtoTextOutput o(&s, true);
26 internal::AppendProtoDebugString(&o, msg);
27 o.CloseTopMessage();
28 return s;
29}
30
31namespace internal {
32
33void AppendProtoDebugString(
34 ::tensorflow::strings::ProtoTextOutput* o,
35 const ::tensorflow::ResourceHandleProto_DtypeAndShape& msg) {
36 if (msg.dtype() != 0) {
37 const char* enum_name = ::tensorflow::EnumName_DataType(msg.dtype());
38 if (enum_name[0]) {
39 o->AppendEnumName("dtype", enum_name);
40 } else {
41 o->AppendNumeric("dtype", msg.dtype());
42 }
43 }
44 if (msg.has_shape()) {
45 o->OpenNestedMessage("shape");
46 ::tensorflow::internal::AppendProtoDebugString(o, msg.shape());
47 o->CloseNestedMessage();
48 }
49}
50
51} // namespace internal
52
53bool ProtoParseFromString(
54 const string& s,
55 ::tensorflow::ResourceHandleProto_DtypeAndShape* msg) {
56 msg->Clear();
57 Scanner scanner(s);
58 if (!internal::ProtoParseFromScanner(&scanner, false, false, msg)) return false;
59 scanner.Eos();
60 return scanner.GetResult();
61}
62
63namespace internal {
64
65bool ProtoParseFromScanner(
66 ::tensorflow::strings::Scanner* scanner, bool nested, bool close_curly,
67 ::tensorflow::ResourceHandleProto_DtypeAndShape* msg) {
68 std::vector<bool> has_seen(2, false);
69 while(true) {
70 ProtoSpaceAndComments(scanner);
71 if (nested && (scanner->Peek() == (close_curly ? '}' : '>'))) {
72 scanner->One(Scanner::ALL);
73 ProtoSpaceAndComments(scanner);
74 return true;
75 }
76 if (!nested && scanner->empty()) { return true; }
77 scanner->RestartCapture()
78 .Many(Scanner::LETTER_DIGIT_UNDERSCORE)
79 .StopCapture();
80 StringPiece identifier;
81 if (!scanner->GetResult(nullptr, &identifier)) return false;
82 bool parsed_colon = false;
83 (void)parsed_colon;
84 ProtoSpaceAndComments(scanner);
85 if (scanner->Peek() == ':') {
86 parsed_colon = true;
87 scanner->One(Scanner::ALL);
88 ProtoSpaceAndComments(scanner);
89 }
90 if (identifier == "dtype") {
91 if (has_seen[0]) return false;
92 has_seen[0] = true;
93 StringPiece value;
94 if (!parsed_colon || !scanner->RestartCapture().Many(Scanner::LETTER_DIGIT_DASH_UNDERSCORE).GetResult(nullptr, &value)) return false;
95 if (value == "DT_INVALID") {
96 msg->set_dtype(::tensorflow::DT_INVALID);
97 } else if (value == "DT_FLOAT") {
98 msg->set_dtype(::tensorflow::DT_FLOAT);
99 } else if (value == "DT_DOUBLE") {
100 msg->set_dtype(::tensorflow::DT_DOUBLE);
101 } else if (value == "DT_INT32") {
102 msg->set_dtype(::tensorflow::DT_INT32);
103 } else if (value == "DT_UINT8") {
104 msg->set_dtype(::tensorflow::DT_UINT8);
105 } else if (value == "DT_INT16") {
106 msg->set_dtype(::tensorflow::DT_INT16);
107 } else if (value == "DT_INT8") {
108 msg->set_dtype(::tensorflow::DT_INT8);
109 } else if (value == "DT_STRING") {
110 msg->set_dtype(::tensorflow::DT_STRING);
111 } else if (value == "DT_COMPLEX64") {
112 msg->set_dtype(::tensorflow::DT_COMPLEX64);
113 } else if (value == "DT_INT64") {
114 msg->set_dtype(::tensorflow::DT_INT64);
115 } else if (value == "DT_BOOL") {
116 msg->set_dtype(::tensorflow::DT_BOOL);
117 } else if (value == "DT_QINT8") {
118 msg->set_dtype(::tensorflow::DT_QINT8);
119 } else if (value == "DT_QUINT8") {
120 msg->set_dtype(::tensorflow::DT_QUINT8);
121 } else if (value == "DT_QINT32") {
122 msg->set_dtype(::tensorflow::DT_QINT32);
123 } else if (value == "DT_BFLOAT16") {
124 msg->set_dtype(::tensorflow::DT_BFLOAT16);
125 } else if (value == "DT_QINT16") {
126 msg->set_dtype(::tensorflow::DT_QINT16);
127 } else if (value == "DT_QUINT16") {
128 msg->set_dtype(::tensorflow::DT_QUINT16);
129 } else if (value == "DT_UINT16") {
130 msg->set_dtype(::tensorflow::DT_UINT16);
131 } else if (value == "DT_COMPLEX128") {
132 msg->set_dtype(::tensorflow::DT_COMPLEX128);
133 } else if (value == "DT_HALF") {
134 msg->set_dtype(::tensorflow::DT_HALF);
135 } else if (value == "DT_RESOURCE") {
136 msg->set_dtype(::tensorflow::DT_RESOURCE);
137 } else if (value == "DT_VARIANT") {
138 msg->set_dtype(::tensorflow::DT_VARIANT);
139 } else if (value == "DT_UINT32") {
140 msg->set_dtype(::tensorflow::DT_UINT32);
141 } else if (value == "DT_UINT64") {
142 msg->set_dtype(::tensorflow::DT_UINT64);
143 } else if (value == "DT_FLOAT_REF") {
144 msg->set_dtype(::tensorflow::DT_FLOAT_REF);
145 } else if (value == "DT_DOUBLE_REF") {
146 msg->set_dtype(::tensorflow::DT_DOUBLE_REF);
147 } else if (value == "DT_INT32_REF") {
148 msg->set_dtype(::tensorflow::DT_INT32_REF);
149 } else if (value == "DT_UINT8_REF") {
150 msg->set_dtype(::tensorflow::DT_UINT8_REF);
151 } else if (value == "DT_INT16_REF") {
152 msg->set_dtype(::tensorflow::DT_INT16_REF);
153 } else if (value == "DT_INT8_REF") {
154 msg->set_dtype(::tensorflow::DT_INT8_REF);
155 } else if (value == "DT_STRING_REF") {
156 msg->set_dtype(::tensorflow::DT_STRING_REF);
157 } else if (value == "DT_COMPLEX64_REF") {
158 msg->set_dtype(::tensorflow::DT_COMPLEX64_REF);
159 } else if (value == "DT_INT64_REF") {
160 msg->set_dtype(::tensorflow::DT_INT64_REF);
161 } else if (value == "DT_BOOL_REF") {
162 msg->set_dtype(::tensorflow::DT_BOOL_REF);
163 } else if (value == "DT_QINT8_REF") {
164 msg->set_dtype(::tensorflow::DT_QINT8_REF);
165 } else if (value == "DT_QUINT8_REF") {
166 msg->set_dtype(::tensorflow::DT_QUINT8_REF);
167 } else if (value == "DT_QINT32_REF") {
168 msg->set_dtype(::tensorflow::DT_QINT32_REF);
169 } else if (value == "DT_BFLOAT16_REF") {
170 msg->set_dtype(::tensorflow::DT_BFLOAT16_REF);
171 } else if (value == "DT_QINT16_REF") {
172 msg->set_dtype(::tensorflow::DT_QINT16_REF);
173 } else if (value == "DT_QUINT16_REF") {
174 msg->set_dtype(::tensorflow::DT_QUINT16_REF);
175 } else if (value == "DT_UINT16_REF") {
176 msg->set_dtype(::tensorflow::DT_UINT16_REF);
177 } else if (value == "DT_COMPLEX128_REF") {
178 msg->set_dtype(::tensorflow::DT_COMPLEX128_REF);
179 } else if (value == "DT_HALF_REF") {
180 msg->set_dtype(::tensorflow::DT_HALF_REF);
181 } else if (value == "DT_RESOURCE_REF") {
182 msg->set_dtype(::tensorflow::DT_RESOURCE_REF);
183 } else if (value == "DT_VARIANT_REF") {
184 msg->set_dtype(::tensorflow::DT_VARIANT_REF);
185 } else if (value == "DT_UINT32_REF") {
186 msg->set_dtype(::tensorflow::DT_UINT32_REF);
187 } else if (value == "DT_UINT64_REF") {
188 msg->set_dtype(::tensorflow::DT_UINT64_REF);
189 } else {
190 int32 int_value;
191 if (strings::SafeStringToNumeric(value, &int_value)) {
192 msg->set_dtype(static_cast<::tensorflow::DataType>(int_value));
193 } else {
194 return false;
195 }
196 }
197 }
198 else if (identifier == "shape") {
199 if (has_seen[1]) return false;
200 has_seen[1] = true;
201 const char open_char = scanner->Peek();
202 if (open_char != '{' && open_char != '<') return false;
203 scanner->One(Scanner::ALL);
204 ProtoSpaceAndComments(scanner);
205 if (!::tensorflow::internal::ProtoParseFromScanner(
206 scanner, true, open_char == '{', msg->mutable_shape())) return false;
207 }
208 }
209}
210
211} // namespace internal
212
213string ProtoDebugString(
214 const ::tensorflow::ResourceHandleProto& msg) {
215 string s;
216 ::tensorflow::strings::ProtoTextOutput o(&s, false);
217 internal::AppendProtoDebugString(&o, msg);
218 o.CloseTopMessage();
219 return s;
220}
221
222string ProtoShortDebugString(
223 const ::tensorflow::ResourceHandleProto& msg) {
224 string s;
225 ::tensorflow::strings::ProtoTextOutput o(&s, true);
226 internal::AppendProtoDebugString(&o, msg);
227 o.CloseTopMessage();
228 return s;
229}
230
231namespace internal {
232
233void AppendProtoDebugString(
234 ::tensorflow::strings::ProtoTextOutput* o,
235 const ::tensorflow::ResourceHandleProto& msg) {
236 o->AppendStringIfNotEmpty("device", ProtobufStringToString(msg.device()));
237 o->AppendStringIfNotEmpty("container", ProtobufStringToString(msg.container()));
238 o->AppendStringIfNotEmpty("name", ProtobufStringToString(msg.name()));
239 o->AppendNumericIfNotZero("hash_code", msg.hash_code());
240 o->AppendStringIfNotEmpty("maybe_type_name", ProtobufStringToString(msg.maybe_type_name()));
241 for (int i = 0; i < msg.dtypes_and_shapes_size(); ++i) {
242 o->OpenNestedMessage("dtypes_and_shapes");
243 ::tensorflow::internal::AppendProtoDebugString(o, msg.dtypes_and_shapes(i));
244 o->CloseNestedMessage();
245 }
246}
247
248} // namespace internal
249
250bool ProtoParseFromString(
251 const string& s,
252 ::tensorflow::ResourceHandleProto* msg) {
253 msg->Clear();
254 Scanner scanner(s);
255 if (!internal::ProtoParseFromScanner(&scanner, false, false, msg)) return false;
256 scanner.Eos();
257 return scanner.GetResult();
258}
259
260namespace internal {
261
262bool ProtoParseFromScanner(
263 ::tensorflow::strings::Scanner* scanner, bool nested, bool close_curly,
264 ::tensorflow::ResourceHandleProto* msg) {
265 std::vector<bool> has_seen(6, false);
266 while(true) {
267 ProtoSpaceAndComments(scanner);
268 if (nested && (scanner->Peek() == (close_curly ? '}' : '>'))) {
269 scanner->One(Scanner::ALL);
270 ProtoSpaceAndComments(scanner);
271 return true;
272 }
273 if (!nested && scanner->empty()) { return true; }
274 scanner->RestartCapture()
275 .Many(Scanner::LETTER_DIGIT_UNDERSCORE)
276 .StopCapture();
277 StringPiece identifier;
278 if (!scanner->GetResult(nullptr, &identifier)) return false;
279 bool parsed_colon = false;
280 (void)parsed_colon;
281 ProtoSpaceAndComments(scanner);
282 if (scanner->Peek() == ':') {
283 parsed_colon = true;
284 scanner->One(Scanner::ALL);
285 ProtoSpaceAndComments(scanner);
286 }
287 if (identifier == "device") {
288 if (has_seen[0]) return false;
289 has_seen[0] = true;
290 string str_value;
291 if (!parsed_colon || !::tensorflow::strings::ProtoParseStringLiteralFromScanner(
292 scanner, &str_value)) return false;
293 SetProtobufStringSwapAllowed(&str_value, msg->mutable_device());
294 }
295 else if (identifier == "container") {
296 if (has_seen[1]) return false;
297 has_seen[1] = true;
298 string str_value;
299 if (!parsed_colon || !::tensorflow::strings::ProtoParseStringLiteralFromScanner(
300 scanner, &str_value)) return false;
301 SetProtobufStringSwapAllowed(&str_value, msg->mutable_container());
302 }
303 else if (identifier == "name") {
304 if (has_seen[2]) return false;
305 has_seen[2] = true;
306 string str_value;
307 if (!parsed_colon || !::tensorflow::strings::ProtoParseStringLiteralFromScanner(
308 scanner, &str_value)) return false;
309 SetProtobufStringSwapAllowed(&str_value, msg->mutable_name());
310 }
311 else if (identifier == "hash_code") {
312 if (has_seen[3]) return false;
313 has_seen[3] = true;
314 uint64 value;
315 if (!parsed_colon || !::tensorflow::strings::ProtoParseNumericFromScanner(scanner, &value)) return false;
316 msg->set_hash_code(value);
317 }
318 else if (identifier == "maybe_type_name") {
319 if (has_seen[4]) return false;
320 has_seen[4] = true;
321 string str_value;
322 if (!parsed_colon || !::tensorflow::strings::ProtoParseStringLiteralFromScanner(
323 scanner, &str_value)) return false;
324 SetProtobufStringSwapAllowed(&str_value, msg->mutable_maybe_type_name());
325 }
326 else if (identifier == "dtypes_and_shapes") {
327 const bool is_list = (scanner->Peek() == '[');
328 do {
329 if (is_list) {
330 scanner->One(Scanner::ALL);
331 ProtoSpaceAndComments(scanner);
332 }
333 const char open_char = scanner->Peek();
334 if (open_char != '{' && open_char != '<') return false;
335 scanner->One(Scanner::ALL);
336 ProtoSpaceAndComments(scanner);
337 if (!::tensorflow::internal::ProtoParseFromScanner(
338 scanner, true, open_char == '{', msg->add_dtypes_and_shapes())) return false;
339 } while (is_list && scanner->Peek() == ',');
340 if (is_list && !scanner->OneLiteral("]").GetResult()) return false;
341 }
342 }
343}
344
345} // namespace internal
346
347} // namespace tensorflow
348