]>
git.saurik.com Git - wxWidgets.git/blob - interface/txtstrm.h
4c4bdb43e3c79fab32313302c987fa2f5c845e38
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: documentation for wxTextInputStream class
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxTextInputStream
13 This class provides functions that read text datas using an input stream.
14 So, you can read @e text floats, integers.
16 The wxTextInputStream correctly reads text files (or streams) in DOS, Macintosh
17 and Unix formats and reports a single newline char as a line ending.
19 Operator is overloaded and you can use this class like a standard C++ iostream.
20 Note, however, that the arguments are the fixed size types wxUint32, wxInt32 etc
21 and on a typical 32-bit computer, none of these match to the "long" type
23 is defined as int on 32-bit architectures) so that you cannot use long. To avoid
24 problems (here and elsewhere), make use of wxInt32, wxUint32 and similar types.
26 If you're scanning through a file using wxTextInputStream, you should check for
28 reading the next item (word / number), because otherwise the last item may get
30 You should however be prepared to receive an empty item (empty string / zero
32 end of file, especially on Windows systems. This is unavoidable because most
33 (but not all) files end
34 with whitespace (i.e. usually a newline).
39 wxFileInputStream input( "mytext.txt" );
40 wxTextInputStream text( input );
45 text i1; // read a 8 bit integer.
46 text i1 f2; // read a 8 bit integer followed by float.
47 text line; // read a text line
54 wxTextInputStream::SetStringSeparators
56 class wxTextInputStream
61 Constructs a text stream associated to the given input stream.
64 The underlying input stream.
66 The initial string separator characters.
68 In Unicode build only: The encoding converter used to convert the bytes in
70 underlying input stream to characters.
72 wxTextInputStream(wxInputStream
& stream
,
73 const wxString
& sep
= " \t");
76 Destroys the wxTextInputStream object.
81 Reads a character, returns 0 if there are no more characters in the stream.
86 Reads a unsigned 16 bit integer from the stream.
87 See wxTextInputStream::Read8 for the
88 description of the @a base parameter.
90 wxUint16
Read16(int base
= 10);
93 Reads a signed 16 bit integer from the stream.
94 See wxTextInputStream::Read8 for the
95 description of the @a base parameter.
97 wxInt16
Read16S(int base
= 10);
100 Reads a 32 bit unsigned integer from the stream.
101 See wxTextInputStream::Read8 for the
102 description of the @a base parameter.
104 wxUint32
Read32(int base
= 10);
107 Reads a 32 bit signed integer from the stream.
108 See wxTextInputStream::Read8 for the
109 description of the @a base parameter.
111 wxInt32
Read32S(int base
= 10);
114 Reads a single unsigned byte from the stream, given in base @e base.
115 The value of @a base must be comprised between 2 and 36, inclusive, or
116 be a special value 0 which means that the usual rules of @c C numbers are
117 applied: if the number starts with @c 0x it is considered to be in base
118 16, if it starts with @c 0 - in base 8 and in base 10 otherwise. Note
119 that you may not want to specify the base 0 if you are parsing the numbers
120 which may have leading zeroes as they can yield unexpected (to the user not
121 familiar with C) results.
123 wxUint8
Read8(int base
= 10);
126 Reads a single signed byte from the stream.
127 See wxTextInputStream::Read8 for the
128 description of the @a base parameter.
130 wxInt8
Read8S(int base
= 10);
133 Reads a double (IEEE encoded) from the stream.
138 Reads a line from the input stream and returns it (without the end of line
144 @b NB: This method is deprecated, use ReadLine()
145 or ReadWord() instead.
148 wxString
ReadString();
151 Reads a word (a sequence of characters until the next separator) from the
154 @see SetStringSeparators()
159 Sets the characters which are used to define the word boundaries in
161 The default separators are the space and @c TAB characters.
163 void SetStringSeparators(const wxString
& sep
);
168 @class wxTextOutputStream
171 This class provides functions that write text datas using an output stream.
172 So, you can write @e text floats, integers.
174 You can also simulate the C++ cout class:
177 wxFFileOutputStream output( stderr );
178 wxTextOutputStream cout( output );
180 cout "This is a text line" endl;
185 The wxTextOutputStream writes text files (or streams) on DOS, Macintosh
186 and Unix in their native formats (concerning the line ending).
191 class wxTextOutputStream
196 Constructs a text stream object associated to the given output stream.
201 The end-of-line mode. One of wxEOL_NATIVE, wxEOL_DOS, wxEOL_MAC and
204 In Unicode build only: The object used to convert
205 Unicode text into ASCII characters written to the output stream.
207 wxTextOutputStream(wxOutputStream
& stream
,
208 wxEOL mode
= wxEOL_NATIVE
);
211 Destroys the wxTextOutputStream object.
213 ~wxTextOutputStream();
216 Returns the end-of-line mode. One of @b wxEOL_DOS, @b wxEOL_MAC and @b
222 Writes a character to the stream.
224 void PutChar(wxChar c
);
227 Set the end-of-line mode. One of @b wxEOL_NATIVE, @b wxEOL_DOS, @b wxEOL_MAC
230 void SetMode(wxEOL mode
= wxEOL_NATIVE
);
233 Writes the 16 bit integer @a i16 to the stream.
235 void Write16(wxUint16 i16
);
238 Writes the 32 bit integer @a i32 to the stream.
240 void Write32(wxUint32 i32
);
243 Writes the single byte @a i8 to the stream.
245 void Write8(wxUint8 i8
);
248 Writes the double @a f to the stream using the IEEE format.
250 virtual void WriteDouble(double f
);
253 Writes @a string as a line. Depending on the end-of-line mode the end of
254 line ('\n') characters in the string are converted to the correct
255 line ending terminator.
257 virtual void WriteString(const wxString
& string
);