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


C++ Filename::string方法代码示例

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


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

示例1:

void Compartment_Report_HDF5_File_Reader::open_data_set
(Cell_GID cell_ID, const char * dataset_name, H5ID & file, H5ID & dataset) const
{
    // Opening file for current cell
    std::string cell_name = "a" + boost::lexical_cast<std::string>(cell_ID);
    Filename filename = _path / (cell_name + ".h5");

    file.reset(H5Fopen(filename.string().c_str(), H5F_ACC_RDONLY, H5P_DEFAULT),
               H5Fclose);
    if (!file)
    {
        throw_exception(
            File_Open_Error("Compartment_Report_HDF5_File_Reader: error "
                            "opening file:" + filename.string()),
            FATAL_LEVEL, __FILE__, __LINE__);
    }

    // Opening the dataset
    std::string dataset_full_name = 
        "/" + cell_name + "/" + (_report_name + "/") + dataset_name;
    H5E_BEGIN_TRY
        dataset.reset(H5Dopen(file, dataset_full_name.c_str()), H5Dclose);
    H5E_END_TRY;
    if (!dataset)
    {
        throw_exception(
            File_Parse_Error("Compartment_Report_HDF5_File_Reader: "
                             "Dataset " + dataset_full_name + " not found "
                             "in file: " + filename.string()),
            FATAL_LEVEL, __FILE__, __LINE__);
    }
}
开发者ID:yonggang985,项目名称:Touch,代码行数:32,代码来源:Compartment_Report_HDF5_File_Reader.cpp

示例2: write_mesh

void Mesh_Binary_File_Writer::write_mesh(
    const Filename        & file,
    Mesh                  & mesh
)
{
    std::ofstream datastream((char*)file.string().c_str(), std::ios::binary);

    if (!datastream)
    {
        throw_exception(
            IO_Error("Mesh_Binary_File_Writer: cannot create "
                     "binary file: " + file.string()),
            WARNING_LEVEL, __FILE__, __LINE__);
    }
    
    // write header infos for the current mesh
    Vertex_Index vertex_count = mesh.vertex_count();
    Triangle_Index triangle_count = mesh.triangle_count();
    Triangle_Index triangle_strip_length = mesh.triangle_strip_length();
    datastream.write((char*)&vertex_count, sizeof(Vertex_Index));
    datastream.write((char*)&triangle_count, sizeof(Triangle_Index));
    datastream.write((char*)&triangle_strip_length, sizeof(Triangle_Index));
    
    // write the vertices data
    datastream.write((char*)mesh.vertices().pointer(),
                     vertex_count * 3 * sizeof(Micron));
    datastream.write((char*)mesh.vertex_sections().pointer(),
                     vertex_count * sizeof(Section_ID));
    datastream.write((char*)mesh.vertex_relative_distances().pointer(), 
                     vertex_count * sizeof(float));
    
    // write the triangles data
    datastream.write((char*)mesh.triangles().pointer(), 
                     triangle_count * 3 * sizeof(Vertex_Index));
    datastream.write((char*)mesh.triangle_strip().pointer(), 
                     triangle_strip_length * sizeof(Vertex_Index));
}
开发者ID:yonggang985,项目名称:Touch,代码行数:37,代码来源:Mesh_Binary_File_Writer.cpp

示例3: open

void Compartment_Voltage_Voxel_Average::open(Filename mapping_filename,
                                             bool portable_format)
{
    std::ifstream file(mapping_filename.string().c_str());
	
	if (file.is_open() == false)
	{
		std::cerr << "Volume compartment mapping file could not be opened (" 
			<< mapping_filename << ")" << std::endl;
		throw std::runtime_error( std::string("Volume compartment mapping file"
			" could not be opened (") 
			+ mapping_filename.string() + ")");
	}

    if (portable_format)
    {
        boost::archive::text_iarchive ia(file);
	    std::cout << "Volume Compartment Mapping: reading from portable text"
            "file (" << mapping_filename.string()  << ")" << std::endl;
        ia >> * this;
	    std::cout << "Volume Compartment Mapping: in memory" << std::endl;
    }
    else
    {
开发者ID:yonggang985,项目名称:Touch,代码行数:24,代码来源:Compartment_Voltage_Voxel_Average.cpp


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