-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfoo_main.cc
More file actions
33 lines (31 loc) · 856 Bytes
/
foo_main.cc
File metadata and controls
33 lines (31 loc) · 856 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <gz/msgs/Factory.hh>
#include <google/protobuf/text_format.h>
int main(int argc, char** argv)
{
if (argc == 1)
{
std::vector<std::string> known_types;
gz::msgs::Factory::Types(known_types);
std::cout << "Known types: " << std::endl;
for (const auto &t: known_types)
{
std::cout << t << std::endl;
}
}
else
{
gz::msgs::Factory::MessagePtr msg = gz::msgs::Factory::New(argv[1]);
if (msg)
{
auto descriptor = msg->GetDescriptor();
auto fileDescriptor = descriptor->file();
std::cout << "Name: " << descriptor->full_name() << std::endl;
std::cout << "File: " << fileDescriptor->name() << std::endl << std::endl;
std::cout << descriptor->DebugString() << std::endl;
}
else
{
std::cout << "Couldn't find msg: " << argv[1] << std::endl;;
}
}
}