CoolProp  4.2.5
An open-source fluid property and humid air property database
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
filestream.h
Go to the documentation of this file.
1 #ifndef RAPIDJSON_FILESTREAM_H_
2 #define RAPIDJSON_FILESTREAM_H_
3 
4 #include <cstdio>
5 
6 namespace rapidjson {
7 
9 
13 class FileStream {
14 public:
15  typedef char Ch;
16 
17  FileStream(FILE* fp) : fp_(fp), count_(0) { Read(); }
18  char Peek() const { return current_; }
19  char Take() { char c = current_; Read(); return c; }
20  size_t Tell() const { return count_; }
21  void Put(char c) { fputc(c, fp_); }
22 
23  // Not implemented
24  char* PutBegin() { return 0; }
25  size_t PutEnd(char*) { return 0; }
26 
27 private:
28  void Read() {
29  RAPIDJSON_ASSERT(fp_ != 0);
30  int c = fgetc(fp_);
31  if (c != EOF) {
32  current_ = (char)c;
33  count_++;
34  }
35  else
36  current_ = '\0';
37  }
38 
39  FILE* fp_;
40  char current_;
41  size_t count_;
42 };
43 
44 } // namespace rapidjson
45 
46 #endif // RAPIDJSON_FILESTREAM_H_
char Ch
Character type. Only support char.
Definition: filestream.h:15
FileStream(FILE *fp)
Definition: filestream.h:17
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:80
size_t PutEnd(char *)
Definition: filestream.h:25
void Put(char c)
Definition: filestream.h:21
size_t Tell() const
Definition: filestream.h:20
char Peek() const
Definition: filestream.h:18
Wrapper of C file stream for input or output.
Definition: filestream.h:13