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


C++ Data_Reader类代码示例

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


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

示例1: load_

    blargg_err_t load_( Data_Reader& in )
    {
        int file_size = in.remain();
        if ( file_size <= h.size )
            return blargg_err_file_type;
        
        RETURN_ERR( in.read( &h, h.size ) );
        if ( !h.valid_tag() )
            return blargg_err_file_type;
        
        int gd3_offset = get_le32( h.gd3_offset ) - 0x2C;
        int remain = file_size - h.size - gd3_offset;
        byte gd3_h [gd3_header_size];
        if ( gd3_offset > 0 && remain >= gd3_header_size )
        {
            RETURN_ERR( in.skip( gd3_offset ) );
            RETURN_ERR( in.read( gd3_h, sizeof gd3_h ) );
            int gd3_size = check_gd3_header( gd3_h, remain );
            if ( gd3_size )
            {
                RETURN_ERR( gd3.resize( gd3_size ) );
                RETURN_ERR( in.read( gd3.begin(), gd3.size() ) );
            }
        }
        return blargg_ok;
    }
开发者ID:Gardenya,项目名称:deadbeef,代码行数:26,代码来源:Vgm_Emu.cpp

示例2: load_rom_data_

blargg_err_t Rom_Data_::load_rom_data_( Data_Reader& in,
        int header_size, void* header_out, int fill, long pad_size )
{
    long file_offset = pad_size - header_size;
    
    rom_addr = 0;
    mask     = 0;
    size_    = 0;
    rom.clear();
    
    file_size_ = in.remain();
    if ( file_size_ <= header_size ) // <= because there must be data after header
        return gme_wrong_file_type;
    blargg_err_t err = rom.resize( file_offset + file_size_ + pad_size );
    if ( !err )
        err = in.read( rom.begin() + file_offset, file_size_ );
    if ( err )
    {
        rom.clear();
        return err;
    }
    
    file_size_ -= header_size;
    memcpy( header_out, &rom [file_offset], header_size );
    
    memset( rom.begin()         , fill, pad_size );
    memset( rom.end() - pad_size, fill, pad_size );
    
    return 0;
}
开发者ID:MisterZeus,项目名称:SNES-Tracker,代码行数:30,代码来源:Classic_Emu.cpp

示例3: load_

    blargg_err_t load_( Data_Reader& in )
    {
        long file_size = in.remain();
        if ( file_size <= Vgm_Emu::header_size )
            return gme_wrong_file_type;
        
        RETURN_ERR( in.read( &h, Vgm_Emu::header_size ) );
        RETURN_ERR( check_vgm_header( h ) );
        
        long gd3_offset = get_le32( h.gd3_offset ) - 0x2C;
        long remain = file_size - Vgm_Emu::header_size - gd3_offset;
        byte gd3_h [gd3_header_size];
        if ( gd3_offset > 0 && remain >= gd3_header_size )
        {
            RETURN_ERR( in.skip( gd3_offset ) );
            RETURN_ERR( in.read( gd3_h, sizeof gd3_h ) );
            long gd3_size = check_gd3_header( gd3_h, remain );
            if ( gd3_size )
            {
                RETURN_ERR( gd3.resize( gd3_size ) );
                RETURN_ERR( in.read( gd3.begin(), gd3.size() ) );
            }
        }
        return 0;
    }
开发者ID:HipsterLion,项目名称:SRB2,代码行数:25,代码来源:Vgm_Emu.cpp

