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


C++ std::exit方法代码示例

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


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

示例1: Keyboard

void Keyboard(unsigned char key, int x, int y)
{
    switch(key)
    {
        case 27: //ESC
            exit(0);
            break;
        case 't':   //'t' has been pressed. this will toggle tracking
        case 'T':
            trackingEnabled = !trackingEnabled;
            if (trackingEnabled == false) status = "Tracking disabled.";
            else status = "Tracking enabled.";
            break;
        case 'p':   //'p' has been pressed. this will pause/resume the code.
        case 'P':
            pauses = !pauses;
            if (pauses == true) {
                status = "Code paused, press 'p' again to resume";
                while (pauses == true) {
                    //stay in this loop until
                    switch (waitKey()) {
                        case 112:
                            //change pause back to false
                            pauses = false;
                            status = "Code resumed.";
                            break;
                    }
                }
            }
            break;
        case 'd':
        case 'D': //'d' has been pressed. this will debug mode
            debugMode = !debugMode;
            if (debugMode == false) status = "Debug mode disabled.";
            else status = "Debug mode enabled.";
            break;
            break;
    }
}
开发者ID:lcheek3,项目名称:CS480-Project-2,代码行数:39,代码来源:main.cpp

示例2: main

int main()
{
    // Set skt abort function to mine (above)
    skt_set_abort(my_skt_abort);

    SERVER_SOCKET srv = skt_server(&port);
    if (srv == -1)
    {
        cerr << "Error: Could not reserve port #" << port << endl;
        cerr << "EXITING" << endl;
        exit(1);
    }

    while (true)
    {
        listen(srv);
    }

    // Done; close server socket
    skt_close(srv);

    return 0;
}
开发者ID:permutationlock,项目名称:neural_network_checkers,代码行数:23,代码来源:tcp_server1.cpp

示例3: loadCameraFromFile

void PPC::loadCameraFromFile(string fName)
{
	// ifstream constructor opens the file
	ifstream inFile(fName, ios::in);

	// exit program if unable to create file
	if (!inFile) { // overloaded ! operator
		cerr << "Camera saved file could not be loaded" << endl;
		exit(1);
	}

	// read camera contents to file sequentially
	inFile >> a;
	inFile >> b;
	inFile >> c;
	inFile >> C;
	inFile >> w;
	inFile >> h;

	buildProjM();

	return; // ifstram destructor closes file
}
开发者ID:centauroWaRRIor,项目名称:InteractiveGraphics,代码行数:23,代码来源:ppc.cpp

示例4: decrypt

int Cryption::decrypt(int fd){

  string IVContents, decryptionKey, decodedKey, decodedIV;

  IVContents = read(fd);
  string encodedIV = IVContents.substr(0,32);
  string FileContents = IVContents.substr(encodedIV.length());

  //Decoding the Key
  decryptionKey = getKey();
  StringSource(decryptionKey, true, new HexDecoder(new StringSink(decodedKey)));
  const byte* dbyteKey = (const byte*) decodedKey.data();

  //Decoding the IV
  StringSource(encodedIV, true, new HexDecoder(new StringSink(decodedIV)));
  const byte* IV = (const byte*) decodedIV.data();

  string decryptedContents;
  //Decrypting actual file
  try{
    CBC_Mode< AES >::Decryption d;
    d.SetKeyWithIV(dbyteKey, CryptoPP::AES::DEFAULT_KEYLENGTH, IV);
    StringSource de(FileContents, true, new StreamTransformationFilter(d, new StringSink (decryptedContents)));
  }
  catch(const CryptoPP::Exception& e){
    cerr<<e.what()<<endl;
    exit(1);
  }


  string DContents = decryptedContents;
  const char *OriginalContents = DContents.c_str();
  ssize_t WriteLength = pwrite(fd, OriginalContents, DContents.length(), 0);
  ftruncate(fd, DContents.length());

  return 0;
}
开发者ID:sravannerella,项目名称:S3FSEncryption,代码行数:37,代码来源:fdcache.cpp

