Jpp  19.1.0
the software that should make you happy
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
JLANG::JFileInputStream Class Reference

Streaming of input. More...

#include <JFileStream.hh>

Inheritance diagram for JLANG::JFileInputStream:
JLANG::JFileInputStreamBuffer std::vector< char >

Public Member Functions

 JFileInputStream (const JAbstractFile &file, const std::size_t size=65536)
 Constructor. More...
 

Protected Types

typedef traits_type::int_type int_type
 

Protected Member Functions

virtual int_type underflow () override
 Check underflow. More...
 
bool in_avail (JTimeval timeout=JTimeval::min()) const
 Check availability of input. More...
 

Protected Attributes

JFile in
 
std::size_t memory
 

Detailed Description

Streaming of input.

Definition at line 24 of file JFileStream.hh.

Member Typedef Documentation

◆ int_type

typedef traits_type::int_type JLANG::JFileInputStreamBuffer::int_type
inherited

Definition at line 32 of file JFileStreamBuffer.hh.

Constructor & Destructor Documentation

◆ JFileInputStream()

JLANG::JFileInputStream::JFileInputStream ( const JAbstractFile file,
const std::size_t  size = 65536 
)
inline

Constructor.

Parameters
filefile
sizesize of internal buffer

Definition at line 35 of file JFileStream.hh.

36  :
37  JFileInputStreamBuffer(file, size),
38  std::istream(this)
39  {}
JFileInputStreamBuffer(const JAbstractFile &file, const std::size_t size=65536, const std::size_t put_back=8)
Constructor.

Member Function Documentation

◆ underflow()

virtual int_type JLANG::JFileInputStreamBuffer::underflow ( )
inlineoverridevirtualinherited

Check underflow.

This method reads as many bytes as possible.

Returns
first character if OK; else EOF

Definition at line 60 of file JFileStreamBuffer.hh.

61  {
62  if (gptr() >= egptr()) {
63 
64  char* __begin = this->data();
65 
66  if (eback() == __begin) {
67 
68  // push put back characters
69 
70  memmove(__begin, egptr() - memory, memory);
71 
72  __begin += memory;
73  }
74 
75  const size_t len = in.read(__begin, this->size() - (__begin - this->data()));
76 
77  if (len != 0)
78  setg(this->data(), __begin, __begin + len);
79  else
80  return traits_type::eof();
81  }
82 
83  return *gptr();
84  }
virtual int read(char *buffer, const int length)
Read data from file.
Definition: JFile.hh:80

◆ in_avail()

bool JLANG::JFileInputStreamBuffer::in_avail ( JTimeval  timeout = JTimeval::min()) const
inlineinherited

Check availability of input.

This method returns true if at least one byte can be read without blocking.

Parameters
timeouttimeout
Returns
true if ready to read; else false

Definition at line 94 of file JFileStreamBuffer.hh.

95  {
96  return JFileDescriptorMask(in).in_avail(timeout);
97  }
Auxiliary class for method select.
bool in_avail(JTimeval timeout=JTimeval::min())
Check availability of input.

Member Data Documentation

◆ in

JFile JLANG::JFileInputStreamBuffer::in
protectedinherited

Definition at line 100 of file JFileStreamBuffer.hh.

◆ memory

std::size_t JLANG::JFileInputStreamBuffer::memory
protectedinherited

Definition at line 101 of file JFileStreamBuffer.hh.


The documentation for this class was generated from the following file: