当前位置: 首页>>代码示例>>C++>>正文


C++ Datum::isList方法代码示例

本文整理汇总了C++中Datum::isList方法的典型用法代码示例。如果您正苦于以下问题:C++ Datum::isList方法的具体用法?C++ Datum::isList怎么用?C++ Datum::isList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Datum的用法示例。


在下文中一共展示了Datum::isList方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: unpackageExperiment

bool ExperimentUnpackager::unpackageExperiment(Datum payload) {
	
	namespace bf = boost::filesystem;
	
    if(payload.getDataType() != M_DICTIONARY) {
        merror(M_NETWORK_MESSAGE_DOMAIN,
			   "Invalid payload type for experiment package");
        return false;
    }
	
 Datum experimentFilePackage = 
							payload.getElement(M_PACKAGER_EXPERIMENT_STRING);

	if(experimentFilePackage.getNElements() != 
							M_EXPERIMENT_PACKAGE_NUMBER_ELEMENTS_PER_UNIT || 
	   experimentFilePackage.getDataType() != M_DICTIONARY) 
		return false;
	
 Datum experimentFileName = 
				experimentFilePackage.getElement(M_PACKAGER_FILENAME_STRING);
	if(experimentFileName.getDataType() != M_STRING || 
	   experimentFileName.getString().empty())
		return false;
	
	bf::path experimentName(experimentFileName.getString());
	
	loadedExperimentFilename = prependExperimentInstallPath(removeFileExtension(experimentName.string()),
								experimentName.string());
	
	bf::path experimentPath = loadedExperimentFilename.branch_path();
	
	createExperimentInstallDirectoryStructure(experimentName.string());
	
	
	// create the XML file
 Datum experimentFileBuffer = 
		experimentFilePackage.getElement(M_PACKAGER_CONTENTS_STRING);
	
	if(experimentFileBuffer.getDataType() != M_STRING ||
	   experimentFileBuffer.getString().empty())
		return false;
	
	if(!(createFile(Datum(loadedExperimentFilename.string().c_str()), 
					experimentFileBuffer))) {
        // failed to create experiment file
        merror(M_FILE_MESSAGE_DOMAIN,
			   "Failed to create server side experiment file %s", 
			   loadedExperimentFilename.string().c_str());
        return false;
    }
	
	// create all of the other media files
 Datum mediaFileList = payload.getElement(M_PACKAGER_MEDIA_BUFFERS_STRING);
	
	if(mediaFileList.isList()) {
	
		for(int i=0; i<mediaFileList.getNElements(); ++i) {
		 Datum mediaFilePackage = mediaFileList.getElement(i);
		
			if(mediaFilePackage.getDataType() != M_DICTIONARY |
			   mediaFilePackage.getNElements() != 2) {
				merror(M_FILE_MESSAGE_DOMAIN,
					   "incorrectly packaged media files");
				return false;
			}
		
		 Datum mediaFileName = 
						mediaFilePackage.getElement(M_PACKAGER_FILENAME_STRING);
		 Datum mediaFileBuffer = 
						mediaFilePackage.getElement(M_PACKAGER_CONTENTS_STRING);
		
			if(mediaFileName.getDataType() != M_STRING ||
			   mediaFileName.getString().empty() ||
			   mediaFileBuffer.getDataType() != M_STRING) return false;
		
			std::string filename(mediaFileName.getString());
			std::string filenameWPath = experimentPath.string() + "/" + filename;
		
			if(!(createFile(Datum(filenameWPath.c_str()), 
							mediaFileBuffer))) {
				// failed to create experiment file
				merror(M_FILE_MESSAGE_DOMAIN,
					   "Failed to create server side experiment file %s", 
					   filenameWPath.c_str());
				return false;
			}
		}
	}
	
	expandRangeReplicatorItems(loadedExperimentFilename);
	modifyExperimentMediaPaths(loadedExperimentFilename);
	
    return true;
}
开发者ID:mworks,项目名称:mworks,代码行数:94,代码来源:ExperimentUnpackager.cpp


注:本文中的Datum::isList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。