#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <vector>
#include <iterator>
#include "JLang/JFileStream.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"
 
Go to the source code of this file.
 | 
| int  | main (int argc, char **argv) | 
|   | 
Example program to test JLANG::JFileStream class. 
- Author
 - mdejong 
 
Definition in file JFileStream.cc.
 
◆ main()
      
        
          | int main  | 
          ( | 
          int  | 
          argc,  | 
        
        
           | 
           | 
          char **  | 
          argv  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Definition at line 24 of file JFileStream.cc.
   29   string  file_name = 
"test_file.txt";
 
   34     JParser<> zap(
"Example program to test file streaming.");
 
   36     zap[
'f'] = 
make_field(file_name)   = 
"test_file.txt";
 
   41   catch(
const exception &error) {
 
   42     FATAL(error.what() << endl);
 
   48   data_in.push_back(
"hello");
 
   49   data_in.push_back(
"world");
 
   52     int fd = 
open(file_name.c_str(), O_RDWR | O_CREAT | O_TRUNC, 0666);
 
   56     JFileOutputStream os(fd);
 
   68     int fd = 
open(file_name.c_str(), O_RDWR);
 
   72     JFileInputStream is(fd);
 
   74     for (
string buffer; 
getline(is,buffer); ) {
 
   75       data_out.push_back(buffer);
 
   82     cout << 
"data_in  "; 
copy(data_in .begin(), data_in .end(), ostream_iterator<string>(cout, 
" ")); cout << endl;
 
   83     cout << 
"data_out "; 
copy(data_out.begin(), data_out.end(), ostream_iterator<string>(cout, 
" ")); cout << endl;
 
   86   ASSERT(data_in == data_out);