示例5: encrypt

int Cryption::encrypt(int fd){
  AutoSeededRandomPool prng;
  string encryptedBytes, encodedKey, decodedKey;

  encodedKey = getKey();
  cout<<"Encode: "<<encodedKey<<endl;
  StringSource(encodedKey, true, new HexDecoder(new StringSink(decodedKey)));
  cout<<"Decode: "<<decodedKey<<endl;
  const byte* ebyteKey = (const byte*) decodedKey.data();

  string encodedIV;
  //createIV
  byte IVBytes[AES::BLOCKSIZE];
  prng.GenerateBlock(IVBytes, sizeof(IVBytes));
  StringSource(IVBytes, sizeof(IVBytes), true, new HexEncoder(new StringSink(encodedIV)));

  encryptedBytes = read(fd);

  string encryptedContents;
  //Encrypting the file contents
  try{
    CBC_Mode< AES >::Encryption e;
    e.SetKeyWithIV(ebyteKey, CryptoPP::AES::DEFAULT_KEYLENGTH, IVBytes);
    StringSource file(encryptedBytes, true, new StreamTransformationFilter(e,new StringSink(encryptedContents)));
  }
  catch( const CryptoPP::Exception& e ){
    cerr << e.what() << endl;
    exit(1);
  }

  string output = encodedIV + encryptedContents;
  const char *bufContents = output.c_str();
  ssize_t WriteLength = pwrite(fd, bufContents, output.length(), 0);
  ftruncate(fd, output.length());
  
  return 0;
}
开发者ID:sravannerella,项目名称:S3FSEncryption,代码行数:37,代码来源:fdcache.cpp

示例6: exit

void CellLine::getParameters_LQ3(double &returnAlpha_X3,
                                 double &returnBeta_X3,
                                 double &returnD_t3,
                                 double &returnGenome_Length,
                                 double &returnAlpha_SSB,
                                 double &returnAlpha_DSB,
                                 long int &returnBase_Pairs) const
{
    if( isLQ3loaded )
    {
        returnAlpha_X3 = alpha_X3;
        returnBeta_X3 = beta_X3;
        returnD_t3 = D_t3;
        returnGenome_Length = genomeLength;
        returnAlpha_SSB = alpha_SSB;
        returnAlpha_DSB = alpha_DSB;
        returnBase_Pairs = base_Pairs;
    }
    else
    {
        cerr << "CellLine: the LQ3 parametrization has not been loaded." << endl;
        exit(1);
    }
}
开发者ID:batuff,项目名称:Survival,代码行数:24,代码来源:CellLine.cpp

示例7: exit

double Track_Elsasser2007::getRadialIntegral(const double r_min,
                                             const double r_max) const
{
   if( r_min < 0. || r_max < r_min )
   {
      cerr << "double Track_Elsasser2007::getRadialIntegral(const double, const double) const -- Invalid r_min, r_max specified." << endl;
      exit(1);
   }

   if( r_max == r_min )
      return 0.;

   cerr << "Warning: implementation of double Track_Elsasser2007::getRadialIntegral(const double, const double) const not complete." << endl;

//    double r_end = (r_max < r_penumbra ? r_max : r_penumbra);
//    double dose = 0.;
//    if( r_min < r_core )
//    {
//       if( r_max <= r_core )
//          dose += dose_core * (r_max*r_max - r_min*r_min);
//       else
//       {
//          dose += dose_core * (r_core*r_core - r_min*r_min);
// 
// 
//          dose += 2 * k_p * log(r_end / r_core);
//       }
//    }
//    else if( r_min < r_penumbra )
//    {
//       dose += 2 * k_p * log(r_end / r_min);
//    }
// 
//    return dose / (r_max*r_max - r_min*r_min);
   return -1.;
}
开发者ID:batuff,项目名称:Survival,代码行数:36,代码来源:Track_Elsasser2007.cpp

示例8: createTextFile

