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


C++ ReadInt函数代码示例

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


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

示例1: ReadInt

void LcfReader::Read<bool>(bool& ref) {
	ref = ReadInt() > 0;
}
开发者ID:Zegeri,项目名称:liblcf,代码行数:3,代码来源:reader_lcf.cpp

示例2: BBP_read_int

int BBP_read_int(struct plugin_info *PI, const char *rcs, int def)
{
    char buffer[256];
    return ReadInt(PI->rcpath, make_key(buffer, PI, rcs), def);
}
开发者ID:Jmos,项目名称:bbclean-xzero450,代码行数:5,代码来源:bbPlugin+.cpp

示例3: read_gadget

/*=============================================================================
 *                                READ_GADGET
 *=============================================================================*/
void read_gadget(FILE *icfile, float **out_x,float **out_y,float **out_z)
{

  int            i;
  long           no_part;
  int            massflag;
  char           DATA[MAXSTRING];
  float          fdummy[3];
  double         ddummy[3];
  double         x_fac;
  long           pid;

  
  /*================= read in GADGET IO header =================*/
  if(FORMAT == 2)
   {
    GADGET_SKIP;
    fread(DATA,sizeof(char),blklen,icfile);
    DATA[4] = '\0';
    fprintf(stderr,"reading... %s\n",DATA);
    
    GADGET_SKIP;
   }
  
  GADGET_SKIP;
  
  ReadInt(icfile,&(gadget.header.np[0]),SWAPBYTES);
  ReadInt(icfile,&(gadget.header.np[1]),SWAPBYTES);
  ReadInt(icfile,&(gadget.header.np[2]),SWAPBYTES);
  ReadInt(icfile,&(gadget.header.np[3]),SWAPBYTES);    /* number of particles in current file */
  ReadInt(icfile,&(gadget.header.np[4]),SWAPBYTES);
  ReadInt(icfile,&(gadget.header.np[5]),SWAPBYTES);
  ReadDouble(icfile,&(gadget.header.massarr[0]),SWAPBYTES);
  ReadDouble(icfile,&(gadget.header.massarr[1]),SWAPBYTES);
  ReadDouble(icfile,&(gadget.header.massarr[2]),SWAPBYTES);
  ReadDouble(icfile,&(gadget.header.massarr[3]),SWAPBYTES);
  ReadDouble(icfile,&(gadget.header.massarr[4]),SWAPBYTES);
  ReadDouble(icfile,&(gadget.header.massarr[5]),SWAPBYTES);
  ReadDouble(icfile,&(gadget.header.expansion),SWAPBYTES);
  ReadDouble(icfile,&(gadget.header.redshift),SWAPBYTES);
  ReadInt(icfile,&(gadget.header.flagsfr),SWAPBYTES);
  ReadInt(icfile,&(gadget.header.flagfeedback),SWAPBYTES);
  ReadInt(icfile,&(gadget.header.nall[0]),SWAPBYTES);
  ReadInt(icfile,&(gadget.header.nall[1]),SWAPBYTES);
  ReadInt(icfile,&(gadget.header.nall[2]),SWAPBYTES);  /* total number of particles in simulation */
  ReadInt(icfile,&(gadget.header.nall[3]),SWAPBYTES);
  ReadInt(icfile,&(gadget.header.nall[4]),SWAPBYTES);
  ReadInt(icfile,&(gadget.header.nall[5]),SWAPBYTES);
  ReadInt(icfile,&(gadget.header.flagcooling),SWAPBYTES);
  ReadInt(icfile,&(gadget.header.NumFiles),SWAPBYTES);
  ReadDouble(icfile,&(gadget.header.BoxSize),SWAPBYTES);
  ReadDouble(icfile,&(gadget.header.Omega0),SWAPBYTES);
  ReadDouble(icfile,&(gadget.header.OmegaLambda),SWAPBYTES);
  ReadDouble(icfile,&(gadget.header.HubbleParam),SWAPBYTES);
  ReadChars(icfile,&(gadget.header.unused[0]),SIZEOFGADGETHEADER- 6*4- 6*8- 2*8- 2*4- 6*4- 2*4 - 4*8);
  
  GADGET_SKIP;
  /*================= read in GADGET IO header =================*/

  
  /* keep track of no. of particles in each GADGET file */
  gadget.np[0][gadget.i_gadget_file] = gadget.header.np[0];
  gadget.np[1][gadget.i_gadget_file] = gadget.header.np[1];
  gadget.np[2][gadget.i_gadget_file] = gadget.header.np[2];
  gadget.np[3][gadget.i_gadget_file] = gadget.header.np[3];
  gadget.np[4][gadget.i_gadget_file] = gadget.header.np[4];
  gadget.np[5][gadget.i_gadget_file] = gadget.header.np[5];
  
  /* conversion factors to Mpc/h, km/sec, Msun/h */
  x_fac  = GADGET_LUNIT;
  //m_fac  = GADGET_MUNIT;
  
  /* count total no. of particles in current file (and set massflag) */
  massflag    = 0;
  no_part     = 0;
  gadget.nall = 0;
  for(i=0;i<6;i++) 
   {
    no_part     += gadget.header.np[i];
    gadget.nall += gadget.header.nall[i];
    if(gadget.header.massarr[i] < MZERO && gadget.header.np[i] > 0)
      massflag=1;  
   }  
  
  #ifdef _VERB
  fprintf(stderr,"expansion factor: %lf\n",             gadget.header.expansion);
  fprintf(stderr,"redshift:         %lf\n",             gadget.header.redshift);
  fprintf(stderr,"boxsize:          %lf (%lf Mpc/h)\n", gadget.header.BoxSize,gadget.header.BoxSize*GADGET_LUNIT);
  fprintf(stderr,"omega0:           %lf\n",             gadget.header.Omega0);
  fprintf(stderr,"lambda0:          %lf\n",             gadget.header.OmegaLambda);
  fprintf(stderr,"HubbleParam:      %lf\n\n",           gadget.header.HubbleParam);
  
  fprintf(stderr,"gas:    np[0]=%9d\t nall[0]=%9d\t massarr[0]=%g\n",gadget.header.np[0],gadget.header.nall[0],gadget.header.massarr[0]); 
  fprintf(stderr,"halo:   np[1]=%9d\t nall[1]=%9d\t massarr[1]=%g\n",gadget.header.np[1],gadget.header.nall[1],gadget.header.massarr[1]); 
  fprintf(stderr,"disk:   np[2]=%9d\t nall[2]=%9d\t massarr[2]=%g\n",gadget.header.np[2],gadget.header.nall[2],gadget.header.massarr[2]); 
  fprintf(stderr,"bulge:  np[3]=%9d\t nall[3]=%9d\t massarr[3]=%g\n",gadget.header.np[3],gadget.header.nall[3],gadget.header.massarr[3]); 
  fprintf(stderr,"stars:  np[4]=%9d\t nall[4]=%9d\t massarr[4]=%g\n",gadget.header.np[4],gadget.header.nall[4],gadget.header.massarr[4]); 
//.........这里部分代码省略.........
开发者ID:savila,项目名称:halogen.c,代码行数:101,代码来源:read_snapshot.c

示例4: ReadInt

/// Read MapFeatureHeader head from file
void CSMFMapFile::ReadMapFeatureHeader(MapFeatureHeader& head, CFileHandler& file)
{
	head.numFeatureType = ReadInt(file);
	head.numFeatures = ReadInt(file);
}
开发者ID:sprunk,项目名称:spring,代码行数:6,代码来源:SMFMapFile.cpp

示例5: fread

bool RSObject::Load(FILE *file,RSMaterialManager *pMM)
{
	int i,j,k;

	fread(&m_Header,sizeof(m_Header),1,file);
	if((m_Header.RSMID!=HEADER_RSMID)||(m_Header.Build!=HEADER_BUILD))
	{
		rslog("Incorrect file format. rsm build #%d. #%d required.\n",m_Header.Build,HEADER_BUILD);
		return false;
	}
	m_pMM=pMM;

	fread(&m_bbox,sizeof(rboundingbox),1,file);
	m_bbox.Minz=m_bbox.Miny=m_bbox.Minx=100000000;
	m_bbox.Maxz=m_bbox.Maxy=m_bbox.Maxx=-100000000;

	ReadInt(nMaterial);
	materials=new RSMaterial*[nMaterial+1];

//	rslog("[ load object :%d mtrl_num %d ]\n",g_obj_cnt,nMaterial);

	materials[0]=&RSDefaultMaterial;
	for (i=0;i<nMaterial;i++)
	{
		char buf[256];
		{int l=fgetc(file);buf[l]=0;if(l) fread(buf,l,1,file);}
		RSMaterial *pmat=pMM->GetMaterial(buf);
		materials[i+1]=pmat ? pmat : &RSDefaultMaterial;

//		rslog("\t-mtrl :%d name %s \n",i,buf);
	}

	nMaterial++;	// for default material;

	ReadInt(nMesh);
	CMesh *mesh=meshes=new CMesh[nMesh];

//	rslog("\n\t-mesh num :%d \n\n",nMesh);

	for(i=0;i<nMesh;i++)
	{
		ReadString(mesh->name);strlwr(mesh->name);
		ReadMatrix(mesh->mat);
		fread(&mesh->m_bbox,sizeof(rboundingbox),1,file);

		mesh->m_bbox.Minz=mesh->m_bbox.Miny=mesh->m_bbox.Minx=100000000;
		mesh->m_bbox.Maxz=mesh->m_bbox.Maxy=mesh->m_bbox.Maxx=-100000000;

		mesh->center=rvector(0,0,0);

		ReadInt(mesh->nFaces);
		CFaces *faces=mesh->faceshead=mesh->nFaces?new CFaces[mesh->nFaces]:NULL;

//		rslog("\t-mesh face num :%d \n",mesh->nFaces);

		for(j=0;j<mesh->nFaces;j++)
		{
			ReadInt(faces->iMaterial);faces->iMaterial++;		// convert to 1-base index
			ReadInt(faces->nv);
			faces->tnlvertices=new VERTEX[faces->nv];
			fread(faces->tnlvertices,sizeof(VERTEX),faces->nv,file);

			for(k=0;k<faces->nv;k++)
			{
				rvector *pv=(rvector*)(&faces->tnlvertices[k].x);
				m_BoundingSphereRadius=max(m_BoundingSphereRadius,pv->GetMagnitude());
				m_BoundingSphereRadiusXY=max(m_BoundingSphereRadiusXY,rvector(pv->x,pv->y,0).GetMagnitude());
				mesh->m_bbox.Minx=min(mesh->m_bbox.Minx,pv->x);
				mesh->m_bbox.Maxx=max(mesh->m_bbox.Maxx,pv->x);
				mesh->m_bbox.Miny=min(mesh->m_bbox.Miny,pv->y);
				mesh->m_bbox.Maxy=max(mesh->m_bbox.Maxy,pv->y);
				mesh->m_bbox.Minz=min(mesh->m_bbox.Minz,pv->z);
				mesh->m_bbox.Maxz=max(mesh->m_bbox.Maxz,pv->z);
			}

//			rslog("\t\t-mesh face v num :%d \n",faces->nv);

			if(fgetc(file)==1)
			{
				faces->indicies_original=new WORD[faces->nv];
				fread(faces->indicies_original,sizeof(WORD),faces->nv,file);
			}
			else
			{
				ReadInt(faces->ni);
				faces->indicies=new WORD[faces->ni];
				fread(faces->indicies,sizeof(WORD),faces->ni,file);
			}
			faces++;
		}

		if(strstr(mesh->name,ALIGN_POINT_STRING))
			mesh->m_align=RS_ALIGNSTYLE_POINT;
		else
		if(strstr(mesh->name,ALIGN_LINE_STRING))
			mesh->m_align=RS_ALIGNSTYLE_LINE;
		else
			mesh->m_align=RS_ALIGNSTYLE_NONE;

		MergeBoundingBox(&m_bbox,&mesh->m_bbox);
//.........这里部分代码省略.........
开发者ID:MagistrAVSH,项目名称:node3d,代码行数:101,代码来源:RSObject.cpp

示例6: CPL_IGNORE_RET_VAL

int USGSDEMDataset::LoadFromFile(VSILFILE *InDem)
{
    // check for version of DEM format
    CPL_IGNORE_RET_VAL(VSIFSeekL(InDem, 864, 0));

    // Read DEM into matrix
    const int nRow = ReadInt(InDem);
    const int nColumn = ReadInt(InDem);
    const bool bNewFormat = VSIFTellL(InDem) >= 1024 || nRow != 1 || nColumn != 1;
    if (bNewFormat)
    {
        CPL_IGNORE_RET_VAL(VSIFSeekL(InDem, 1024, 0));  // New Format
        int i = ReadInt(InDem);
        int j = ReadInt(InDem);
        if ( i != 1 || ( j != 1 && j != 0 ) )  // File OK?
        {
            CPL_IGNORE_RET_VAL(VSIFSeekL(InDem, 893, 0));  // Undocumented Format (39109h1.dem)
            i = ReadInt(InDem);
            j = ReadInt(InDem);
            if ( i != 1 || j != 1 )  // File OK?
            {
                CPLError( CE_Failure, CPLE_AppDefined,
                          "Does not appear to be a USGS DEM file." );
                return FALSE;
            }
            else
                nDataStartOffset = 893;
        }
        else
            nDataStartOffset = 1024;
    }
    else
        nDataStartOffset = 864;

    CPL_IGNORE_RET_VAL(VSIFSeekL(InDem, 156, 0));
    const int nCoordSystem = ReadInt(InDem);
    const int iUTMZone = ReadInt(InDem);

    CPL_IGNORE_RET_VAL(VSIFSeekL(InDem, 528, 0));
    const int nGUnit = ReadInt(InDem);
    const int nVUnit = ReadInt(InDem);

    // Vertical Units in meters
    if (nVUnit==1)
        pszUnits = "ft";
    else
        pszUnits = "m";

    CPL_IGNORE_RET_VAL(VSIFSeekL(InDem, 816, 0));
    const double dxdelta = DConvert(InDem, 12);
    const double dydelta = DConvert(InDem, 12);
    if( dydelta == 0 )
        return FALSE;
    fVRes = DConvert(InDem, 12);

/* -------------------------------------------------------------------- */
/*      Should we treat this as floating point, or GInt16.              */
/* -------------------------------------------------------------------- */
    if (nVUnit==1 || fVRes < 1.0)
        eNaturalDataFormat = GDT_Float32;
    else
        eNaturalDataFormat = GDT_Int16;

/* -------------------------------------------------------------------- */
/*      Read four corner coordinates.                                   */
/* -------------------------------------------------------------------- */
    CPL_IGNORE_RET_VAL(VSIFSeekL(InDem, 546, 0));
    DPoint2 corners[4];  // SW, NW, NE, SE
    for (int i = 0; i < 4; i++)
    {
        corners[i].x = DConvert(InDem, 24);
        corners[i].y = DConvert(InDem, 24);
    }

    // find absolute extents of raw vales
    DPoint2 extent_min, extent_max;
    extent_min.x = std::min(corners[0].x, corners[1].x);
    extent_max.x = std::max(corners[2].x, corners[3].x);
    extent_min.y = std::min(corners[0].y, corners[3].y);
    extent_max.y = std::max(corners[1].y, corners[2].y);

    /* dElevMin = */ DConvert(InDem, 48);
    /* dElevMax = */ DConvert(InDem, 48);

    CPL_IGNORE_RET_VAL(VSIFSeekL(InDem, 858, 0));
    const int nProfiles = ReadInt(InDem);

/* -------------------------------------------------------------------- */
/*      Collect the spatial reference system.                           */
/* -------------------------------------------------------------------- */
    OGRSpatialReference sr;
    bool bNAD83 = true;

    // OLD format header ends at byte 864
    if (bNewFormat)
    {
        // year of data compilation
        CPL_IGNORE_RET_VAL(VSIFSeekL(InDem, 876, 0));
        char szDateBuffer[5];
        CPL_IGNORE_RET_VAL(VSIFReadL(szDateBuffer, 4, 1, InDem));
//.........这里部分代码省略.........
开发者ID:rouault,项目名称:gdal,代码行数:101,代码来源:usgsdemdataset.cpp

示例7: main


//.........这里部分代码省略.........
   if(InitShell(argc,argv,hsmooth_version,hsmooth_vc_id)<SUCCESS)
      HError(2400,"HSmooth: InitShell failed");

   InitMem();   InitLabel();
   InitMath();  InitSigP();
   InitWave();  InitAudio();
   InitVQ();    InitModel();
   if(InitParm()<SUCCESS)  
      HError(2400,"HSmooth: InitParm failed");

   InitTrain(); InitUtil();

   if (!InfoPrinted() && NumArgs() == 0)
      ReportUsage();
   if (NumArgs() == 0) Exit(0);

   SetConfParms();
   CreateHeap(&hmmStack,"HmmStore", MSTAK, 1, 1.0, 50000, 500000);
   CreateHMMSet(&hset,&hmmStack,TRUE);
   while (NextArg() == SWITCHARG) {
      s = GetSwtArg();
      if (strlen(s)!=1) 
         HError(2419,"HSmooth: Bad switch %s; must be single letter",s);
      switch(s[0]){
      case 'b':
         epsilon = GetChkedFlt(0.0,1.0,s); break;           
      case 'c':
         maxStep = GetChkedInt(1,1000,s); break;            
      case 'd':
         if (NextArg()!=STRINGARG)
            HError(2419,"HSmooth: HMM definition directory expected");
         hmmDir = GetStrArg(); break;  
      case 'e':
         if (NextArg()!=STRINGARG)
            HError(2419,"HSmooth: HMM definition directory expected");
         newDir = GetStrArg(); break;  
      case 'm':
         minEgs = GetChkedInt(1,1000,s); break;
      case 'o':
         if (NextArg()!=STRINGARG)
            HError(2419,"HSmooth: HMM file extension expected");
         newExt = GetStrArg(); break;
      case 's':
         stats = TRUE;
         if (NextArg()!=STRINGARG)
            HError(2419,"HSmooth: Stats file name expected");
         statFN = GetStrArg(); break;
      case 'u':
         SetuFlags(); break;
      case 'v':
         minVar = GetChkedFlt(0.0,10.0,s); break;
      case 'w':
         mixWeightFloor = MINMIX * GetChkedFlt(0.0,10000.0,s); 
         break;
      case 'x':
         if (NextArg()!=STRINGARG)
            HError(2419,"HSmooth: HMM file extension expected");
         hmmExt = GetStrArg(); break;
      case 'B':
         saveBinary=TRUE;
         break;
      case 'H':
         if (NextArg() != STRINGARG)
            HError(2419,"HSmooth: HMM macro file name expected");
         AddMMF(&hset,GetStrArg());
         break;
      case 'M':
         if (NextArg()!=STRINGARG)
            HError(2419,"HSmooth: Output macro file directory expected");
         newDir = GetStrArg();
         break;    
      case 'T':
         trace = GetChkedInt(0,0100000,s); break;
      default:
         HError(2419,"HSmooth: Unknown switch %s",s);
      }
   } 
   if (NextArg() != STRINGARG)
      HError(2419,"HSmooth: file name of HMM list expected");
   Initialise(GetStrArg());
   do {
      if (NextArg()!=STRINGARG)
         HError(2419,"HSmooth: accumulator file name expected");
      accfn = GetStrArg();
      src=LoadAccs(&hset,accfn,uFlags);
      ReadFloat(&src,&tmpFlt,1,ldBinary);
      totalPr += (LogDouble)tmpFlt;
      ReadInt(&src,&tmpInt,1,ldBinary);
      totalT += tmpInt;
      CloseSource(&src);      
      nBlk++;
      MakeWtAccLists();
   } while (NumArgs()>0);
   AttachWtAccLists();
   Interpolate();
   if (stats) StatReport();
   UpdateModels();
   Exit(0);
   return (0);          /* never reached -- make compiler happy */
}
开发者ID:2hanson,项目名称:voice_dialling,代码行数:101,代码来源:HSmooth.c

示例8: main

int main (int argc, char *argv[]) {
  int st;
  SimParams params;
  int max_steps = std::numeric_limits<int>::max();

  std::string within_filename, output_filename;
  po::options_description desc("Options");
  desc.add_options()
    ("help,h",  "Print help messages")
    ("group,g", po::value<std::string>()->default_value("He"),
     "Group for temperature profiles")
    ("index,n", po::value<std::string>()->default_value("index.ndx"),
     ".ndx file containing atomic indices for groups")
    ("gro", po::value<std::string>()->default_value("conf.gro"),
     ".gro file containing list of atoms/molecules")
    ("top", po::value<std::string>()->default_value("topol.top"),
     ".top file containing atomic/molecular properties")
    ("within,w",
     po::value<std::string>(&within_filename)->default_value("within.dat"),
     ".dat file specifying solvating molecules")
    ("output,o",
     po::value<std::string>(&output_filename)->default_value("qDist.txt"),
     "Output filename");

  po::variables_map vm;
  po::store(po::parse_command_line(argc, argv, desc), vm);
  po::notify(vm);
  if (vm.count("help")) {
    std::cout << desc << "\n";
    exit(EXIT_SUCCESS);
  }

  std::map<std::string, std::vector<int> > groups;
  groups = ReadNdx(vm["index"].as<std::string>());

  std::vector<Molecule> molecules = GenMolecules(vm["top"].as<std::string>(),
                                                 params);
  AtomGroup all_atoms(vm["gro"].as<std::string>(), molecules);
  AtomGroup selected_group(vm["group"].as<std::string>(),
                           SelectGroup(groups, vm["group"].as<std::string>()),
                           all_atoms);

  std::fstream within_file(within_filename.c_str());
  assert(within_file.is_open());

  arma::irowvec within = arma::zeros<arma::irowvec>(selected_group.size());
  arma::irowvec nearest = arma::zeros<arma::irowvec>(4);
  Histogram q_hist(100, 0.01);

  rvec *x_in = NULL;
  matrix box_mat;
  arma::rowvec box = arma::zeros<arma::rowvec>(DIMS);
  std::string xtc_filename = "prod.xtc";
  XDRFILE *xtc_file;
  params.ExtractTrajMetadata(strdup(xtc_filename.c_str()), (&x_in), box);
  xtc_file = xdrfile_open(strdup(xtc_filename.c_str()), "r");
  params.set_max_time(vm["max_time"].as<double>());

  arma::rowvec dx;
  arma::mat dx_near = arma::zeros<arma::mat>(4,DIMS);
  arma::rowvec r2 = arma::zeros<arma::rowvec>(selected_group.size());
  float time,prec;
  for (int step=0; step<max_steps; step++) {
    if(read_xtc(xtc_file, params.num_atoms(), &st, &time, box_mat, x_in, &prec))
      break;
    params.set_box(box_mat);
    int i = 0;
    for (std::vector<int>::iterator i_atom = selected_group.begin();
         i_atom != selected_group.end(); i_atom++, i++) {
      selected_group.set_position(i, x_in[*i_atom]);
    }
    ReadInt(within, within_file);
    for (int i_atom = 0; i_atom < selected_group.size(); ++i_atom) {
      if (!within(i_atom)) continue;
      selected_group.FindNearestk(selected_group.position(i_atom), params.box(),
                                  selected_group.index_to_molecule(i_atom), 4,
                                  dx, r2, nearest);
      int q = 0;
      for (int i_near = 0; i_near < 4; ++i_near) {
        FindDxNoShift(dx, selected_group.position(i_atom),
                      selected_group.position(i_near), box);
        dx_near.row(i_near) = arma::normalise(dx);

        for (int i_near2 = 0; i_near2 < i_near; ++i_near2) {
          double sqrt_q =
              arma::dot(dx_near.row(i_near),dx_near.row(i_near2)) + 1.0/3.0;
          q += sqrt_q*sqrt_q;
        }
      }
      q_hist.Add(q);
    }
  }
  q_hist.Print(output_filename, true);
}
开发者ID:thekannman,项目名称:z_tetra,代码行数:94,代码来源:main.cpp

示例9: BeDecode

int BeDecode(ScriptValue &sv, StringValue *s, int *pos) {
	if (s->len < pos[0]) return 0;
	if (s->value[pos[0]] == 'i') {
		pos[0] ++;
		unsigned char *end = strchr(s->value + pos[0], 'e');
		__int64 val;
		if (!ReadInt(s->value + pos[0], end, val)) return 0;
		CreateIntValue(sv, val);
		pos[0] = 1+(int)(end-s->value);
	}
	else if (s->value[pos[0]] == 'l') {
		pos[0] ++;
		CreateListValue(sv, 3);
		while (s->len > pos[0]) {
			if (s->value[pos[0]] == 'e') {
				pos[0] ++;
				return 1;
			}
			ScriptValue sv2;
			if (!BeDecode(sv2, s, pos) || !sv.listVal->PushBack(sv2)) {
				sv.Release();
				return 0;
			}
		}
		sv.Release();
		return 0;
	}
	else if (s->value[pos[0]] == 'd') {
		pos[0] ++;
		CreateDictValue(sv, 3);
		while (s->len > pos[0]) {
			if (s->value[pos[0]] == 'e') {
				pos[0] ++;
				return 1;
			}
			ScriptValue sv2, sv3;
			if (!BeDecode(sv2, s, pos)) {
				sv.Release();
				return 0;
			}
			if (sv2.type != SCRIPT_STRING || !BeDecode(sv3, s, pos)) {
				sv2.Release();
				sv.Release();
				return 0;
			}
			if (!sv.dictVal->Add(sv, sv2)) {
				sv.Release();
				return 0;
			}
		}
		sv.Release();
		return 0;
	}
	else if (s->value[pos[0]] == 'n') {
		CreateNullValue(sv);
		pos[0]++;
	}
	else if (s->value[pos[0]] == 'f') {
		pos[0]++;
		if (pos[0] + 8 > s->len) return 0;
		double d;
		memcpy(&d, s->value+pos[0], 8);
		pos[0] += 8;
		CreateDoubleValue(sv, d);
		return 1;
	}
	else {
		unsigned char *end = strchr(s->value + pos[0], ':');
		__int64 val;
		if (!ReadInt(s->value + pos[0], end, val) || val < 0) return 0;
		pos[0] = 1+(int)(end-s->value);
		if (pos[0] + val > s->len) return 0;
		if (!CreateStringValue(sv, s->value+pos[0], (int) val)) return 0;
		pos[0] += (int) val;
	}
	return 1;
}
开发者ID:ZmeyNet,项目名称:lcdmiscellany,代码行数:77,代码来源:BencodeScript.cpp

示例10: TRACE

status_t
AudioFormatConverter::Read(void* buffer, int64 pos, int64 frames)
{
	TRACE("AudioFormatConverter::Read(%p, %Ld, %Ld)\n", buffer, pos, frames);
	status_t error = InitCheck();
	if (error != B_OK) {
		TRACE("AudioFormatConverter::Read() done 1\n");
		return error;
	}
	pos += fOutOffset;

	if (fFormat.u.raw_audio.format == fSource->Format().u.raw_audio.format
		&& fFormat.u.raw_audio.byte_order
		   == fSource->Format().u.raw_audio.byte_order) {
		TRACE("AudioFormatConverter::Read() done 2\n");
		return fSource->Read(buffer, pos, frames);
	}


	int32 inSampleSize = fSource->Format().u.raw_audio.format
		& media_raw_audio_format::B_AUDIO_SIZE_MASK;
	int32 outSampleSize = fFormat.u.raw_audio.format
		& media_raw_audio_format::B_AUDIO_SIZE_MASK;
	int32 channelCount = fFormat.u.raw_audio.channel_count;
	int32 inFrameSize = inSampleSize * channelCount;
	int32 outFrameSize = outSampleSize * channelCount;
	char* reformatBuffer = NULL;
	char* inBuffer = (char*)buffer;

	#ifdef TRACE_AUDIO_CONVERTER
		char formatString[256];
		string_for_format(fSource->Format(), formatString, 256);
		TRACE("  source format: %s\n", formatString);
		TRACE("  in format : format: %lx, sample size: %ld, channels: %ld, "
			"byte order: %lu\n", fSource->Format().u.raw_audio.format,
			inSampleSize, channelCount,
			fSource->Format().u.raw_audio.byte_order);
		TRACE("  out format: format: %lx, sample size: %ld, channels: %ld, "
			"byte order: %lu\n", fFormat.u.raw_audio.format, outSampleSize,
			channelCount, fFormat.u.raw_audio.byte_order);
	#endif // TRACE_AUDIO_CONVERTER

	if (inSampleSize != outSampleSize) {
		reformatBuffer = new char[frames * inFrameSize];
		inBuffer = reformatBuffer;
	}
	error = fSource->Read(inBuffer, pos, frames);
	// convert samples to host endianess
	uint32 hostByteOrder
		= (B_HOST_IS_BENDIAN) ? B_MEDIA_BIG_ENDIAN : B_MEDIA_LITTLE_ENDIAN;
	if (fSource->Format().u.raw_audio.byte_order != hostByteOrder) {
		swap_sample_byte_order(inBuffer, fSource->Format().u.raw_audio.format,
							   frames * inFrameSize);
	}
	// convert the sample type
	switch (fSource->Format().u.raw_audio.format) {
		// float
		case media_raw_audio_format::B_AUDIO_FLOAT:
			switch (fFormat.u.raw_audio.format) {
				case media_raw_audio_format::B_AUDIO_FLOAT:
					break;
				case media_raw_audio_format::B_AUDIO_INT:
					convert(ReadFloat(), WriteInt(), inBuffer, (char*)buffer,
							frames, inSampleSize, outSampleSize, channelCount);
					break;
				case media_raw_audio_format::B_AUDIO_SHORT:
					convert(ReadFloat(), WriteShort(), inBuffer, (char*)buffer,
							frames, inSampleSize, outSampleSize, channelCount);
					break;
				case media_raw_audio_format::B_AUDIO_UCHAR:
					convert(ReadFloat(), WriteUChar(), inBuffer, (char*)buffer,
							frames, inSampleSize, outSampleSize, channelCount);
					break;
				case media_raw_audio_format::B_AUDIO_CHAR:
					convert(ReadFloat(), WriteChar(), inBuffer, (char*)buffer,
							frames, inSampleSize, outSampleSize, channelCount);
					break;
			}
			break;
		// int
		case media_raw_audio_format::B_AUDIO_INT:
			switch (fFormat.u.raw_audio.format) {
				case media_raw_audio_format::B_AUDIO_FLOAT:
					convert(ReadInt(), WriteFloat(), inBuffer, (char*)buffer,
							frames, inSampleSize, outSampleSize, channelCount);
					break;
				case media_raw_audio_format::B_AUDIO_INT:
					break;
				case media_raw_audio_format::B_AUDIO_SHORT:
					convert(ReadInt(), WriteShort(), inBuffer, (char*)buffer,
							frames, inSampleSize, outSampleSize, channelCount);
					break;
				case media_raw_audio_format::B_AUDIO_UCHAR:
					convert(ReadInt(), WriteUChar(), inBuffer, (char*)buffer,
							frames, inSampleSize, outSampleSize, channelCount);
					break;
				case media_raw_audio_format::B_AUDIO_CHAR:
					convert(ReadInt(), WriteChar(), inBuffer, (char*)buffer,
							frames, inSampleSize, outSampleSize, channelCount);
					break;
//.........这里部分代码省略.........
开发者ID:mmanley,项目名称:Antares,代码行数:101,代码来源:AudioFormatConverter.cpp

示例11: memcpy

GDALDataset *OZIDataset::Open( GDALOpenInfo * poOpenInfo )

{
    if (!Identify(poOpenInfo))
        return NULL;

    GByte abyHeader[14];
    CPLString osImgFilename = poOpenInfo->pszFilename;
    memcpy(abyHeader, poOpenInfo->pabyHeader, 14);

    int bOzi3 = (abyHeader[0] == 0x80 &&
                 abyHeader[1] == 0x77);

    VSILFILE* fp = VSIFOpenL(osImgFilename.c_str(), "rb");
    if (fp == NULL)
        return NULL;

    OZIDataset* poDS = new OZIDataset();
    poDS->fp = fp;

    GByte nRandomNumber = 0;
    GByte nKeyInit = 0;
    if (bOzi3)
    {
        VSIFSeekL(fp, 14, SEEK_SET);
        VSIFReadL(&nRandomNumber, 1, 1, fp);
        //printf("nRandomNumber = %d\n", nRandomNumber);
        if (nRandomNumber < 0x94)
        {
            delete poDS;
            return NULL;
        }
        VSIFSeekL(fp, 0x93, SEEK_CUR);
        VSIFReadL(&nKeyInit, 1, 1, fp);

        VSIFSeekL(fp, 0, SEEK_SET);
        VSIFReadL(abyHeader, 1, 14, fp);
        OZIDecrypt(abyHeader, 14, nKeyInit);
        if (!(abyHeader[6] == 0x40 &&
           abyHeader[7] == 0x00 &&
           abyHeader[8] == 0x01 &&
           abyHeader[9] == 0x00 &&
           abyHeader[10] == 0x36 &&
           abyHeader[11] == 0x04 &&
           abyHeader[12] == 0x00 &&
           abyHeader[13] == 0x00))
        {
            delete poDS;
            return NULL;
        }

        VSIFSeekL(fp, 14 + 1 + nRandomNumber, SEEK_SET);
        int nMagic = ReadInt(fp, bOzi3, nKeyInit);
        CPLDebug("OZI", "OZI version code : 0x%08X", nMagic);

        poDS->bOzi3 = bOzi3;
    }
    else
    {
        VSIFSeekL(fp, 14, SEEK_SET);
    }

    GByte abyHeader2[40], abyHeader2_Backup[40];
    VSIFReadL(abyHeader2, 40, 1, fp);
    memcpy(abyHeader2_Backup, abyHeader2, 40);

    /* There's apparently a relationship between the nMagic number */
    /* and the nKeyInit, but I'm too lazy to add switch/cases that might */
    /* be not exhaustive, so let's try the 'brute force' attack !!! */
    /* It is much so funny to be able to run one in a few microseconds :-) */
    int i;
    for(i = 0; i < 256; i ++)
    {
        nKeyInit = (GByte)i;
        GByte* pabyHeader2 = abyHeader2;
        if (bOzi3)
            OZIDecrypt(abyHeader2, 40, nKeyInit);

        int nHeaderSize = ReadInt(&pabyHeader2); /* should be 40 */
        poDS->nRasterXSize = ReadInt(&pabyHeader2);
        poDS->nRasterYSize = ReadInt(&pabyHeader2);
        int nDepth = ReadShort(&pabyHeader2); /* should be 1 */
        int nBPP = ReadShort(&pabyHeader2); /* should be 8 */
        ReadInt(&pabyHeader2); /* reserved */
        ReadInt(&pabyHeader2); /* pixel number (height * width) : unused */
        ReadInt(&pabyHeader2); /* reserved */
        ReadInt(&pabyHeader2); /* reserved */
        ReadInt(&pabyHeader2); /* ?? 0x100 */
        ReadInt(&pabyHeader2); /* ?? 0x100 */

        if (nHeaderSize != 40 || nDepth != 1 || nBPP != 8)
        {
            if (bOzi3)
            {
                if (nKeyInit != 255)
                {
                    memcpy(abyHeader2, abyHeader2_Backup,40);
                    continue;
                }
                else
//.........这里部分代码省略.........
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:101,代码来源:ozidataset.cpp

示例12: VSIFSeekL

CPLErr OZIRasterBand::IReadBlock( int nBlockXOff, int nBlockYOff,
                                  void * pImage )

{
    OZIDataset *poGDS = (OZIDataset *) poDS;

    int nBlock = nBlockYOff * nXBlocks + nBlockXOff;

    VSIFSeekL(poGDS->fp, poGDS->panZoomLevelOffsets[nZoomLevel] +
                         12 + 1024 + 4 * nBlock, SEEK_SET);
    int nPointer = ReadInt(poGDS->fp, poGDS->bOzi3, poGDS->nKeyInit);
    if (nPointer < 0  || (vsi_l_offset)nPointer >= poGDS->nFileSize)
    {
        CPLError(CE_Failure, CPLE_AppDefined,
                 "Invalid offset for block (%d, %d) : %d",
                 nBlockXOff, nBlockYOff, nPointer);
        return CE_Failure;
    }
    int nNextPointer = ReadInt(poGDS->fp, poGDS->bOzi3, poGDS->nKeyInit);
    if (nNextPointer <= nPointer + 16  ||
        (vsi_l_offset)nNextPointer >= poGDS->nFileSize ||
        nNextPointer - nPointer > 10 * 64 * 64)
    {
        CPLError(CE_Failure, CPLE_AppDefined,
                 "Invalid next offset for block (%d, %d) : %d",
                 nBlockXOff, nBlockYOff, nNextPointer);
        return CE_Failure;
    }

    VSIFSeekL(poGDS->fp, nPointer, SEEK_SET);

    int nToRead = nNextPointer - nPointer;
    GByte* pabyZlibBuffer = (GByte*)CPLMalloc(nToRead);
    if (VSIFReadL(pabyZlibBuffer, nToRead, 1, poGDS->fp) != 1)
    {
        CPLError(CE_Failure, CPLE_AppDefined,
                 "Not enough byte read for block (%d, %d)",
                 nBlockXOff, nBlockYOff);
        CPLFree(pabyZlibBuffer);
        return CE_Failure;
    }

    if (poGDS->bOzi3)
        OZIDecrypt(pabyZlibBuffer, 16, poGDS->nKeyInit);

    if (pabyZlibBuffer[0] != 0x78 ||
        pabyZlibBuffer[1] != 0xDA)
    {
        CPLError(CE_Failure, CPLE_AppDefined,
                 "Bad ZLIB signature for block (%d, %d) : 0x%02X 0x%02X",
                 nBlockXOff, nBlockYOff, pabyZlibBuffer[0], pabyZlibBuffer[1]);
        CPLFree(pabyZlibBuffer);
        return CE_Failure;
    }

    z_stream      stream;
    stream.zalloc = (alloc_func)0;
    stream.zfree = (free_func)0;
    stream.opaque = (voidpf)0;
    stream.next_in = pabyZlibBuffer + 2;
    stream.avail_in = nToRead - 2;

    int err = inflateInit2(&(stream), -MAX_WBITS);

    int i;
    for(i=0;i<64 && err == Z_OK;i++)
    {
        stream.next_out = (Bytef*)pImage + (63 - i) * 64;
        stream.avail_out = 64;
        err = inflate(& (stream), Z_NO_FLUSH);
        if (err != Z_OK && err != Z_STREAM_END)
            break;

        if (pabyTranslationTable)
        {
            int j;
            GByte* ptr = ((GByte*)pImage) + (63 - i) * 64;
            for(j=0;j<64;j++)
            {
                *ptr = pabyTranslationTable[*ptr];
                ptr ++;
            }
        }
    }

    inflateEnd(&stream);

    CPLFree(pabyZlibBuffer);

    return (err == Z_OK || err == Z_STREAM_END) ? CE_None : CE_Failure;
}
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:91,代码来源:ozidataset.cpp

示例13: switch

Variant Deserializer::ReadVariant(VariantType type)
{
    switch (type)
    {
    case VAR_INT:
        return Variant(ReadInt());

    case VAR_BOOL:
        return Variant(ReadBool());

    case VAR_FLOAT:
        return Variant(ReadFloat());

    case VAR_VECTOR2:
        return Variant(ReadVector2());

    case VAR_VECTOR3:
        return Variant(ReadVector3());

    case VAR_VECTOR4:
        return Variant(ReadVector4());

    case VAR_QUATERNION:
        return Variant(ReadQuaternion());

    case VAR_COLOR:
        return Variant(ReadColor());

    case VAR_STRING:
        return Variant(ReadString());

    case VAR_BUFFER:
        return Variant(ReadBuffer());

        // Deserializing pointers is not supported. Return null
    case VAR_VOIDPTR:
    case VAR_PTR:
        ReadUInt();
        return Variant((void*)0);

    case VAR_RESOURCEREF:
        return Variant(ReadResourceRef());

    case VAR_RESOURCEREFLIST:
        return Variant(ReadResourceRefList());

    case VAR_VARIANTVECTOR:
        return Variant(ReadVariantVector());

    case VAR_STRINGVECTOR:
        return Variant(ReadStringVector());

    case VAR_VARIANTMAP:
        return Variant(ReadVariantMap());

    case VAR_INTRECT:
        return Variant(ReadIntRect());

    case VAR_INTVECTOR2:
        return Variant(ReadIntVector2());

    case VAR_MATRIX3:
        return Variant(ReadMatrix3());

    case VAR_MATRIX3X4:
        return Variant(ReadMatrix3x4());

    case VAR_MATRIX4:
        return Variant(ReadMatrix4());

    case VAR_DOUBLE:
        return Variant(ReadDouble());

    default:
        return Variant();
    }
}
开发者ID:unixjet,项目名称:ktblaze,代码行数:77,代码来源:Deserializer.cpp

示例14: ReadTableArray

void IO_UncertSimResults::ReadTableArray(DC_TableArray& tableArray)
{
    tableArray.AllocAndSetSize(ReadInt());
    for (int i = 0; i < tableArray.Size(); i++)
        ReadTable(tableArray[i]);
}
开发者ID:jjayne,项目名称:nSIGHTS,代码行数:6,代码来源:IO_UncertSimResults.cpp

示例15: Load

const bool ControllerMapping::Load(const std::wstring& filename, const wchar_t* defaultJoystick)
{
	const wchar_t*& joy = defaultJoystick; //shorter so it fits into the layout
	const wchar_t* filename_c = filename.c_str();
	//buttons
	if(!ReadInt(L"button_1",			L"joystick", joy,  filename_c, Buttons[eButton1].Joy,    -1, 3)) return false;
	if(!ReadInt(L"button_1",			L"button",   L"0", filename_c, Buttons[eButton1].Button, 0, NUM_DIGITAL-1)) return false;

	if(!ReadInt(L"button_2",			L"joystick", joy,  filename_c, Buttons[eButton2].Joy,    -1, 3)) return false;
	if(!ReadInt(L"button_2",			L"button",   L"1", filename_c, Buttons[eButton2].Button, 0, NUM_DIGITAL-1)) return false;

	if(!ReadInt(L"button_3",			L"joystick", joy,  filename_c, Buttons[eButton3].Joy,    -1, 3)) return false;
	if(!ReadInt(L"button_3",			L"button",   L"2", filename_c, Buttons[eButton3].Button, 0, NUM_DIGITAL-1)) return false;

	if(!ReadInt(L"button_4",			L"joystick", joy,  filename_c, Buttons[eButton4].Joy   , -1, 3)) return false;
	if(!ReadInt(L"button_4",			L"button",   L"3", filename_c, Buttons[eButton4].Button, 0, NUM_DIGITAL-1)) return false;

	if(!ReadInt(L"button_start",		L"joystick", joy,  filename_c, Buttons[eButtonStart].Joy,    -1, 3)) return false;
	if(!ReadInt(L"button_start",		L"button",   L"7", filename_c, Buttons[eButtonStart].Button, 0, NUM_DIGITAL-1)) return false;

	if(!ReadInt(L"button_analog_stick",	L"joystick", joy,  filename_c, Buttons[eButtonJoystick].Joy,    -1, 3)) return false;
	if(!ReadInt(L"button_analog_stick",	L"button",   L"6", filename_c, Buttons[eButtonJoystick].Button, 0, NUM_DIGITAL-1)) return false;

	if(!ReadInt(L"button_bumper",		L"joystick", joy,  filename_c, Buttons[eButtonBumper].Joy,    -1, 3)) return false;
	if(!ReadInt(L"button_bumper",		L"button",   L"4", filename_c, Buttons[eButtonBumper].Button, 0, NUM_DIGITAL-1)) return false;

	//  axes

	//position
	if(!ReadInt(L"axis_x", L"joystick", joy,      filename_c, Position[0].Joy,  -1, 3)) return false;
	if(!ReadInt(L"axis_x", L"axis",     L"0",     filename_c, Position[0].Axis, 0, NUM_ANALOG-1)) return false;
	if(!ReadBool(L"axis_x",L"inverted", L"false", filename_c, Position[0].Inverted)) return false;
	if(!ReadInt(L"axis_x", L"range",    L"100",   filename_c, Position[0].Range, 0, INT_MAX)) return false;

	if(!ReadInt(L"axis_y", L"joystick", joy,      filename_c, Position[1].Joy,  -1, 3)) return false;
	if(!ReadInt(L"axis_y", L"axis",     L"1",     filename_c, Position[1].Axis, 0, NUM_ANALOG-1)) return false;
	if(!ReadBool(L"axis_y",L"inverted", L"false", filename_c, Position[1].Inverted)) return false;
	if(!ReadInt(L"axis_y", L"range",    L"100",   filename_c, Position[1].Range, 0, INT_MAX)) return false;

	if(!ReadInt(L"axis_z", L"joystick", joy,      filename_c, Position[2].Joy,  -1, 3)) return false;
	if(!ReadInt(L"axis_z", L"axis",     L"2",     filename_c, Position[2].Axis, 0, NUM_ANALOG-1)) return false;
	if(!ReadBool(L"axis_z",L"inverted", L"false", filename_c, Position[2].Inverted)) return false;
	if(!ReadInt(L"axis_z", L"range",    L"100",   filename_c, Position[2].Range, 0, INT_MAX)) return false;

	//rotation
	if(!ReadInt(L"axis_pitch", L"joystick", joy,      filename_c, Rotation[ePitch].Joy,  -1, 3)) return false;
	if(!ReadInt(L"axis_pitch", L"axis",     L"3",     filename_c, Rotation[ePitch].Axis, 0, NUM_ANALOG-1)) return false;
	if(!ReadBool(L"axis_pitch",L"inverted", L"false", filename_c, Rotation[ePitch].Inverted)) return false;
	if(!ReadInt(L"axis_pitch",   L"range",    L"45",  filename_c, Rotation[ePitch].Range, 0, 180)) return false;

	if(!ReadInt(L"axis_yaw",   L"joystick", joy,      filename_c, Rotation[eYaw].Joy,    -1, 3)) return false;
	if(!ReadInt(L"axis_yaw",   L"axis",     L"4",     filename_c, Rotation[eYaw].Axis,   0, NUM_ANALOG-1)) return false;
	if(!ReadBool(L"axis_yaw",  L"inverted", L"false", filename_c, Rotation[eYaw].Inverted)) return false;
	if(!ReadInt(L"axis_yaw",   L"range",    L"45",    filename_c, Rotation[eYaw].Range, 0, 180)) return false;

	if(!ReadInt(L"axis_roll",  L"joystick", joy,      filename_c, Rotation[eRoll].Joy,   -1, 3)) return false;
	if(!ReadInt(L"axis_roll" , L"axis",     L"5",     filename_c, Rotation[eRoll].Axis,  0, NUM_ANALOG-1)) return false;
	if(!ReadBool(L"axis_roll", L"inverted", L"false", filename_c, Rotation[eRoll].Inverted)) return false;
	if(!ReadInt(L"axis_roll",  L"range",    L"45",    filename_c, Rotation[eRoll].Range, 0, 180)) return false;

	//trigger
	if(!ReadBool(L"trigger", L"isAxis", L"false", filename_c, TriggerIsAxis)) return false;
	if(TriggerIsAxis)
	{
		if(!ReadInt(L"trigger", L"joystick", joy,      filename_c, TriggerAxis.Joy,  -1, 3)) return false;
		if(!ReadInt(L"trigger", L"axis",     L"7",     filename_c, TriggerAxis.Axis, 0, NUM_ANALOG-1)) return false;
		if(!ReadBool(L"trigger",L"inverted", L"false", filename_c, TriggerAxis.Inverted)) return false;
		if(!ReadBool(L"trigger",L"useFullAxis", L"false",filename_c,TriggerUseFullAxis)) return false;
	}
	else
	{
		if(!ReadInt(L"trigger", L"joystick", joy,  filename_c, TriggerButton.Joy,    -1, 3)) return false;
		if(!ReadInt(L"trigger", L"button",   L"5", filename_c, TriggerButton.Button, 0, NUM_DIGITAL-1)) return false;
	}
	
	//analog stick X
	if(!ReadBool(L"analog_stick_x", L"isAxis", L"true", filename_c, JoystickXIsAxis)) return false;
	if(JoystickXIsAxis)
	{
		if(!ReadInt(L"analog_stick_x", L"joystick", joy,      filename_c, JoystickXAxis.Joy,  -1, 3)) return false;
		if(!ReadInt(L"analog_stick_x", L"axis",     L"6",     filename_c, JoystickXAxis.Axis, 0, NUM_ANALOG-1)) return false;
	}
	else
	{
		if(!ReadInt(L"analog_stick_x", L"joystick_left", joy,  filename_c, JoystickXButtons.Min.Joy,    -1, 3)) return false;
		if(!ReadInt(L"analog_stick_x", L"button_left",   L"9", filename_c, JoystickXButtons.Min.Button, 0, NUM_DIGITAL-1)) return false;
		if(!ReadInt(L"analog_stick_x", L"joystick_right", joy,   filename_c, JoystickXButtons.Max.Joy,    -1, 3)) return false;
		if(!ReadInt(L"analog_stick_x", L"button_right",   L"10", filename_c, JoystickXButtons.Max.Button, 0, NUM_DIGITAL-1)) return false;
	}
	
	//analog stick Y
	if(!ReadBool(L"analog_stick_y", L"isAxis", L"true", filename_c, JoystickYIsAxis)) return false;
	if(JoystickYIsAxis)
	{
		if(!ReadInt(L"analog_stick_y", L"joystick", joy,      filename_c, JoystickYAxis.Joy, -1, 3)) return false;
		if(!ReadInt(L"analog_stick_y", L"axis",     L"7",     filename_c, JoystickYAxis.Axis, 0, NUM_ANALOG-1)) return false;
	}
	else
	{
		if(!ReadInt(L"analog_stick_y", L"joystick_left", joy,   filename_c, JoystickYButtons.Min.Joy, -1, 3)) return false;
//.........这里部分代码省略.........
开发者ID:etoraman,项目名称:Razer-Hydra-DirectInput-Wrapper,代码行数:101,代码来源:ControllerMapping.cpp


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