| Joe Onorato | 6c9547d | 2016-09-07 18:43:49 -0700 | [diff] [blame] | 1 | #include <stdio.h> |
| Pablo Gamito | 6ca20ea | 2024-02-06 17:04:21 +0000 | [diff] [blame] | 2 | |
| Joe Onorato | 6c9547d | 2016-09-07 18:43:49 -0700 | [diff] [blame] | 3 | #include <iomanip> |
| 4 | #include <iostream> |
| Joe Onorato | 6c9547d | 2016-09-07 18:43:49 -0700 | [diff] [blame] | 5 | #include <map> |
| Pablo Gamito | 6ca20ea | 2024-02-06 17:04:21 +0000 | [diff] [blame] | 6 | #include <sstream> |
| 7 | #include <string> |
| 8 | |
| 9 | #include "Errors.h" |
| 10 | #include "java_proto_stream_code_generator.h" |
| 11 | #include "stream_proto_utils.h" |
| Joe Onorato | 6c9547d | 2016-09-07 18:43:49 -0700 | [diff] [blame] | 12 | |
| Yi Jin | 0473f88b | 2017-10-09 11:21:40 -0700 | [diff] [blame] | 13 | using namespace android::stream_proto; |
| Joe Onorato | 6c9547d | 2016-09-07 18:43:49 -0700 | [diff] [blame] | 14 | using namespace google::protobuf::io; |
| 15 | using namespace std; |
| 16 | |
| Joe Onorato | 6c9547d | 2016-09-07 18:43:49 -0700 | [diff] [blame] | 17 | /** |
| Joe Onorato | b38ac0b | 2016-10-28 13:10:25 -0700 | [diff] [blame] | 18 | * |
| Joe Onorato | 6c9547d | 2016-09-07 18:43:49 -0700 | [diff] [blame] | 19 | * Main. |
| 20 | */ |
| 21 | int |
| 22 | main(int argc, char const*const* argv) |
| 23 | { |
| 24 | (void)argc; |
| 25 | (void)argv; |
| 26 | |
| 27 | GOOGLE_PROTOBUF_VERIFY_VERSION; |
| 28 | |
| Joe Onorato | 6c9547d | 2016-09-07 18:43:49 -0700 | [diff] [blame] | 29 | // Read the request |
| Pablo Gamito | 6ca20ea | 2024-02-06 17:04:21 +0000 | [diff] [blame] | 30 | CodeGeneratorRequest request; |
| Joe Onorato | 6c9547d | 2016-09-07 18:43:49 -0700 | [diff] [blame] | 31 | request.ParseFromIstream(&cin); |
| 32 | |
| Pablo Gamito | 6ca20ea | 2024-02-06 17:04:21 +0000 | [diff] [blame] | 33 | CodeGeneratorResponse response = generate_java_protostream_code(request); |
| Joe Onorato | 6c9547d | 2016-09-07 18:43:49 -0700 | [diff] [blame] | 34 | |
| 35 | // If we had errors, don't write the response. Print the errors and exit. |
| 36 | if (ERRORS.HasErrors()) { |
| 37 | ERRORS.Print(); |
| 38 | return 1; |
| 39 | } |
| 40 | |
| 41 | // If we didn't have errors, write the response and exit happily. |
| 42 | response.SerializeToOstream(&cout); |
| 43 | return 0; |
| 44 | } |