Exemplo n.º 1
0
void
SyncFiles::readInput(void)
{
  ReadLine rL;

  // now switch to std::cin
  rL.connect_cin();  // std::cin

  // read instructions
  while( ! rL.readLine() )
  {
     for( size_t i=0 ; i < rL.size() ; ++i )
     {
       ensemble->member.push_back( new Member );

       if( path.size() )
         ensemble->member.back()->setPath(path);

       ensemble->member.back()->setFilename(rL.getItem(i));
     }
  }

  // sz will be changed corresponding to the effective range
  ensemble->sz = ensemble->member.size() ;
  ensemble->last = ensemble->sz -1 ; // the real size
  return;
}
Exemplo n.º 2
0
void
readOptions(std::vector<std::string> &argv)
{
  ReadLine rL;
  std::string file;

  bool isCinProvided=false;

  // find filename of parameter-file.
  for( size_t i=0 ; i<argv.size() ; ++i)
  {
     // find "--file"
     if( argv[i].find("--file") < std::string::npos )
     {
       if( argv[i] == "--file" && (i+1) < argv.size() )
       {
         file = argv[i+1];

         // remove: --file's argument
         argv.erase(argv.begin() + i +1 );
       }
       else
         file = argv[i].substr(7);

       // remove: --file
       argv.erase(argv.begin() + i);
       break;
     }

     if( argv[i].find("--input") < std::string::npos )
     {
       isCinProvided=true;

       // remove argument
       argv.erase(argv.begin() + i);
       break;
     }
  }

  if( file.size() > 0 )
  {
     rL.open(file); // from file

     // read instructions
     while( ! rL.readLine() )
     {
        if( rL.at(0) == '#')
          continue;

        for( size_t j=0 ; j < rL.size() ; ++j)
          argv.push_back( rL.getItem(j) ) ;
     }

    rL.close();
  }

  if( !isCinProvided)
    return;

  // now switch to std::cin
  rL.connect_cin();  // std::cin

  // read instructions
  while( ! rL.readLine() )
  {
     if( rL.at(0) == '#' )
       continue;

     for( size_t j=0 ; j < rL.size() ; ++j)
       argv.push_back( rL.getItem(j) ) ;
  }

  return;
}