1/*---------------------------------------------------------------------\
 
    8\---------------------------------------------------------------------*/
 
    9/** \file zypp/PoolQueryUtil.tcc
 
   11 * including fstream is not hell here because this header only included
 
   12 * by implementation file, header doesn't need include it.
 
   14#ifndef ZYPP_POOLQUERYUTIL_TCC
 
   15#define ZYPP_POOLQUERYUTIL_TCC
 
   19#include <zypp/Pathname.h>
 
   20#include <zypp/PoolQuery.h>
 
   21#include <zypp/base/String.h>
 
   27   * sends to output iterator all queries readed from file.
 
   31   *  insert_iterator<list<PoolQuery> > ii(s, s.end());
 
   32   *  readPoolQueriesFromStream(f,ii);
 
   35  template <class OutputIterator>
 
   36  void readPoolQueriesFromFile(const zypp::filesystem::Pathname &file,
 
   40    std::ifstream fin( file.c_str() );
 
   43      ZYPP_THROW(Exception(str::form("Cannot open file %s",file.c_str())));
 
   48      found = q.recover( fin );
 
   57   * Writes all queries from begin to end.
 
   60  template <class InputIterator>
 
   61  void writePoolQueriesToFile(const zypp::filesystem::Pathname &file,
 
   62      InputIterator begin, InputIterator end )
 
   64    std::ofstream fout( file.c_str(), std::ios_base::out | std::ios_base::trunc );
 
   67      ZYPP_THROW(Exception(str::form("Cannot open file %s",file.c_str())));
 
   69    for_( it, begin, end )
 
   71      it->serialize( fout );
 
   78#endif // ZYPP_POOLQUERYUTIL_H