rapidjson::FileStream Class Reference

Wrapper of C file stream for input or output. More...

#include <filestream.h>

+ Inheritance diagram for rapidjson::FileStream:

Public Types

typedef char Ch
 Character type. Only support char. More...
 

Public Member Functions

 FileStream (FILE *fp)
 
char Peek () const
 
char Take ()
 
size_t Tell () const
 
void Put (char c)
 
charPutBegin ()
 
size_t PutEnd (char *)
 

Private Member Functions

void Read ()
 

Private Attributes

FILE * fp_
 
char current_
 
size_t count_
 

Detailed Description

Wrapper of C file stream for input or output.

This simple wrapper does not check the validity of the stream.

Member Typedef Documentation

◆ Ch

Character type. Only support char.

Constructor & Destructor Documentation

◆ FileStream()

rapidjson::FileStream::FileStream ( FILE *  fp)
inline
42 : fp_(fp), count_(0) { Read(); }
void Read()
Definition: filestream.h:54
FILE * fp_
Definition: filestream.h:65
size_t count_
Definition: filestream.h:67

References Read().

Member Function Documentation

◆ Peek()

char rapidjson::FileStream::Peek ( ) const
inline
44 { return current_; }
char current_
Definition: filestream.h:66

References current_.

◆ Put()

void rapidjson::FileStream::Put ( char  c)
inline
47 { fputc(c, fp_); }

References fp_.

◆ PutBegin()

char* rapidjson::FileStream::PutBegin ( )
inline
50 { return 0; }

◆ PutEnd()

size_t rapidjson::FileStream::PutEnd ( char )
inline
51 { return 0; }

◆ Read()

void rapidjson::FileStream::Read ( )
inlineprivate
54  {
55  RAPIDJSON_ASSERT(fp_ != 0);
56  int c = fgetc(fp_);
57  if (c != EOF) {
58  current_ = (char)c;
59  count_++;
60  }
61  else
62  current_ = '\0';
63  }
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:105

References count_, current_, fp_, and RAPIDJSON_ASSERT.

Referenced by FileStream(), and Take().

◆ Take()

char rapidjson::FileStream::Take ( )
inline
45 { char c = current_; Read(); return c; }

References current_, and Read().

◆ Tell()

size_t rapidjson::FileStream::Tell ( ) const
inline
46 { return count_; }

References count_.

Member Data Documentation

◆ count_

size_t rapidjson::FileStream::count_
private

Referenced by Read(), and Tell().

◆ current_

char rapidjson::FileStream::current_
private

Referenced by Peek(), Read(), and Take().

◆ fp_

FILE* rapidjson::FileStream::fp_
private

Referenced by Put(), and Read().


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