TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
FileWriteStream Class Reference

Wrapper of C file stream for input using fread(). More...

#include <filewritestream.h>

Public Types

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

Public Member Functions

 FileWriteStream (std::FILE *fp, char *buffer, size_t bufferSize)
 
void Put (char c)
 
void PutN (char c, size_t n)
 
void Flush ()
 
char Peek () const
 
char Take ()
 
size_t Tell () const
 
char * PutBegin ()
 
size_t PutEnd (char *)
 

Private Member Functions

 FileWriteStream (const FileWriteStream &)
 
FileWriteStreamoperator= (const FileWriteStream &)
 

Private Attributes

std::FILE * fp_
 
char * buffer_
 
char * bufferEnd_
 
char * current_
 

Detailed Description

Wrapper of C file stream for input using fread().

Note
implements Stream concept

Member Typedef Documentation

typedef char FileWriteStream::Ch

Character type. Only support char.

Constructor & Destructor Documentation

FileWriteStream::FileWriteStream ( std::FILE *  fp,
char *  buffer,
size_t  bufferSize 
)
inline
31  : fp_(fp), buffer_(buffer), bufferEnd_(buffer + bufferSize), current_(buffer_) {
32  RAPIDJSON_ASSERT(fp_ != 0);
33  }
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:344
const size_t bufferSize
Definition: RASession.h:31
char * current_
Definition: filewritestream.h:80
char * bufferEnd_
Definition: filewritestream.h:79
char * buffer_
Definition: filewritestream.h:78
std::FILE * fp_
Definition: filewritestream.h:77
FileWriteStream::FileWriteStream ( const FileWriteStream )
private

Member Function Documentation

void FileWriteStream::Flush ( )
inline
58  {
59  if (current_ != buffer_) {
60  fwrite(buffer_, 1, static_cast<size_t>(current_ - buffer_), fp_);
61  current_ = buffer_;
62  }
63  }
char * current_
Definition: filewritestream.h:80
char * buffer_
Definition: filewritestream.h:78
std::FILE * fp_
Definition: filewritestream.h:77

+ Here is the caller graph for this function:

FileWriteStream& FileWriteStream::operator= ( const FileWriteStream )
private
char FileWriteStream::Peek ( ) const
inline
66 { RAPIDJSON_ASSERT(false); return 0; }
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:344
void FileWriteStream::Put ( char  c)
inline
35  {
36  if (current_ >= bufferEnd_)
37  Flush();
38 
39  *current_++ = c;
40  }
void Flush()
Definition: filewritestream.h:58
char * current_
Definition: filewritestream.h:80
char * bufferEnd_
Definition: filewritestream.h:79

+ Here is the call graph for this function:

char* FileWriteStream::PutBegin ( )
inline
69 { RAPIDJSON_ASSERT(false); return 0; }
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:344
size_t FileWriteStream::PutEnd ( char *  )
inline
70 { RAPIDJSON_ASSERT(false); return 0; }
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:344
void FileWriteStream::PutN ( char  c,
size_t  n 
)
inline
42  {
43  size_t avail = static_cast<size_t>(bufferEnd_ - current_);
44  while (n > avail) {
45  std::memset(current_, c, avail);
46  current_ += avail;
47  Flush();
48  n -= avail;
49  avail = static_cast<size_t>(bufferEnd_ - current_);
50  }
51 
52  if (n > 0) {
53  std::memset(current_, c, n);
54  current_ += n;
55  }
56  }
void Flush()
Definition: filewritestream.h:58
char * current_
Definition: filewritestream.h:80
char * bufferEnd_
Definition: filewritestream.h:79

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

char FileWriteStream::Take ( )
inline
67 { RAPIDJSON_ASSERT(false); return 0; }
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:344
size_t FileWriteStream::Tell ( ) const
inline
68 { RAPIDJSON_ASSERT(false); return 0; }
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:344

Member Data Documentation

char* FileWriteStream::buffer_
private
char* FileWriteStream::bufferEnd_
private
char* FileWriteStream::current_
private
std::FILE* FileWriteStream::fp_
private

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