MCPcopy Create free account
hub / github.com/davisking/dlib / underflow

Method underflow

dlib/sockstreambuf/sockstreambuf.cpp:94–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92// ----------------------------------------------------------------------------------------
93
94 sockstreambuf::int_type sockstreambuf::
95 underflow(
96 )
97 {
98 if (gptr() < egptr())
99 {
100 return static_cast<unsigned char>(*gptr());
101 }
102
103 int num_put_back = static_cast<int>(gptr() - eback());
104 if (num_put_back > max_putback)
105 {
106 num_put_back = max_putback;
107 }
108
109 // copy the putback characters into the putback end of the in_buffer
110 std::memmove(in_buffer.get()+(max_putback-num_put_back), gptr()-num_put_back, num_put_back);
111
112 if (flushes_output_on_read())
113 {
114 if (flush_out_buffer() == EOF)
115 {
116 // an error occurred
117 return EOF;
118 }
119 }
120
121 int num = con.read(in_buffer.get()+max_putback, in_buffer_size-max_putback);
122 if (num <= 0)
123 {
124 // an error occurred or the connection is over which is EOF
125 return EOF;
126 }
127
128 // reset in_buffer pointers
129 setg (in_buffer.get()+(max_putback-num_put_back),
130 in_buffer.get()+max_putback,
131 in_buffer.get()+max_putback+num);
132
133 return static_cast<unsigned char>(*gptr());
134 }
135
136// ----------------------------------------------------------------------------------------
137

Callers

nothing calls this directly

Calls 2

getMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected