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


C++ HOFFSET函数代码示例

本文整理汇总了C++中HOFFSET函数的典型用法代码示例。如果您正苦于以下问题:C++ HOFFSET函数的具体用法?C++ HOFFSET怎么用?C++ HOFFSET使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: create_symbol_datatype

/*-------------------------------------------------------------------------
 * Function:    create_symbol_datatype
 *
 * Purpose:     Create's the HDF5 datatype used for elements in the SWMR
 *              testing datasets.
 *
 * Parameters:  N/A
 *
 * Return:      Success:    An HDF5 type ID
 *              Failure:    -1
 *
 *-------------------------------------------------------------------------
 */
hid_t
create_symbol_datatype(void)
{
    hid_t sym_type_id;          /* Datatype ID for symbol */
    hid_t opaq_type_id;         /* Datatype ID for opaque part of record */

    /* Create opaque datatype to represent other information for this record */
    if((opaq_type_id = H5Tcreate(H5T_OPAQUE, (size_t)DTYPE_SIZE)) < 0)
        return -1;

    /* Create compound datatype for symbol */
    if((sym_type_id = H5Tcreate(H5T_COMPOUND, sizeof(symbol_t))) < 0)
        return -1;

    /* Insert fields in symbol datatype */
    if(H5Tinsert(sym_type_id, "rec_id", HOFFSET(symbol_t, rec_id), H5T_NATIVE_UINT64) < 0)
        return -1;
    if(H5Tinsert(sym_type_id, "info", HOFFSET(symbol_t, info), opaq_type_id) < 0)
        return -1;

    /* Close opaque datatype */
    if(H5Tclose(opaq_type_id) < 0)
        return -1;

    return sym_type_id;
} /* end create_symbol_datatype() */
开发者ID:FilipeMaia,项目名称:hdf5,代码行数:39,代码来源:swmr_common.c

示例2: create_ieee_complex256

/* Counterpart for complex256 */
hid_t create_ieee_complex256(const char *byteorder) {
  herr_t err = 0;
  hid_t float_id, complex_id;
  H5T_order_t h5order = H5Tget_order(H5T_NATIVE_LDOUBLE);

  complex_id = H5Tcreate(H5T_COMPOUND, sizeof(npy_complex256));
  float_id = H5Tcopy(H5T_NATIVE_LDOUBLE);
  if (float_id < 0)
  {
    H5Tclose(complex_id);
    return float_id;
  }

  if ((strcmp(byteorder, "little") == 0) && (h5order != H5T_ORDER_LE))
    err = H5Tset_order(float_id, H5T_ORDER_LE);
  else if ((strcmp(byteorder, "big") == 0) && (h5order != H5T_ORDER_BE))
    err = H5Tset_order(float_id, H5T_ORDER_BE);

  if (err < 0)
  {
    H5Tclose(complex_id);
    return err;
  }

  H5Tinsert(complex_id, "r", HOFFSET(npy_complex256, real), float_id);
  H5Tinsert(complex_id, "i", HOFFSET(npy_complex256, imag), float_id);
  H5Tclose(float_id);
  return complex_id;
}
开发者ID:bbudescu,项目名称:PyTables,代码行数:30,代码来源:utils.c

示例3: make_particle_type

/*-------------------------------------------------------------------------
 * function to create a datatype representing the particle struct
 *-------------------------------------------------------------------------
 */
static hid_t
make_particle_type(void)
{
    hid_t type_id;
    hid_t string_type;
    size_t type_size = sizeof(particle_t);

    /* Create the memory data type. */
    if ((type_id = H5Tcreate (H5T_COMPOUND, type_size )) < 0 )
        return -1;

    /* Insert fields. */
    string_type = H5Tcopy( H5T_C_S1 );
    H5Tset_size( string_type, (size_t)16 );

    if ( H5Tinsert(type_id, "Name", HOFFSET(particle_t, name) , string_type ) < 0 )
        return -1;
    if ( H5Tinsert(type_id, "Lat", HOFFSET(particle_t, lati) , H5T_NATIVE_INT ) < 0 )
        return -1;
    if ( H5Tinsert(type_id, "Long", HOFFSET(particle_t, longi) , H5T_NATIVE_INT ) < 0 )
        return -1;
    if ( H5Tinsert(type_id, "Pressure", HOFFSET(particle_t, pressure) , H5T_NATIVE_FLOAT ) < 0 )
        return -1;
    if ( H5Tinsert(type_id, "Temperature", HOFFSET(particle_t, temperature) , H5T_NATIVE_DOUBLE ) < 0 )
        return -1;

    return type_id;
}
开发者ID:quinoacomputing,项目名称:HDF5,代码行数:32,代码来源:test_packet.c

示例4: hdf5

    /** Creates a HDF5 type identifier for the [kmer,abundance] structure. This type will be used
     * for dumping Count instances in a HDF5 file (like SortingCount algorithm does).
     * \param[in] isCompound : tells whether the structure is compound (SHOULD BE OBSOLETE IN THE FUTURE)
     * \return the HDF5 identifier for the type. */
    static hid_t hdf5 (bool& isCompound)
    {
        hid_t abundanceType = H5T_NATIVE_UINT16;

        if (sizeof(Number)==1) {
            abundanceType = H5T_NATIVE_UINT8;
        }
        else if (sizeof(Number)==2) {
            abundanceType = H5T_NATIVE_UINT16;
        }
        else if (sizeof(Number)==4) {
            abundanceType = H5T_NATIVE_UINT32;
        }
        else if (sizeof(Number)==8) {
            abundanceType = H5T_NATIVE_UINT64;
        }
        else {
            throw "Bad type size for Abundance HDF5 serialization";
        }

        hid_t result = H5Tcreate (H5T_COMPOUND, sizeof(Abundance));
        H5Tinsert (result, "value",      HOFFSET(Abundance, value),     Type::hdf5(isCompound));
        H5Tinsert (result, "abundance",  HOFFSET(Abundance, abundance), abundanceType);

        isCompound = true;

        return result;
    }
开发者ID:cdeltel,项目名称:gatb-core-mirrored,代码行数:32,代码来源:Abundance.hpp

示例5: gent_compound

/*-------------------------------------------------------------------------
 * Function:    gent_compound
 *
 * Purpose:     Generate a compound dataset in LOC_ID
 *
 *-------------------------------------------------------------------------
 */
static void gent_compound(hid_t loc_id)
{
    typedef struct s_t
    {
        char str1[20];
        char str2[20];
    } s_t;
    hid_t   sid, did, tid_c, tid_s;
    hsize_t dims[1] = {2};
    s_t     buf[2]  = {{"str1", "str2"}, {"str3", "str4"}};

    /* create dataspace */
    sid = H5Screate_simple(1, dims, NULL);

    /* create a compound type */
    tid_c = H5Tcreate(H5T_COMPOUND, sizeof(s_t));
    tid_s = H5Tcopy(H5T_C_S1);
    H5Tset_size(tid_s, 20);

    H5Tinsert(tid_c, "str1", HOFFSET(s_t,str1), tid_s);
    H5Tinsert(tid_c, "str2", HOFFSET(s_t,str2), tid_s);

    /* create dataset */
    did = H5Dcreate2(loc_id, DATASET_COMPOUND, tid_c, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);

    /* write */
    H5Dwrite(did, tid_c, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf);

    /* close */
    H5Sclose(sid);
    H5Dclose(did);
    H5Tclose(tid_c);
    H5Tclose(tid_s);
}
开发者ID:Hulalazz,项目名称:rnnlib,代码行数:41,代码来源:h5copygentest.c

示例6: main

int main(int argc, char *argv[])
{
    hdf_sa_t arr[LEN];
    initArr(arr, LEN);

    // create data type corresponding to compound struct
    hid_t cid = H5Tcreate(H5T_COMPOUND, sizeof(hdf_sa_t));
    H5Tinsert(cid, "a", HOFFSET(hdf_sa_t, a), H5T_NATIVE_INT);
    H5Tinsert(cid, "b", HOFFSET(hdf_sa_t, b), H5T_NATIVE_FLOAT);
    H5Tinsert(cid, "c", HOFFSET(hdf_sa_t, c), H5T_NATIVE_DOUBLE);

    // write data to file
    hid_t fid = H5Fcreate("compound.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);

    // create data space
    hsize_t dim[1] = {LEN};
    hid_t space = H5Screate_simple(1, dim, NULL);
    hid_t dataset = H5Dcreate(fid, "compound", cid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);

    // write data 
    H5Dwrite(dataset, cid, H5S_ALL, H5S_ALL, H5P_DEFAULT, arr);

    H5Sclose(space);
    H5Dclose(dataset);
    H5Fclose(fid);

    return 0;
}
开发者ID:wxm71,项目名称:todo,代码行数:28,代码来源:compound.c

示例7: sizeof

void pyne::Material::_load_comp_protocol1(H5::H5File * db, std::string datapath, int row)
{
  H5::DataSet data_set = (*db).openDataSet(datapath);

  hsize_t data_offset[1] = {row};
  if (row < 0)
  {
    // Handle negative row indecies
    H5::DataSpace data_space = data_set.getSpace();
    hsize_t data_dims[1];
    int data_rank = data_space.getSimpleExtentDims(data_dims);
    data_offset[0] += data_dims[0];
  };

  // Grab the nucpath
  std::string nucpath;
  H5::Attribute nuc_attr = data_set.openAttribute("nucpath");
  hsize_t nuc_attr_len = nuc_attr.getStorageSize() / sizeof(char);
  H5::StrType nuc_attr_type(0, nuc_attr_len);
  nuc_attr.read(nuc_attr_type, nucpath);

  // Grab the nuclides
  std::vector<int> nuclides = h5wrap::h5_array_to_cpp_vector_1d<int>(db, nucpath, H5::PredType::NATIVE_INT);
  int nuc_size = nuclides.size();
  hsize_t nuc_dims[1] = {nuc_size};

  // Get the data hyperslab
  H5::DataSpace data_hyperslab = data_set.getSpace();
  hsize_t data_count[1] = {1};
  data_hyperslab.selectHyperslab(H5S_SELECT_SET, data_count, data_offset);

  // Get memory space for writing
  H5::DataSpace mem_space (1, data_count);

  // Get material type
  size_t material_struct_size = sizeof(pyne::material_struct) + sizeof(double)*(nuc_size);
  H5::CompType data_desc(material_struct_size);
  H5::ArrayType comp_values_array_type (H5::PredType::NATIVE_DOUBLE, 1, nuc_dims);

  // make the data table type
  data_desc.insertMember("name", HOFFSET(pyne::material_struct, name), H5::StrType(0, 20));
  data_desc.insertMember("mass", HOFFSET(pyne::material_struct, mass), H5::PredType::NATIVE_DOUBLE);
  data_desc.insertMember("atoms_per_mol", HOFFSET(pyne::material_struct, atoms_per_mol), H5::PredType::NATIVE_DOUBLE);
  data_desc.insertMember("comp", HOFFSET(pyne::material_struct, comp), comp_values_array_type);

  // make the data array, have to over-allocate
  material_struct * mat_data = (material_struct *) malloc(material_struct_size);

  // Finally, get data and put in on this instance
  data_set.read(mat_data, data_desc, mem_space, data_hyperslab);

  name = std::string((*mat_data).name);
  mass = (*mat_data).mass;
  atoms_per_mol = (*mat_data).atoms_per_mol;
  for (int i = 0; i < nuc_size; i++)
    comp[nuclides[i]] = (double) (*mat_data).comp[i];

  free(mat_data);
};
开发者ID:chrisdembia,项目名称:pyne,代码行数:59,代码来源:material.cpp

示例8: hdf5

 inline static hid_t hdf5 (bool& compound)
 {
     hid_t result = H5Tcreate (H5T_COMPOUND, sizeof(Entry));
     H5Tinsert (result, "index",      HOFFSET(Entry, index),     H5T_NATIVE_UINT16);
     H5Tinsert (result, "abundance",  HOFFSET(Entry, abundance), H5T_NATIVE_UINT64);
     compound = true;
     return result;
 }
开发者ID:zy26,项目名称:gatb-core,代码行数:8,代码来源:IHistogram.hpp

示例9: require_group

void NSDFWriter::createEventMap()
{
    herr_t status;    
    hid_t eventMapContainer = require_group(filehandle_, MAPEVENTSRC);
    // Open the container for the event maps
    // Create the Datasets themselves (one for each field - each row
    // for one object).
    for (map< string, vector < string > >::iterator ii = classFieldToEventSrc_.begin();
         ii != classFieldToEventSrc_.end();
         ++ii){
        vector < string > pathTokens;
        tokenize(ii->first, "/", pathTokens);
        string className = pathTokens[0];
        string fieldName = pathTokens[1];
        hid_t classGroup = require_group(eventMapContainer, className);
        hid_t strtype = H5Tcopy(H5T_C_S1);
        status = H5Tset_size(strtype, H5T_VARIABLE);
        // create file space
        hid_t ftype = H5Tcreate(H5T_COMPOUND, sizeof(hvl_t) +sizeof(hobj_ref_t));
        status = H5Tinsert(ftype, "source", 0, strtype);
        status = H5Tinsert(ftype, "data", sizeof(hvl_t), H5T_STD_REF_OBJ);
        hsize_t dims[1] = {ii->second.size()};
        hid_t space = H5Screate_simple(1, dims, NULL);
        // The dataset for mapping is named after the field
        hid_t ds = H5Dcreate2(classGroup, fieldName.c_str(), ftype, space,
                              H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
        status = H5Sclose(space);
        map_type * buf = (map_type*)calloc(ii->second.size(), sizeof(map_type));
        // Populate the buffer entries with source uid and data
        // reference
        for (unsigned int jj = 0; jj < ii->second.size(); ++jj){
            buf->source = ii->second[jj].c_str();
            char * dsname = (char*)calloc(256, sizeof(char));
            ssize_t size = H5Iget_name(classFieldToEvent_[ii->first][jj], dsname, 255);
            if (size > 255){
                free(dsname);
                dsname = (char*)calloc(size, sizeof(char));
                size = H5Iget_name(classFieldToEvent_[ii->first][jj], dsname, 255);
            }
            status = H5Rcreate(&(buf->data), filehandle_, dsname, H5R_OBJECT, -1);
            free(dsname);
            assert(status >= 0);            
        }
        // create memory space
        hid_t memtype = H5Tcreate(H5T_COMPOUND, sizeof(map_type));
        status = H5Tinsert(memtype, "source",
                           HOFFSET(map_type, source), strtype);
        status = H5Tinsert(memtype, "data",
                           HOFFSET(map_type, data), H5T_STD_REF_OBJ);
        status = H5Dwrite(ds, memtype,  H5S_ALL, H5S_ALL, H5P_DEFAULT, buf);
        free(buf);
        status = H5Tclose(strtype);
        status = H5Tclose(ftype);
        status = H5Tclose(memtype);
        status = H5Dclose(ds);
    }
}
开发者ID:asiaszmek,项目名称:moose-core,代码行数:57,代码来源:NSDFWriter.cpp

示例10: arma_H5Tcreate

inline
hid_t
get_hdf5_type< std::complex<double> >()
  {
  hid_t type = arma_H5Tcreate(H5T_COMPOUND, sizeof(hdf5_complex_t<double>));

  arma_H5Tinsert(type, "real", HOFFSET(hdf5_complex_t<double>, real), arma_H5T_NATIVE_DOUBLE);
  arma_H5Tinsert(type, "imag", HOFFSET(hdf5_complex_t<double>, imag), arma_H5T_NATIVE_DOUBLE);

  return type;
  }
开发者ID:RcppCore,项目名称:RcppArmadillo,代码行数:11,代码来源:hdf5_misc.hpp

示例11: H5Tcreate

inline
hid_t
get_hdf5_type< std::complex<float> >()
  {
  hid_t type = H5Tcreate(H5T_COMPOUND, sizeof(hdf5_complex_t<float>));
  
  H5Tinsert(type, "real", HOFFSET(hdf5_complex_t<float>, real), H5T_NATIVE_FLOAT);
  H5Tinsert(type, "imag", HOFFSET(hdf5_complex_t<float>, imag), H5T_NATIVE_FLOAT);
  
  return type;
  }
开发者ID:ELEN4002-Lab-Project-2012,项目名称:ELEN4002-Lab-Project,代码行数:11,代码来源:hdf5_misc.hpp

示例12: get_species_comp_type

 static H5::CompType get_species_comp_type()
 {
     H5::CompType h5_species_comp_type(sizeof(h5_species_struct));
     h5_species_comp_type.insertMember(
         std::string("id"), HOFFSET(h5_species_struct, id),
         H5::PredType::STD_I32LE);
     h5_species_comp_type.insertMember(
         std::string("serial"), HOFFSET(h5_species_struct, serial),
         H5::StrType(H5::PredType::C_S1, 32));
     return h5_species_comp_type;
 }
开发者ID:greatlse,项目名称:ecell4,代码行数:11,代码来源:ParticleSpaceHDF5Writer.hpp

示例13: get_particle_comp_type

 static H5::CompType get_particle_comp_type()
 {
     H5::CompType h5_particle_comp_type(sizeof(h5_particle_struct));
     h5_particle_comp_type.insertMember(
         std::string("lot"), HOFFSET(h5_particle_struct, lot),
         H5::PredType::NATIVE_INT);
     h5_particle_comp_type.insertMember(
         std::string("serial"), HOFFSET(h5_particle_struct, serial),
         H5::PredType::NATIVE_INT);
     h5_particle_comp_type.insertMember(
         std::string("sid"), HOFFSET(h5_particle_struct, sid),
         H5::PredType::STD_I32LE);
     h5_particle_comp_type.insertMember(
         std::string("posx"), HOFFSET(h5_particle_struct, posx),
         H5::PredType::NATIVE_DOUBLE);
     h5_particle_comp_type.insertMember(
         std::string("posy"), HOFFSET(h5_particle_struct, posy),
         H5::PredType::NATIVE_DOUBLE);
     h5_particle_comp_type.insertMember(
         std::string("posz"), HOFFSET(h5_particle_struct, posz),
         H5::PredType::NATIVE_DOUBLE);
     h5_particle_comp_type.insertMember(
         std::string("radius"), HOFFSET(h5_particle_struct, radius),
         H5::PredType::NATIVE_DOUBLE);
     h5_particle_comp_type.insertMember(
         std::string("D"), HOFFSET(h5_particle_struct, D),
         H5::PredType::NATIVE_DOUBLE);
     return h5_particle_comp_type;
 }
开发者ID:greatlse,项目名称:ecell4,代码行数:29,代码来源:ParticleSpaceHDF5Writer.hpp

示例14: write

void write(hid_t& file, std::vector<Region>& regions)
{
  const size_t record_size = sizeof(Region);

  size_t record_offset[] = { HOFFSET(Region, bam_file_key),
                             HOFFSET(Region, chromosome),
                             HOFFSET(Region, region_name),
                             HOFFSET(Region, start),
                             HOFFSET(Region, stop),
                             HOFFSET(Region, strand),
                             HOFFSET(Region, count),
                             HOFFSET(Region, normalized_count) };

  size_t field_sizes[] = { sizeof(Region::bam_file_key),
                           sizeof(Region::chromosome),
                           sizeof(Region::region_name),
                           sizeof(Region::start),
                           sizeof(Region::stop),
                           sizeof(Region::strand),
                           sizeof(Region::count),
                           sizeof(Region::normalized_count) };

  herr_t status = H5TBappend_records(file, "region_counts", regions.size(), record_size, record_offset,
                                     field_sizes, regions.data());
  if (status != 0)
  {
    std::stringstream ss;
    ss << "Error appending record, status = " << status;
    throw std::runtime_error(ss.str());
  }
}
开发者ID:BoulderLabs,项目名称:pipeline,代码行数:31,代码来源:bamliquidator_regions.m.cpp

示例15: linkDatatype

hid_t linkDatatype()
{
	hid_t tLink;
	hid_t tPosition;
	hid_t tNumber;	
	
	tLink = H5Tcreate(H5T_COMPOUND, sizeof(link_t));
	tPosition = H5Tcopy(H5T_NATIVE_INT32);
	tNumber = H5Tcopy(H5T_NATIVE_INT32);
	H5Tinsert(tLink, "position", HOFFSET(link_t, position), tPosition);
	H5Tinsert(tLink, "number", HOFFSET(link_t, number), tNumber);
	H5Tclose(tPosition);
	H5Tclose(tNumber);
	return tLink;
}
开发者ID:hbredin,项目名称:pinocchIO,代码行数:15,代码来源:structure_utils.c


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