示例4: load_

    blargg_err_t load_( Data_Reader& in )
    {
        int file_size = in.remain();
        if ( file_size <= h.size_min )
            return blargg_err_file_type;
        
        RETURN_ERR( in.read( &h, h.size_min ) );
        if ( !h.valid_tag() )
            return blargg_err_file_type;

        if ( h.size() > h.size_min )
            RETURN_ERR( in.read( &h.rf5c68_rate, h.size() - h.size_min ) );

        h.cleanup();

        int data_offset = get_le32( h.data_offset ) + offsetof( Vgm_Core::header_t, data_offset );
        int data_size = file_size - offsetof( Vgm_Core::header_t, data_offset ) - data_offset;
        int gd3_offset = get_le32( h.gd3_offset );
        if ( gd3_offset > 0 )
            gd3_offset += offsetof( Vgm_Core::header_t, gd3_offset );

        int amount_to_skip = gd3_offset - h.size();

        if ( gd3_offset > 0 && gd3_offset > data_offset )
        {
            data_size = gd3_offset - data_offset;
            amount_to_skip = 0;

            RETURN_ERR( data.resize( data_size ) );
            RETURN_ERR( in.skip( data_offset - h.size() ) );
            RETURN_ERR( in.read( data.begin(), data_size ) );
        }

        int remain = file_size - gd3_offset;
        byte gd3_h [gd3_header_size];
        if ( gd3_offset > 0 && remain >= gd3_header_size )
        {
            RETURN_ERR( in.skip( amount_to_skip ) );
            RETURN_ERR( in.read( gd3_h, sizeof gd3_h ) );
            int gd3_size = check_gd3_header( gd3_h, remain );
            if ( gd3_size )
            {
                RETURN_ERR( gd3.resize( gd3_size ) );
                RETURN_ERR( in.read( gd3.begin(), gd3.size() ) );
            }

            if ( data_offset > gd3_offset )
            {
                RETURN_ERR( data.resize( data_size ) );
                RETURN_ERR( in.skip( data_offset - gd3_offset - sizeof gd3_h - gd3.size() ) );
                RETURN_ERR( in.read( data.begin(), data.end() - data.begin() ) );
            }
        }

        return (blargg_err_t)blargg_ok;
    }
开发者ID:Kinglions,项目名称:modizer,代码行数:56,代码来源:Vgm_Emu.cpp

示例5: Data_Reader

bool Amisic::Initialize()
{
  if (InputPath()=="" && InputFile()=="") return false;
  Data_Reader *reader = new Data_Reader(" ",";","!","=");
  reader->AddComment("#");
  reader->AddWordSeparator("\t");
  reader->SetInputPath(InputPath());
  reader->SetInputFile(InputFile());
  std::vector<std::string> model;
  if (!reader->VectorFromFile(model,"HARD_MODEL_NAME")) {
    model.push_back("Simple_Chain");
  }
  for (size_t i=1;i<model.size();++i) model[0]+=" "+model[i];
  SelectHardModel(model[0]);
  if (!reader->VectorFromFile(model,"SOFT_MODEL_NAME")) {
    model.push_back("None");
  }
  for (size_t i=1;i<model.size();++i) model[0]+=" "+model[i];
  SelectSoftModel(model[0]);
  std::string file;
  if (!reader->ReadFromFile(file,"HARD_MODEL_FILE")) file=InputFile();
  p_hardbase->SetInputPath(InputPath());
  p_hardbase->SetInputFile(file);
  if (!reader->ReadFromFile(file,"SOFT_MODEL_FILE")) file=InputFile();
  p_softbase->SetInputPath(InputPath());
  p_softbase->SetInputFile(file);
  delete reader;
  bool success=true;
  success=success&&p_hardbase->Initialize();
  success=success&&p_softbase->Initialize();
  return success;
}
开发者ID:alisw,项目名称:SHERPA,代码行数:32,代码来源:Amisic.C

示例6: load_

// Reads file into array, placing file_offset bytes of padding before the beginning, and pad_size after the end
blargg_err_t Rom_Data::load_( Data_Reader& in, int header_size, int file_offset )
{
    clear();
    file_size_ = in.remain();
    if ( file_size_ <= header_size ) // <= because there must be data after header
        return blargg_err_file_type;
    
    RETURN_ERR( rom.resize( file_offset + file_size_ + pad_size ) );
    
    return in.read( rom.begin() + file_offset, file_size_ );
}
开发者ID:Kinglions,项目名称:modizer,代码行数:12,代码来源:Rom_Data.cpp

示例7: DEBUG_FUNC

void Hard_Decay_Handler::ReadDecayTable(Flavour decayer)
{
  DEBUG_FUNC(decayer);
  if (!m_store_results) return;
  Data_Reader reader = Data_Reader("|",";","!");
  reader.SetAddCommandLine(false);
  reader.AddComment("#");
  reader.AddComment("//");
  reader.AddWordSeparator("\t");
  reader.SetInputPath(m_resultdir);
  reader.SetInputFile(decayer.ShellName());
  
  vector<vector<string> > file;
  if(reader.MatrixFromFile(file)) {
    for (size_t iline=0; iline<file.size(); ++iline) {
      if (file[iline].size()==4) {
        string decaychannel=file[iline][0];
        vector<double> results(3);
        for (size_t i=0; i<3; ++i) results[i]=ToType<double>(file[iline][i+1]);
        m_read[decayer].insert(make_pair(decaychannel, results));
      }
      else {
        PRINT_INFO("Wrong format in decay table in "<<m_resultdir);
      }
    }
  }
}
开发者ID:pmillet,项目名称:sherpa,代码行数:27,代码来源:Hard_Decay_Handler.C

