Log In | Get Help   
Home My Page Projects Code Snippets Project Openings Mareframe
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files
[mareframe] Annotation of /trunk/gadget/commentstream.h
[mareframe] / trunk / gadget / commentstream.h Repository:
ViewVC logotype

Annotation of /trunk/gadget/commentstream.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (view) (download)

1 : agomez 1 #ifndef commentstream_h
2 :     #define commentstream_h
3 :    
4 :     #include "gadget.h"
5 :    
6 :     class CommentStream;
7 :     typedef CommentStream& (*__commentmanip)(CommentStream&);
8 :    
9 :     /**
10 :     * \class Whitespace
11 :     * \brief This is the dummy class used to strip white space from any input stream
12 :     */
13 :     class Whitespace {
14 :     public:
15 :     /**
16 :     * \brief This is the default Whitespace constructor
17 :     */
18 :     Whitespace() { v = 0; };
19 :     /**
20 :     * \brief This is the default Whitespace destructor
21 :     */
22 :     ~Whitespace() {};
23 :     /**
24 :     * \brief This operator will strip white space from a given input istream
25 :     * \param istr is the istream to strip white space from
26 :     * \param ws is the Whitespace used to strip white space from the data
27 :     */
28 :     friend istream& operator >> (istream& istr, Whitespace& ws);
29 :     private:
30 :     /**
31 :     * \brief This is a dummy object used when stripping the white space from any input files
32 :     */
33 :     int v;
34 :     };
35 :    
36 :     /**
37 :     * \class CommentStream
38 :     * \brief This is the class used to strip comments (and whitespace) from any input stream
39 :     */
40 :     class CommentStream {
41 :     public:
42 :     friend CommentStream& ws(CommentStream& ins);
43 :     /**
44 :     * \brief This is the default CommentStream constructor
45 :     */
46 :     CommentStream() { istrptr = NULL; };
47 :     /**
48 :     * \brief This is the CommentStream constructor for a given input stream
49 :     * \param istr is the given input stream
50 :     */
51 :     CommentStream(istream& istr) { istrptr = &istr; };
52 :     /**
53 :     * \brief This is the default CommentStream destructor
54 :     */
55 :     ~CommentStream() {};
56 :     /**
57 :     * \brief This function will store a given input stream
58 :     * \param istr is the given input stream
59 :     */
60 :     void setStream(istream& istr) { istrptr = &istr; };
61 :     /**
62 :     * \brief This operator will read data from the CommentStream and store it as an integer
63 :     * \param a is the integer used to store the data that has been read
64 :     */
65 :     CommentStream& operator >> (int& a);
66 :     /**
67 :     * \brief This operator will read data from the CommentStream and store it as a double
68 :     * \param a is the double used to store the data that has been read
69 :     */
70 :     CommentStream& operator >> (double& a);
71 :     /**
72 :     * \brief This operator will read data from the CommentStream and store it as a char*
73 :     * \param a is the char* used to store the data that has been read
74 :     */
75 :     CommentStream& operator >> (char* a);
76 :     CommentStream& operator >> (__commentmanip func);
77 :     /**
78 :     * \brief This function will inspect (but not read) the next character in the input stream
79 :     * \return the next character in the input stream
80 :     */
81 :     char peek();
82 :     /**
83 :     * \brief This function will check to see if the input stream has reached the end of file marker
84 :     * \return 1 if the input stream has reached the end of file marker, 0 otherwise
85 :     */
86 :     int eof() { return istrptr->eof(); };
87 :     /**
88 :     * \brief This function will check to see if the input stream has failed
89 :     * \return 1 if the input stream has failed, 0 otherwise
90 :     */
91 :     int fail() { return istrptr->fail(); };
92 :     /**
93 :     * \brief This function will check to see if the input stream has failed
94 :     * \return 1 if the input stream has failed, 0 otherwise
95 :     */
96 :     int operator !() { return istrptr->fail(); };
97 :     /**
98 :     * \brief This function will find the specified position in the input stream
99 :     * \param pos is the position in the input stream to be found
100 :     */
101 :     CommentStream& seekg(streampos pos) { istrptr->seekg(pos); return *this; };
102 :     /**
103 :     * \brief This function will return the current position in the input stream
104 :     * \return pos, the current position in the input stream
105 :     */
106 :     streampos tellg() { return istrptr->tellg(); };
107 :     /**
108 :     * \brief This function will read the next character from the input stream
109 :     * \param c will store the next character in the input stream
110 :     */
111 :     CommentStream& get(char& c);
112 :     /**
113 :     * \brief This function will read the next line from the input stream
114 :     * \param text will store the next line in the input stream
115 :     * \param length is the length of the line to be read from the input stream
116 :     */
117 :     CommentStream& getLine(char* text, int length);
118 :     protected:
119 :     /**
120 :     * \brief This function will remove the comments and whitespace from the input stream
121 :     */
122 :     void killComments();
123 :     /**
124 :     * \brief This is the input stream that will have the comments and whitespace removed
125 :     */
126 :     istream* istrptr;
127 :     };
128 :    
129 :     CommentStream& ws(CommentStream& ins);
130 :    
131 :     #endif

root@forge.cesga.es
ViewVC Help
Powered by ViewVC 1.0.0  

Powered By FusionForge