Gadget
commentstream.h
Go to the documentation of this file.
1 #ifndef commentstream_h
2 #define commentstream_h
3 
4 #include "gadget.h"
5 
6 class CommentStream;
7 typedef CommentStream& (*__commentmanip)(CommentStream&);
8 
13 class Whitespace {
14 public:
18  Whitespace() { v = 0; };
28  friend istream& operator >> (istream& istr, Whitespace& ws);
29 private:
33  int v;
34 };
35 
41 public:
42  friend CommentStream& ws(CommentStream& ins);
46  CommentStream() { istrptr = NULL; };
51  CommentStream(istream& istr) { istrptr = &istr; };
60  void setStream(istream& istr) { istrptr = &istr; };
65  CommentStream& operator >> (int& a);
70  CommentStream& operator >> (double& a);
75  CommentStream& operator >> (char* a);
81  char peek();
86  int eof() { return istrptr->eof(); };
91  int fail() { return istrptr->fail(); };
96  int operator !() { return istrptr->fail(); };
101  CommentStream& seekg(streampos pos) { istrptr->seekg(pos); return *this; };
106  streampos tellg() { return istrptr->tellg(); };
111  CommentStream& get(char& c);
117  CommentStream& getLine(char* text, int length);
118 protected:
122  void killComments();
126  istream* istrptr;
127 };
128 
130 
131 #endif
This is the class used to strip comments (and whitespace) from any input stream.
Definition: commentstream.h:40
CommentStream & get(char &c)
This function will read the next character from the input stream.
Definition: commentstream.cc:52
CommentStream & operator>>(int &a)
This operator will read data from the CommentStream and store it as an integer.
Definition: commentstream.cc:77
int operator!()
This function will check to see if the input stream has failed.
Definition: commentstream.h:96
int eof()
This function will check to see if the input stream has reached the end of file marker.
Definition: commentstream.h:86
~CommentStream()
This is the default CommentStream destructor.
Definition: commentstream.h:55
istream * istrptr
This is the input stream that will have the comments and whitespace removed.
Definition: commentstream.h:126
void setStream(istream &istr)
This function will store a given input stream.
Definition: commentstream.h:60
friend CommentStream & ws(CommentStream &ins)
Definition: commentstream.cc:11
int fail()
This function will check to see if the input stream has failed.
Definition: commentstream.h:91
streampos tellg()
This function will return the current position in the input stream.
Definition: commentstream.h:106
CommentStream & getLine(char *text, int length)
This function will read the next line from the input stream.
Definition: commentstream.cc:65
char peek()
This function will inspect (but not read) the next character in the input stream.
Definition: commentstream.cc:33
CommentStream()
This is the default CommentStream constructor.
Definition: commentstream.h:46
void killComments()
This function will remove the comments and whitespace from the input stream.
Definition: commentstream.cc:16
CommentStream(istream &istr)
This is the CommentStream constructor for a given input stream.
Definition: commentstream.h:51
CommentStream & seekg(streampos pos)
This function will find the specified position in the input stream.
Definition: commentstream.h:101
This is the dummy class used to strip white space from any input stream.
Definition: commentstream.h:13
~Whitespace()
This is the default Whitespace destructor.
Definition: commentstream.h:22
friend istream & operator>>(istream &istr, Whitespace &ws)
This operator will strip white space from a given input istream.
Definition: commentstream.cc:5
Whitespace()
This is the default Whitespace constructor.
Definition: commentstream.h:18
CommentStream &(* __commentmanip)(CommentStream &)
Definition: commentstream.h:7
CommentStream & ws(CommentStream &ins)
Definition: commentstream.cc:11