Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
rapidjson::FileStream Class Reference

(Deprecated) Wrapper of C file stream for input or output. More...

#include <filestream.h>

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)
 
void Flush ()
 
char * PutBegin ()
 
size_t PutEnd (char *)
 

Private Member Functions

 FileStream (const FileStream &)
 
FileStreamoperator= (const FileStream &)
 
void Read ()
 

Private Attributes

FILE * fp_
 
char current_
 
size_t count_
 

Detailed Description

(Deprecated) Wrapper of C file stream for input or output.

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

Note
implements Stream concept
deprecated: This was only for basic testing in version 0.1, it is found that the performance is very low by using fgetc(). Use FileReadStream instead.

Definition at line 35 of file filestream.h.

Member Typedef Documentation

Character type. Only support char.

Definition at line 37 of file filestream.h.

Constructor & Destructor Documentation

rapidjson::FileStream::FileStream ( FILE *  fp)
inline
rapidjson::FileStream::FileStream ( const FileStream )
private

Member Function Documentation

void rapidjson::FileStream::Flush ( )
inline

Definition at line 44 of file filestream.h.

44 { fflush(fp_); }
FileStream& rapidjson::FileStream::operator= ( const FileStream )
private
char rapidjson::FileStream::Peek ( ) const
inline

Definition at line 40 of file filestream.h.

40 { return current_; }
void rapidjson::FileStream::Put ( char  c)
inline

Definition at line 43 of file filestream.h.

43 { fputc(c, fp_); }
char* rapidjson::FileStream::PutBegin ( )
inline

Definition at line 47 of file filestream.h.

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

Definition at line 48 of file filestream.h.

48 { return 0; }
void rapidjson::FileStream::Read ( )
inlineprivate

Definition at line 55 of file filestream.h.

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

Definition at line 41 of file filestream.h.

41 { char c = current_; Read(); return c; }
size_t rapidjson::FileStream::Tell ( ) const
inline

Definition at line 42 of file filestream.h.

42 { return count_; }

Member Data Documentation

size_t rapidjson::FileStream::count_
private

Definition at line 68 of file filestream.h.

char rapidjson::FileStream::current_
private

Definition at line 67 of file filestream.h.

FILE* rapidjson::FileStream::fp_
private

Definition at line 66 of file filestream.h.


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