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

Method xsgetn

dlib/matlab/subprocess_stream.cpp:355–387  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

353 }
354
355 std::streamsize xsgetn (
356 char_type* s,
357 std::streamsize n
358 )
359 {
360 std::streamsize temp = n;
361 while (n > 0)
362 {
363 int num = static_cast<int>(egptr() - gptr());
364 if (num >= n)
365 {
366 // copy data from our buffer
367 std::memcpy(s, gptr(), static_cast<size_t>(n));
368 gbump(static_cast<int>(n));
369 return temp;
370 }
371
372 // read more data into our buffer
373 if (num == 0)
374 {
375 if (underflow() == EOF)
376 break;
377 continue;
378 }
379
380 // copy all the data from our buffer
381 std::memcpy(s, gptr(), num);
382 n -= num;
383 gbump(num);
384 s += num;
385 }
386 return temp-n;
387 }
388
389 private:
390

Callers

nothing calls this directly

Calls 1

memcpyFunction · 0.50

Tested by

no test coverage detected