在C++中一个文件描述符协议中,FileDescriptor
接口具有一种方法DebugString()
其格式描述符的内容在.proto
语法 - 即完全wha你想要。为了使用它,首先需要编写代码,使用DescriptorPool
接口将原始FileDescriptorProto
转换为FileDescriptor
。
像这样的东西应该这样做:
#include <google/protobuf/descriptor.h>
#include <google/protobuf/descriptor.pb.h>
#include <iostream>
int main() {
google::protobuf::FileDescriptorProto fileProto;
fileProto.ParseFromFileDescriptor(0);
google::protobuf::DescriptorPool pool;
const google::protobuf::FileDescriptor* desc =
pool.BuildFile(fileProto);
std::cout << desc->DebugString() << std::endl;
return 0;
}
你需要养活这个程序FileDescriptorProto,您可以通过使用Java您的字符串编码使用ISO-8859-字节得到的原始字节1个字符集。
另请注意,如果文件导入任何其他文件,则上述操作不起作用 - 您必须首先将这些导入装入DescriptorPool
。
我一定会尝试一下。如果我找到一个工具,我会报告。如果不是,我/我会自己做,但不会很快... – OGP