本文整理汇总了C++中Importer::Import方法的典型用法代码示例。如果您正苦于以下问题:C++ Importer::Import方法的具体用法?C++ Importer::Import怎么用?C++ Importer::Import使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Importer
的用法示例。
在下文中一共展示了Importer::Import方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: register_protobuf_file
void register_protobuf_file(string filePath, string fileName, int proto_hadoop)
{
if ( g_listPBFile.end() != find(g_listPBFile.begin(), g_listPBFile.end(), filePath + fileName ) )
{
return;
}
g_listPBFile.push_back( filePath + fileName );
DiskSourceTree sourceTree;
sourceTree.MapPath("", filePath);
// keep the Descriptor data in memory
Importer* importer = new Importer(&sourceTree, NULL);
const FileDescriptor* file = NULL;
file = importer->Import(fileName);
if (NULL == file)
{
return;
}
// recursive parse import file
for (int iDependencyIndex = 0; iDependencyIndex < file->dependency_count(); iDependencyIndex++)
{
const FileDescriptor* dependencyFile = NULL;
dependencyFile = file->dependency(iDependencyIndex);
if (NULL == dependencyFile)
{
return;
}
register_protobuf_file(filePath, dependencyFile->name(), proto_hadoop);
}
// parse message
for (int iMsgIndex = 0; iMsgIndex < file->message_type_count(); iMsgIndex++)
{
const Descriptor* message = file->message_type(iMsgIndex);
register_protobuf_message(message, proto_hadoop);
}
// parse service
for (int iServiceIndex = 0; iServiceIndex < file->service_count(); iServiceIndex++)
{
const ServiceDescriptor* service = file->service(iServiceIndex);
for (int iMethodIndex = 0; iMethodIndex < service->method_count(); iMethodIndex++)
{
const MethodDescriptor* method = service->method(iMethodIndex);
MethodInfo methodInfo;
methodInfo.methodParamType = method->input_type()->full_name();
methodInfo.methodReturnType = method->output_type()->full_name();
g_mapMethod.insert(pair<string, MethodInfo>(method->name(), methodInfo));
}
} // end parse service
}