MCPcopy Create free account
hub / github.com/cinder/Cinder / readStringUntil

Method readStringUntil

src/cinder/Serial.cpp:321–345  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

319}
320
321std::string Serial::readStringUntil( char token, size_t maxLength, double timeoutSeconds )
322{
323 std::string buffer;
324 buffer.reserve( 1024 );
325
326 bool useMaxLength = maxLength > 0;
327 bool useTimer = timeoutSeconds > 0;
328 Timer timer( useTimer );
329
330 bool done = false;
331 while( ! done ) {
332 char v = readChar();
333 buffer.push_back( v );
334 if( v == token ) {
335 done = true;
336 }
337 else if( useMaxLength && ( buffer.size() >= maxLength ) ) {
338 done = true;
339 }
340 else if( useTimer && ( timer.getSeconds() > timeoutSeconds ) ) {
341 throw SerialTimeoutExc();
342 }
343 }
344 return buffer;
345}
346
347void Serial::writeString( const std::string &str )
348{

Callers 1

updateMethod · 0.80

Calls 5

readCharFunction · 0.85
getSecondsMethod · 0.80
reserveMethod · 0.45
push_backMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected