在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