/* getString tries to read string from the pipe
   If succeed, return 0, -1 on error
*/
int CReadBuffer::getString(char ** x) {

    if (x == NULL)
      return -1;

    *x = NULL;
    
    int rc = 0;
    int length;

    rc = getInt(&length);
    if (rc <= 0) {
        *x = NULL;
        return -1;
    }

    char* buff;
    buff = (char *) malloc((length + 1) * sizeof(char));
    
    if (buff == NULL) {
      *x = NULL;
      return -1;
    }
    
    rc = getIt(buff,length); 

    if (rc == length) {
      buff[length] = 0;
      *x = buff;
    }
    else
      ::free(buff);

    return rc == length ? 0:-1;
}
int CReadBuffer::getShort(short * x) {

    char buff[2];
    int rv = getIt(buff, 2);
    short result = (buff[0] << 8) |
		   (buff[1] & 0xFF);
    *x = result;
    return rv;
}
int CReadBuffer::getInt(int * x) {

    char buff[4];
    int rv = getIt(buff, 4);
    int result = (buff[0] << 24) |
		 ((buff[1] << 16) & 0xFF0000) |
		 ((buff[2] << 8) & 0xFF00) |
		 (buff[3] & 0xFF);
    *x = result;
    return rv;
}
Beispiel #4
0
int _tmain(int argc, _TCHAR* argv[])
{
	std::string s;
	s = "22";
	printf("%s\n", s.c_str());

	ttt t;
	std::vector<ttt> v;
	v.push_back(t);
	std::vector<ttt> v2 = v;
	ttt t2;
	{
		CallTimeRecorder t("new 2000000");
		CorbaNameExList lst = getIt();
	}
	return 0;
}
vector<double>* OutputFile::getRoverM(ParamQt*param)
{
  vector<double>*v=new vector<double>();
  startOver();
  while (getIt(param))
    {
      v->push_back(param->getRM());
    }
  startOver();
  return v;

  /*int L=getL();
  int b=getB();
  vector<double>*v=new vector<double>();
  //for (unsigned int i=0;i<rhos.size();i++) v->push_back(rhos[i]/thetas[i]*L*deltas[i]/(deltas[i]*b+L-b)*0.75*(1.0-exp(-4.0*thetas[i]/L)));
  for (unsigned int i=0;i<rhos.size();i++) v->push_back(rhos[i]/thetas[i]*L*deltas[i]/(deltas[i]*b+L-b)*3.0*thetas[i]/(3.0*L+4.0*thetas[i]));
  return v;*/
}
int CReadBuffer::getByte(char * x) {
    return getIt((char *) x, 1);
}
Beispiel #7
0
  //possible inputs for media in .egsinp file
  std::vector<string> codes1;
  codes1.push_back("elements");
  codes1.push_back("no. of atoms");
  codes1.push_back("mass fractions");
  codes1.push_back("rho");
  codes1.push_back("stopping powers");
  codes1.push_back("bremsstrahlung correction");
  codes1.push_back("gas pressure");
  codes1.push_back("density correction file");
  codes1.push_back("sterncid");

  DE_Parser *p = new DE_Parser(codes,0,"media definition", in, false);

  rPEGSLESS->AE         = getIt( codes[0] , "", rPEGSLESS->errors, p );
  rPEGSLESS->UE         = getIt( codes[1] , "", rPEGSLESS->errors, p );
  rPEGSLESS->AP         = getIt( codes[2] ,"", rPEGSLESS->errors, p );
  rPEGSLESS->UP        = getIt( codes[3] ,"", rPEGSLESS->errors, p );
  rPEGSLESS->matdatafile         = getIt( codes[4] ,"", rPEGSLESS->errors, p );

  //now search for media defined in the .egsinp file
  //set multiple entries to true to allow for multiple media defined
  DE_Parser *p2 = new DE_Parser(med_delims,0,"media definition", in, true);

  bool loop=true;
  while (loop) {

     //qt3to4 -- BW
     //string temp_start = getIt( codes[5] ,"", rPEGSLESS->errors, p );
     //string temp_stop = getIt( codes[6] ,"", rPEGSLESS->errors, p );
Beispiel #8
0
}

std::ifstream & operator >> ( std::ifstream & in, MMCInputs*  rMC )
{
	std::vector<string> codes;
	codes.push_back("NUMBER OF HISTORIES");
	codes.push_back("MAX CPU HOURS ALLOWED");
	codes.push_back("IFULL");
	codes.push_back("STATISTICAL ACCURACY SOUGHT");
	codes.push_back("SCORE KERMA");
	codes.push_back("PHOTON REGENERATION");
	codes.push_back("INITIAL RANDOM NO. SEEDS");

	DE_Parser *p = new DE_Parser(codes,0,"Monte Carlo inputs", in, false);

	rMC->ncase   = getIt( codes[0] , "20000", rMC->errors, p ) ;
	rMC->maxcpu  = getIt( codes[1] , "60", rMC->errors, p ) ;
  	if ( ( rMC->gusercode() != sprrznrc ) && ( rMC->gusercode() != flurznrc ) ){
		rMC->ifull   = getIt( codes[2] , "dose and stoppers", rMC->errors, p ) ;
		rMC->stat    = getIt( codes[3] , "0.1", rMC->errors, p ) ;
	}
	if ( rMC->gusercode() == dosrznrc) {
		rMC->kerma   = getIt( codes[4] , "no", rMC->errors, p ) ;
	}
	else if ( rMC->gusercode() != flurznrc ) {
        	rMC->photreg = getIt( codes[5] , "no", rMC->errors, p ) ;
	}

	rMC->rnd   = getThem( codes[6], 1, 1073741824, rMC->rnd, rMC->errors, p ) ;
//	if ( rMC->rnd[0] > 4 ) {
//		rMC->rnd[0] = 1;