forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandleStream.I
More file actions
88 lines (80 loc) · 1.8 KB
/
handleStream.I
File metadata and controls
88 lines (80 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/**
* PANDA 3D SOFTWARE
* Copyright (c) Carnegie Mellon University. All rights reserved.
*
* All use of this software is subject to the terms of the revised BSD
* license. You should have received a copy of this license along
* with this source code in a file named "LICENSE."
*
* @file handleStream.I
* @author drose
* @date 2009-06-05
*/
/**
*
*/
inline HandleStream::
HandleStream() : std::iostream(&_buf) {
}
/**
*
*/
inline HandleStream::
~HandleStream() {
close();
}
/**
* Attempts to open the given handle for input. The stream may not be
* simultaneously open for input and output.
*/
inline void HandleStream::
open_read(FHandle handle) {
clear((std::ios::iostatetate)0);
_buf.open_read(handle);
if (!_buf.is_open_read()) {
clear(std::ios::failbit);
}
}
/**
* Attempts to open the given handle for output. The stream may not be
* simultaneously open for input and output.
*/
inline void HandleStream::
open_write(FHandle handle) {
clear((std::ios::iostatetate)0);
_buf.open_write(handle);
if (!_buf.is_open_write()) {
clear(std::ios::failbit);
}
}
/**
*
*/
inline void HandleStream::
close() {
_buf.close();
}
/**
* Closes the underlying handle, *without* attempting to flush the stream.
*/
inline void HandleStream::
close_handle() {
_buf.close_handle();
}
/**
* Returns the handle that was passed to open_read() or open_write().
*/
inline FHandle HandleStream::
get_handle() const {
return _buf.get_handle();
}
/**
* Returns true if there is data in the stream's "get" buffer, meaning that at
* least one character can be extracted from the stream without making an OS
* read() call. Returns false if the get buffer is empty, meaning the next
* read call will hit the OS.
*/
inline bool HandleStream::
has_gdata() const {
return _buf.has_gdata();
}