JASSv2
instream_file.h
Go to the documentation of this file.
1 /*
2  INSTREAM_FILE.H
3  ---------------
4  Copyright (c) 2016 Andrew Trotman
5  Released under the 2-clause BSD license (See:https://en.wikipedia.org/wiki/BSD_licenses)
6 */
14 #pragma once
15 
16 #include "file.h"
17 #include "instream.h"
18 
19 namespace JASS
20  {
21  /*
22  CLASS INSTREAM_FILE
23  -------------------
24  */
28  class instream_file : public instream
29  {
30  protected:
32  size_t file_length;
33  size_t bytes_read;
34 
35  protected:
36  /*
37  INSTREAM_FILE::INSTREAM_FILE()
38  ------------------------------
39  */
44  instream_file(FILE *file);
45 
46  public:
47  /*
48  INSTREAM_FILE::INSTREAM_FILE()
49  ------------------------------
50  */
55  instream_file(const std::string &filename);
56 
57  /*
58  INSTREAM_FILE::~INSTREAM_FILE()
59  -------------------------------
60  */
64  virtual ~instream_file()
65  {
66  /* Nothing */
67  }
68 
69  /*
70  INSTREAM_FILE::READ()
71  ---------------------
72  */
77  virtual void read(document &buffer);
78 
79  /*
80  INSTREAM_FILE::UNITTEST()
81  -------------------------
82  */
86  static void unittest(void);
87  };
88 }
instream_file(FILE *file)
Constructor.
Definition: instream_file.cpp:18
static void unittest(void)
Unit test this class.
Definition: instream_file.cpp:75
Read data from an input stream.
Definition: instream.h:45
Container class representing a document through the indexing pipeline.
Definition: document.h:31
virtual ~instream_file()
Destructor.
Definition: instream_file.h:64
size_t bytes_read
The number of bytes that have been read from the file.
Definition: instream_file.h:33
Partial file and whole file based I/O methods.
Base class for reading data from some input source.
Subclass of the instream base class used for reading data from a disk file.
Definition: instream_file.h:28
virtual void read(document &buffer)
Read buffer.contents.size() bytes of data into buffer.contents, resizing on eof.
Definition: instream_file.cpp:44
File based I/O methods including whole file and partial files.
Definition: file.h:45
file disk_file
The file to read from.
Definition: instream_file.h:31
Definition: compress_integer_elias_delta_simd.c:23
size_t file_length
The length of the file.
Definition: instream_file.h:32