// create formatted text file for printing
void createTextFile( fstream &readFromFile )
{
   // create text file
   ofstream outPrintFile( "print.txt", ios::out );

   // exit program if ofstream cannot create file
   if ( !outPrintFile ) 
   {
      cerr << "File could not be created." << endl;
      exit( 1 );
   } // end if

   outPrintFile << left << setw( 10 ) << "Account" << setw( 16 )
      << "Last Name" << setw( 11 ) << "First Name" << right
      << setw( 10 ) << "Balance" << endl;

   // set file-position pointer to beginning of readFromFile
   readFromFile.seekg( 0 );

   // read first record from record file
   ClientData client;
   readFromFile.read( reinterpret_cast< char * >( &client ),
      sizeof( ClientData ) );

   // copy all records from record file into text file
   while ( !readFromFile.eof() ) 
   {
      // write single record to text file
      if ( client.getAccountNumber() != 0 ) // skip empty records
         outputLine( outPrintFile, client );

      // read next record from record file
      readFromFile.read( reinterpret_cast< char * >( &client ), 
         sizeof( ClientData ) );
   } // end while
} // end function createTextFile
开发者ID:tecmilenio,项目名称:computacion2,代码行数:37,代码来源:Fig17_15.cpp

示例9: main

int main(int argc, char* argv[])
{
	AutoSeededRandomPool prng;

	byte key[AES::DEFAULT_KEYLENGTH] = {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f};
	//prng.GenerateBlock(key, sizeof(key));  /* For pseudo random key generation */

	byte plain[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff};
	string cipher, encoded, recovered;

	/**************************************************************************************
	NOTE:
	***************************************************************************************
	-- plaintext can also be changed to type string of 16 bytes i.e. 16 characters
	-- Only Decryption can also be performed on the same basis
	****************************************************************************************/

	if(sizeof(key) != BLOCK_SIZE_BYTES || sizeof(plain) != BLOCK_SIZE_BYTES)
	{
		cerr << "Either plainText or Key has improper block size" << endl;
		exit(1);
	}

	/*********************************\
	\*********************************/

	// print key
	encoded.clear();
	StringSource(key, sizeof(key), true,
		new HexEncoder(
			new StringSink(encoded)
		) // HexEncoder
	); // StringSource
	cout << "key: " << encoded << endl;

	/*********************************\
	\*********************************/

	try
	{
		cout << "plain text: " << plain << endl;

		ECB_Mode< AES >::Encryption e;
		e.SetKey(key, sizeof(key));

		StringSource ss(plain, sizeof(plain), true, 
			new StreamTransformationFilter(e,
				new StringSink(cipher)//,
					//BlockPaddingScheme::NO_PADDING
			) // StreamTransformationFilter      
		); // StringSource
	}
	catch(const CryptoPP::Exception& e)
	{
		cerr << e.what() << endl;
		exit(1);
	}

	/*********************************\
	\*********************************/

	// print Cipher Text
	encoded.clear();
	StringSource(cipher, true,
		new HexEncoder(
			new StringSink(encoded)
		) // HexEncoder
	); // StringSource
	encoded.resize(16*2);
	cout << "cipher text: " << encoded << endl;

	/*********************************\
	\*********************************/

	try
	{
		ECB_Mode< AES >::Decryption d;
		d.SetKey(key, sizeof(key));

		StringSource s(cipher, true, 
			new StreamTransformationFilter(d,
				new StringSink(recovered)
			) // StreamTransformationFilter
		); // StringSource

		cout << "recovered text: " << recovered << endl;
	}
	catch(const CryptoPP::Exception& e)
	{
		cerr << e.what() << endl;
		exit(1);
	}

	/*********************************\
	\*********************************/

	return 0;
}
开发者ID:chiggum,项目名称:crypto,代码行数:98,代码来源:aes_library_implementation.cpp

示例10: main

int main(void) {
  int ret;
  // register Ctrl-C handler
  std::signal(SIGINT, exitGraceful);

  if (0 != initialize_enclave(&eid)) {
    cerr << "failed to init enclave" << endl;
    exit(-1);
  }

  mbedtls_net_context listen_fd, client_fd;
  // initialize the object
  ssl_conn_init(eid);
  // initialize threads
  memset(threads, 0, sizeof(threads));

  mbedtls_printf("  . Bind on https://localhost:4433/ ...");
  fflush(stdout);

  if ((ret = mbedtls_net_bind(&listen_fd, NULL, "4433", MBEDTLS_NET_PROTO_TCP)) != 0) {
    mbedtls_printf(" failed\n  ! mbedtls_net_bind returned %d\n\n", ret);
    std::exit(-1);
  }

  mbedtls_printf(" ok\n");

  mbedtls_printf("  [ main ]  Waiting for a remote connection\n");

  // non-block accept
  while (true) {
    // check for Ctrl-C flag
    std::this_thread::sleep_for (std::chrono::seconds(1));
    if (quit.load()) {
      cerr << "Ctrl-C pressed. Quiting..." << endl;
      break;
    }

#ifdef MBEDTLS_ERROR_C
    if (ret != 0) {
      char error_buf[100];
      mbedtls_strerror(ret, error_buf, 100);
      mbedtls_printf("  [ main ]  Last error was: -0x%04x - %s\n", -ret, error_buf);
    }
#endif

    /*
     * 3. Wait until a client connects
     */

    if (0 != mbedtls_net_set_nonblock(&listen_fd)) {
      cerr << "can't set nonblock for the listen socket" << endl;
    }
    ret = mbedtls_net_accept(&listen_fd, &client_fd, NULL, 0, NULL);
    if (ret == MBEDTLS_ERR_SSL_WANT_READ) {
      ret = 0;
      continue;
    } else if (ret != 0) {
      mbedtls_printf("  [ main ] failed: mbedtls_net_accept returned -0x%04x\n", ret);
      break;
    }

    mbedtls_printf("  [ main ]  ok\n");
    mbedtls_printf("  [ main ]  Creating a new thread for client %d\n", client_fd.fd);

    if ((ret = thread_create(&client_fd)) != 0) {
      mbedtls_printf("  [ main ]  failed: thread_create returned %d\n", ret);
      mbedtls_net_free(&client_fd);
      continue;
    }
    ret = 0;
  } // while (true)

  sgx_destroy_enclave(eid);
  return (ret);
}
开发者ID:bl4ck5un,项目名称:mbedtls-SGX,代码行数:75,代码来源:m_server.cpp

示例11: main

int main (int argc, char ** argv)
{
   const clock_t begin_time = clock();
   const solreal begin_walltime = time(NULL);
   string infilnam,outfilnam,gnpnam;
   string progname;
   optFlags options;
   ifstream ifile;
   ofstream ofile;
   
   getOptions(argc,argv,options); //This processes the options from the command line.
   mkFileNames(argv,options,infilnam,outfilnam,gnpnam); //This creates the names used.
   printHappyStart(argv,CURRENTVERSION,PROGRAMCONTRIBUTORS); //Just to let the user know that the initial configuration is OK
   
   cout << endl << "Loading wave function from file: " << infilnam << "... ";
   
   GaussWaveFunction gwf;
   if (!(gwf.readFromFile(infilnam))) { //Loading the wave function
      setScrRedBoldFont();
      cout << "Error: the wave function could not be loaded!\n";
      setScrNormalFont();
      exit(1);
   }
   cout << "Done." << endl;
   
   bondNetWork bnw;
   bnw.readFromFile(infilnam); //Loading the bond-network (if the wave function
                               //was read, there souldn't be problems here.
   bnw.setUpBNW();             //To setup the bond network.
   
   waveFunctionGrid2D grid;    //Defining a grid object
   
   /* Looking for user grid dimensions */
   
   int nn=DEFAULTPOINTSPERDIRECTION;
   if (options.setn1) {
      sscanf(argv[options.setn1],"%d",&nn);
      grid.setNPts(nn);
   } else {
      grid.setNPts(nn);
   }
   
   /* Defining the line direction and other properties, and setting up the grid */
   
   int at1=0,at2=1,at3=2;
   if (bnw.nNuc==1) {
      at1=at2=0,at3=0;
      grid.setUpSimplePlane(bnw,0);
      cout << "The file " << infilnam << " has only one atom" << endl;
      cout << "Using this atom to set the plane...\n";
   } else if (bnw.nNuc==2) {
      at1=0;
      at2=at3=1;
      grid.setUpSimplePlane(bnw,0,1);
      cout << "The file " << infilnam << " has only two atoms" << endl;
      cout << "Using these atoms to set the plane...\n";
   } else {
      if (options.setats) {
         sscanf(argv[options.setats],"%d",&at1);
         sscanf(argv[options.setats+1],"%d",&at2);
         sscanf(argv[options.setats+2],"%d",&at3);
         if (at1<1||at2<1||at3<1||at1>bnw.nNuc||at2>bnw.nNuc||at3>bnw.nNuc) {
            setScrRedBoldFont();
            cout << "Error: one of the given atoms do not exist!\n";
            setScrNormalFont();
            exit(1);
         }
         cout << "Using atoms " << at1 << "(" << bnw.atLbl[at1-1]
         << "), " << at2 << "(" << bnw.atLbl[at2-1] << "), and "
         << at3 << "(" << bnw.atLbl[at3-1] << ") to set the plane."
         << endl;
         at1--;
         at2--;
         at3--;
         grid.setUpSimplePlane(bnw,at1,at2,at3);
      } else {
         at1=at2=at3=0;
         grid.setUpSimplePlane(bnw,0);
         cout << "Using the first atom to set the line...\n";
      }
   }
   //cout << "checkpoint" << endl;
   cout << "The size of the grid will be: " << grid.getNPts(0) << "x" << grid.getNPts(1) << endl;
   cout << "Total number of points that will be computed: " << grid.getNPts(0)*grid.getNPts(1) << endl;
   
   /* Setting the property to be computed */
   
   char prop;
   if (options.prop2plot) {
      prop=argv[options.prop2plot][0];
   } else {
      prop='d';
   }
   
   /* Main calculation loop, chooses between different available fields. */
   
   cout << "Evaluating and writing property..." << endl;
   cout << "(Scalar Field to plot: " << getFieldTypeKeyLong(prop) << ")." << endl << endl;
   switch (prop) {
      case 'd':
//.........这里部分代码省略.........
开发者ID:jmsolano,项目名称:denstoolkit,代码行数:101,代码来源:dtkplane.cpp

示例12: makeGnuplotFile

//*******************************************************************************************
void makeGnuplotFile(optFlags &opts, string &gnpn,string &outn,char p2p,
                     solreal dimparam,bondNetWork &bn,int a1,int a2,int a3,waveFunctionGrid2D &grd)
{
   ofstream gfil;
   gfil.open(gnpn.c_str());
   
   /* Choosing the label (legend) for the plot  and the zrange for the plot */
   solreal minzrange,maxzrange;
   string plbl=getFieldTypeKeyShort(p2p);;
   switch (p2p) {
      case 'd':
         minzrange=0.0e0;
         maxzrange=0.6e0;
         break;
      case 'g':
         minzrange=0.0e0;
         maxzrange=2.0e0;
         break;
      case 'l':
         minzrange=-2.0e0;
         maxzrange=2.0e0;
         break;
      case 'E':
         minzrange=0.0e0;
         maxzrange=1.0e0;
         break;
      case 'S':
         minzrange=-10.0e0;
         maxzrange=10.0e0;
         break;
      case 'L':
         minzrange=0.0e0;
         maxzrange=1.0e0;
         break;
      case 'M':
         minzrange=0.0e0;
         maxzrange=2.0e0;
         break;
      case 'N':
         minzrange=0.0e0;
         maxzrange=2.0e0;
         break;
      case 'G':
         minzrange=0.0e0;
         maxzrange=10.0e0;
         break;
      case 'K':
         minzrange=0.0e0;
         maxzrange=10.0e0;
         break;
      case 'p' :
         minzrange=0.0e0;
         maxzrange=2.0e0;
         break;
      case 'P' :
         minzrange=0.0e0;
         maxzrange=2.0e0;
         break;
      case 'r' :
         minzrange=-1.0e0;
         maxzrange=1.0e0;
         break;
      case 's' :
         minzrange=0.0e0;
         maxzrange=1.0e0;
         break;
      case 'u' :
         minzrange=-1.0e0;
         maxzrange=1.0e0;
         break;
      case 'U' :
         minzrange=-1.0e0;
         maxzrange=1.0e0;
         break;
      case 'V':
         minzrange=-0.6e0;
         maxzrange=0.6e0;
         break;
      default:
         setScrRedBoldFont();
         cout << "Error: The property \"" << p2p << "\" does not exist!" << endl;
         setScrNormalFont();
         exit(1);
         break;
   }
   
   gfil << "reset" << endl;
   
   /* In this part the name is scanned for possible occurrings of the character '_'.
    For a proper display in the eps file, it has to be changed to "\_" */
   string line="";
   for (size_t i=0; i<outn.length(); i++) {
      if (outn[i]=='_') {line+='\\';}
      line+=outn[i];
   }
   gfil << "set title '" << line << "'" << endl;
   
   /* Adding an underscore and braces to the atome labels in order to make the numbers
    subindices */
//.........这里部分代码省略.........
开发者ID:jmsolano,项目名称:denstoolkit,代码行数:101,代码来源:dtkplane.cpp

示例13: main

int main(int argc, char* argv[])
{
	//Tabela consulta comando
		//Armazena comando HELO
		char helo[6] = "helo ";
		char H_E_L_O[6] = "HELO ";
		//Armazena comando MAIL FROM
		char mail[11] = "mail from:";
		char M_A_I_L[11] = "MAIL FROM:";
		//Armazena comando RCPT
		char rcpt[9] = "rcpt to:";
		char R_C_P_T[9] = "RCPT TO:";
		//Fim de comando
		//char fim[3] = "\r\n";
		char at = '@';
		//Armazena comando DATA
		char D_A_T_A[7] = "DATA\r\n";
		char data[7] = "data\r\n";
		//Armazena comando RSET
		char R_S_E_T[7] = "RSTE\r\n";
		char rset[7] = "rste\r\n";
		//Armazena comando NOOP
		char N_O_O_P[7] = "NOOP\r\n";
		char noop[7] = "noop\r\n";
		//Armazena comando QUIT
		char Q_U_I_T[7] = "QUIT\r\n";
		char quit[7] = "quit\r\n";


    int sock, cliente_sock;
    struct sockaddr_in sock_param, cliente;
    socklen_t addrlen= sizeof(cliente);

	string recebe, envia; //strings dos textos
	const char *char_envia; //usado como parametro no write
	char char_recebe[TAMANHO_BUFFER_RECEBE];
	//char *char_recebe; //usado como parametro no read

	sock = socket(AF_INET, SOCK_STREAM, 0);

	if (sock==-1) //ou <0
		{
	 	perror("opening stream socket"); //erro ao abrir o socket
	 	exit(1);
		}

	bzero(&sock_param, sizeof(sock_param)); //zera o resto da estrutura
	sock_param.sin_family = AF_INET; //declaração da familia arpa net
	sock_param.sin_port=htons(PORTA); /*25 eh a SMTP PORT */
	sock_param.sin_addr.s_addr = INADDR_ANY; //aceita conexão de qq ip, eh setado em 0.0.0.0

	bind (sock, (struct sockaddr*)&sock_param, sizeof(sock_param)); //vincula o socket a um endereço ip
	

	// Escutando Porta
	listen(sock, 5); //"escuta" o socket esperando conexao, numero de conexções q ele guenta ate a certa aparecer (5 maximo)

	
	while (1) //o servidor nunca para
	{
	//strings para formar arquivo
	//Armazena e-mail from
	string str_mail = "";
	//Armazena e-mail to
	string str_rcpt = "";
	//Armazena mensagem
	string mensagem = "";
	//Nome do arquivo
	string nome_arquivo = "";

	//O cliente conecta
	cliente_sock = accept(sock, (struct sockaddr*)&cliente, &addrlen);

	//Quando o servidor aceita uma comunicacao ele envia uma mensage (Primeira Mensagem)
	envia = "220 SERVIDOR TP1 SMTP\n";
	char_envia=envia.c_str(); //converte a string
	send(cliente_sock,char_envia,envia.length(),0);	//envia a msg pro cliente

	//inicializando variáveis a cada nova conexão
	recebeu_helo = false;
	recebeu_mail = false;
	recebeu_rcpt = false;
	recebeu_msg = false;
	recebeu_data = false;
	recebeu_rset = false;
	recebeu_noop = false;
	recebeu_quit = false;
	loop2 = true;

	do {//Loop2
		recebe.clear();
		
		//Esvazia char_recebe
		bzero(char_recebe,TAMANHO_BUFFER_RECEBE);
		//Escuta mensagens e se recebe armazena em "recebe"
		read(cliente_sock, char_recebe, TAMANHO_BUFFER_RECEBE);//;recv (, char_recebe, ,MSG_WAITALL);								
		recebe=string(char_recebe); //converte para string										

		if ((recebeu_data == true) && (recebeu_msg == false))
			{
//.........这里部分代码省略.........
开发者ID:thaliacampolina,项目名称:Redes,代码行数:101,代码来源:servidor.cpp

示例14: main

int main( int argc, char** argv )
{
	commandline_options cmdopt;
	get_commandline_options( cmdopt, argc, argv );

	typedef void (*generator_type)(
		const std::string&,
		std::ostream&,
		const GenerateOptions&,
		const symbol_map_type&,
		const symbol_map_type&,
		const std::map< size_t, std::string >&,
		const action_map_type&,
		const tgt::parsing_table& );
		
	std::map< std::string, generator_type > generators;
	generators["Java"]		= generate_java;
	generators["C#"]		= generate_csharp;
	generators["C++"]				= generate_cpp;
	generators["JavaScript"]		= generate_javascript;
	generators["D"]					= generate_d;

	std::ifstream ifs( cmdopt.infile.c_str() );
	if( !ifs ) {
		std::cerr << "caper: can't open input file '" << cmdopt.infile << "'" << std::endl;
		exit(1);
	}

	std::ofstream ofs( cmdopt.outfile.c_str() );
	if( !ofs ) {
		std::cerr << "caper: can't open output file '" << cmdopt.outfile << "'" << std::endl;
		exit(1);
	}

	// cpgスキャナ
	typedef std::istreambuf_iterator<char> is_iterator;
	is_iterator b( ifs );	// 即値にするとVC++が頓珍漢なことを言う
	is_iterator e;
	scanner< is_iterator > s( b, e );

	try {
		// cpgパーサ
		cpg::parser p;
		make_cpg_parser( p );

		// cpgパース
		Token token = token_empty;
		while( token != token_eof ) {
			value_type v;
			token = s.get( v );
			try {
				p.push( token, v );
			}
			catch( zw::gr::syntax_error& ) {
				throw syntax_error( v.range.beg, token );
			}
		}


		// 各種情報の収集
		GenerateOptions options;
		options.token_prefix = "token_";
		options.external_token = false;
		options.namespace_name = "caper_parser";
		options.dont_use_stl = false;

		symbol_map_type terminal_types;
		symbol_map_type nonterminal_types;
		collect_informations(
			options,
			terminal_types,
			nonterminal_types,
			p.accept_value() );

		// 対象文法の構文テーブルの作成
		tgt::parsing_table table;
		std::map< std::string, size_t > token_id_map;
		action_map_type actions;
		make_target_parser(
			table,
			token_id_map,
			actions,
			p.accept_value(),
			terminal_types,
			nonterminal_types,
			cmdopt.algorithm == "lr1" );

		// ターゲットパーサの出力
		std::map< size_t, std::string > reverse_token_id_map;
		for( std::map< std::string, size_t >::const_iterator i = token_id_map.begin() ;
			 i != token_id_map.end();
			 ++i ) {
			reverse_token_id_map[(*i).second] = (*i).first;
		}
		generators[ cmdopt.language ](
			cmdopt.outfile,
			ofs,
			options,
			terminal_types,
			nonterminal_types,
//.........这里部分代码省略.........
开发者ID:y-fujii,项目名称:caper,代码行数:101,代码来源:caper.cpp

示例15: setParametrization

void CellLine::setParametrization(const string parametrization_type)
{
    if(parametrization_type == "LQ_noDt" && isLQ_noDtLoaded)
        selectedParametrization = &CellLine::parametrization_LQ_noDt;
    
    else if(parametrization_type == "LQ_noDt_T" && isLQ_noDt_TLoaded)
        selectedParametrizationT = &CellLine::parametrization_LQ_noDt_T;
    
    else if(parametrization_type == "LQ" && isLQloaded)
        selectedParametrization = &CellLine::parametrization_LQ;
    
    else if((parametrization_type == "LQ2" || parametrization_type == "LQ2_interpolated_readfile") && isLQ2loaded)
    {
        selectedParametrization = &CellLine::parametrization_LQ2;
        selectedDamageEnhancement = &CellLine::interpolatedDamageEnhancement;
        selectedEtaGeneration = &CellLine::readDamageEnhancement;
        needEtaGenerated = true;
    }
    
    else if(parametrization_type == "LQ3" && isLQ3loaded)
    {
        selectedParametrization = &CellLine::parametrization_LQ3;
        selectedDamageEnhancement = &CellLine::interpolatedDamageEnhancement;
        selectedEtaGeneration = &CellLine::readDamageEnhancement;
        needEtaGenerated = true;
    }
    
    else if(parametrization_type == "LQ2_interpolated_analytic" && isLQ2loaded)
    {
        selectedParametrization = &CellLine::parametrization_LQ2;
        selectedDamageEnhancement = &CellLine::interpolatedDamageEnhancement;
        selectedEtaGeneration = &CellLine::analyticDamageEnhancement;
        needEtaGenerated = true;
    }
    
    else if(parametrization_type == "LQ2_interpolated_MC" && isLQ2loaded)
    {
        selectedParametrization = &CellLine::parametrization_LQ2;
        selectedDamageEnhancement = &CellLine::interpolatedDamageEnhancement;
        selectedEtaGeneration = &CellLine::damageEnhancement;
        needEtaGenerated = true;
    }
    
    else if(parametrization_type == "LQ2_punctual_analytic" && isLQ2loaded)
    {
        selectedParametrization = &CellLine::parametrization_LQ2;
        selectedDamageEnhancement = &CellLine::analyticDamageEnhancement;
    }
    
    else if(parametrization_type == "LQ2_punctual_MC" && isLQ2loaded)
    {
        selectedParametrization = &CellLine::parametrization_LQ2;
        selectedDamageEnhancement = &CellLine::damageEnhancement;
    }
    
    else
    {
        cerr << "CellLine: The selected X-ray parametrization is not provided or has not been loaded." << endl;
        exit(1);
    }

    //clog << "Selected " << parametrization_type << " parametrization for X-rays." << endl;

    if(needEtaGenerated)
    {
        cout << "Generating damage enhancement... ";
        double d = 100;
        int etaCounter = 0;
        int points = 200;
        do {
            doseForEta[etaCounter] = d;
            etaPre[etaCounter] = (*this.*selectedEtaGeneration)(d);
            etaCounter++;
            d = pow( double(10), 2 + etaCounter * (4 + log10(5))/(points - 1) );
        } while( d <= 5e6 );
        needEtaGenerated = false;
        cout << "done." << endl
             << endl << flush;
    }
}
开发者ID:batuff,项目名称:Survival,代码行数:80,代码来源:CellLine.cpp


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