示例8: load_

 blargg_err_t load_( Data_Reader& in )
 {
     int file_size = in.remain();
     if ( file_size < Sfm_Emu::sfm_min_file_size )
         return blargg_err_file_type;
     RETURN_ERR( data.resize( file_size ) );
     RETURN_ERR( in.read( data.begin(), data.end() - data.begin() ) );
     RETURN_ERR( check_sfm_header( data.begin() ) );
     int metadata_size = get_le32( data.begin() + 4 );
     byte temp = data[ 8 + metadata_size ];
     data[ 8 + metadata_size ] = '\0';
     metadata.parseDocument( (const char *)data.begin() + 8 );
     data[ 8 + metadata_size ] = temp;
     return blargg_ok;
 }
开发者ID:iOSAppList,项目名称:modizer,代码行数:15,代码来源:Spc_Sfm.cpp

示例9: load_

    blargg_err_t load_( Data_Reader& in )
    {
        long file_size = in.remain();
        if ( file_size < Snes_Spc::spc_min_file_size )
            return gme_wrong_file_type;
        RETURN_ERR( in.read( &header, Spc_Emu::header_size ) );
        RETURN_ERR( check_spc_header( header.tag ) );
        long const xid6_offset = 0x10200;
        long xid6_size = file_size - xid6_offset;
        if ( xid6_size > 0 )
        {
            RETURN_ERR( xid6.resize( xid6_size ) );
            RETURN_ERR( in.skip( xid6_offset - Spc_Emu::header_size ) );
            RETURN_ERR( in.read( xid6.begin(), xid6.size() ) );
        }
        return 0;
    }
开发者ID:bazzinotti,项目名称:libGME_M,代码行数:17,代码来源:Spc_Emu.cpp

示例10: load_

    blargg_err_t load_( Data_Reader& in )
    {
        assert( offsetof (header_t,fields) == Hes_Emu::header_size + 0x20 );
        blargg_err_t err = in.read( &h, sizeof h );
        if ( err )
            return (err == in.eof_error ? gme_wrong_file_type : err);
        return check_hes_header( &h );
    }
开发者ID:Accusedbold,项目名称:zdoom,代码行数:8,代码来源:Hes_Emu.cpp

示例11: InitialiseGenerator

void InitialiseGenerator(int argc, char *argv[])
{
  if(argc<2) {
    cout<<"Usage: ./SingleDecay <PDG_CODE>"<<endl;
    THROW(normal_exit,"you didn't specify the decaying particle by PDG code.");
  }

  small_sherpa_init(argc, argv);

  hadrons = new SHERPA::Hadron_Decay_Handler(".", "Fragmentation.dat");

  Data_Reader * reader = new Data_Reader(" ",";","!","=");
  reader->AddWordSeparator("\t");
  reader->SetInputPath("./");
  reader->SetInputFile("YFS.dat");
  photons = new PHOTONS::Photons(reader,true);

  mother_flav = Flavour( (kf_code) abs(ToType<int>(argv[1])) );
  mother_flav.SetStable(false);
  if(ToType<int>(argv[1])<0) mother_flav=mother_flav.Bar();

  rpa->gen.SetEcms(mother_flav.HadMass());
  msg_Info()<<"Welcome. I am decaying a "<<mother_flav<<endl;

  Particle* mother_part = new Particle( 1,mother_flav,
                                        Vec4D(mother_flav.HadMass(),0.,0.,0.) );
  mother_part->SetTime();
  mother_part->SetFinalMass(mother_flav.HadMass());
  
  ref_blob = new Blob();
  ref_blob->SetType(btp::Hadron_Decay);
  ref_blob->SetStatus(blob_status::needs_hadrondecays);
  ref_blob->AddToInParticles(mother_part);

  try {
    hadrons->FillOnshellDecay(ref_blob, NULL);
  } catch (Return_Value::code ret) {
    msg_Error()<<METHOD<<" Something went wrong for blob: "<<ref_blob<<endl;
    return;
  }
}
开发者ID:alisw,项目名称:SHERPA,代码行数:41,代码来源:Main_SingleDecayPhotons.C

