JASSv2
instream_memory.h
Go to the documentation of this file.
1 /*
2  INSTREAM_MEMORY.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 */
13 #pragma once
14 
15 #include <stdio.h>
16 
17 #include "instream.h"
18 
19 namespace JASS
20  {
21  /*
22  CLASS INSTREAM_MEMORY
23  ---------------------
24  */
28  class instream_memory : public instream
29  {
30  protected:
31  size_t bytes_read;
32  const uint8_t *file;
33  size_t file_length;
34 
35  public:
36  /*
37  INSTREAM_MEMORY::INSTREAM_MEMORY()
38  ----------------------------------
39  */
45  instream_memory(const void *memory, size_t length):
46  instream(),
47  bytes_read(0),
48  file((uint8_t *)memory),
49  file_length(length)
50  {
51  /* Nothing */
52  }
53  /*
54  INSTREAM_MEMORY::READ()
55  -----------------------
56  */
61  virtual void read(document &buffer);
62 
63  /*
64  INSTREAM_MEMORY::UNITTEST()
65  ---------------------------
66  */
70  static void unittest(void);
71  };
72  }
virtual void read(document &buffer)
Read buffer.size() bytes of data into buffer.contents, resizing on eof.
Definition: instream_memory.cpp:19
Read data from an input stream.
Definition: instream.h:45
Container class representing a document through the indexing pipeline.
Definition: document.h:31
std::shared_ptr< allocator > memory
Any and all memory allocation must happen using this object.
Definition: instream.h:49
instream_memory(const void *memory, size_t length)
Constructor.
Definition: instream_memory.h:45
Base class for reading data from some input source.
Subclass of instream for reading data from a memory buffer.
Definition: instream_memory.h:28
size_t bytes_read
The number of bytes this object has read for the buffer.
Definition: instream_memory.h:31
static void unittest(void)
Unit test this class.
Definition: instream_memory.cpp:52
size_t file_length
The length of the in-memory buffer.
Definition: instream_memory.h:33
Definition: compress_integer_elias_delta_simd.c:23
const uint8_t * file
A pointer to the in-memory buffer (thought of as an in-place file)
Definition: instream_memory.h:32