示例12: load_

    blargg_err_t load_( Data_Reader& in )
    {
        blargg_err_t err = in.read( &h, h.size );
        if ( err )
            return (blargg_is_err_type( err, blargg_err_file_eof ) ? blargg_err_file_type : err);
        
        set_track_count( h.track_count );
        if ( !h.valid_tag() )
            return blargg_err_file_type;
        
        return blargg_ok;
    }
开发者ID:Gardenya,项目名称:deadbeef,代码行数:12,代码来源:Gbs_Emu.cpp

示例13: load_

    blargg_err_t load_( Data_Reader& in )
    {
        blargg_err_t err = in.read( &h, Nsf_Emu::header_size );
        if ( err )
            return (err == in.eof_error ? gme_wrong_file_type : err);
        
        if ( h.chip_flags & ~(namco_flag | vrc6_flag | fme7_flag) )
            set_warning( "Uses unsupported audio expansion hardware" );
        
        set_track_count( h.track_count );
        return check_nsf_header( &h );
    }
开发者ID:Lin20,项目名称:projectpmr,代码行数:12,代码来源:Nsf_Emu.cpp

示例14: CleanUp

bool Simple_String::Initialize()
{
  CleanUp();
  if (InputPath()=="" && InputFile()=="") return false;
  if (!rpa->gen.Beam1().IsHadron() ||
      !rpa->gen.Beam2().IsHadron()) return false;
  Data_Reader *reader = new Data_Reader(" ",";","!","=");
  reader->AddComment("#");
  reader->AddWordSeparator("\t");
  reader->SetInputPath(InputPath());
  reader->SetInputFile(InputFile());
  std::vector<std::vector<std::string> > helpsvv;
  if (!reader->MatrixFromFile(helpsvv,"REGGE_TRAJECTORY")) {
    helpsvv.push_back(std::vector<std::string>(3));
    helpsvv.back()[0]="Pomeron";
    helpsvv.back()[1]="1.0808";
    helpsvv.back()[2]="0.25";
  }
  msg_Info()<<"Simple_String::Initialize(): Adding Reggeon {\n";
  for (size_t i=0;i<helpsvv.size();++i) {
    if (helpsvv[i].size()<3) continue;
    m_reggeons.push_back(new Reggeon_Trajectory
             (ToType<double>(helpsvv[i][1]),
              ToType<double>(helpsvv[i][2])));
    m_reggeons.back()->SetS(sqr(rpa->gen.Ecms()));
    msg_Info()<<"   "<<std::setw(10)<<helpsvv[i][0]
          <<" "<<std::setw(8)<<helpsvv[i][1]
          <<" "<<std::setw(8)<<helpsvv[i][2]<<"\n";
  }
  msg_Info()<<"}"<<std::endl;
  p_remnants[0]=p_isr->GetRemnant(0);
  p_remnants[1]=p_isr->GetRemnant(1);
  return true;
}
开发者ID:alisw,项目名称:SHERPA,代码行数:34,代码来源:Simple_String.C

示例15: read_sta_file

blargg_err_t Nes_Snapshot::read_sta_file( Data_Reader& in )
{
    sram_size = 0x2000;
    BLARGG_RETURN_ERR( in.read( sram, sram_size ) );
    
    ram_valid = true;
    BLARGG_RETURN_ERR( in.read( ram, 0x800 ) );
    
    sta_regs_t r;
    BLARGG_RETURN_ERR( in.read( &r, sizeof r ) );
    this->cpu.pc = r.pc [1] * 0x100 + r.pc [0];
    this->cpu.a = r.a;
    this->cpu.status = r.p;
    this->cpu.x = r.x;
    this->cpu.y = r.y;
    this->cpu.sp = r.s;
    cpu_valid = true;
    
    BLARGG_RETURN_ERR( in.read( spr_ram, 0x100 ) );
    spr_ram_valid = true;
    
    chr_size = 0x2000;
    BLARGG_RETURN_ERR( in.read( chr, chr_size ) );
    
    nametable_size = 0x1000;
    BLARGG_RETURN_ERR( in.read( nametable, nametable_size ) );
    
    return blargg_success;
}
开发者ID:clems71,项目名称:QuickNES_Core,代码行数:29,代码来源:Nes_Snapshot.cpp


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