FastLED 3.10.8
Loading...
Searching...
No Matches

◆ getline()

istream_real & fl::istream_real::getline ( string & str)

Definition at line 339 of file istream.cpp.hpp.

339 {
340 str.clear();
341
342 // Read from current buffer position to end
343 while (mPos < mBufferLen) {
344 if (mBuffer[mPos] == '\n') {
345 mPos++; // Consume the newline
346 return *this;
347 }
348 // Explicitly append as a character string to avoid fl::u8->number conversion
349 char ch[2] = {mBuffer[mPos], '\0'};
350 str.append(ch, 1);
351 mPos++;
352 }
353
354 // If we need more data, read a new line
355 if (fl::available() > 0) {
356 // Read more characters until newline
357 while (fl::available() > 0) {
358 int c = fl::read();
359 if (c == -1) break;
360 if (c == '\n') break;
361 if (c == '\r') continue; // Skip carriage return
362 // Explicitly append as a character string to avoid fl::u8->number conversion
363 char ch[2] = {static_cast<char>(c), '\0'};
364 str.append(ch, 1);
365 }
366 }
367
368 return *this;
369}
fl::size mBufferLen
Definition istream.h:32
fl::size mPos
Definition istream.h:33
char mBuffer[BUFFER_SIZE]
Definition istream.h:31
int read() FL_NO_EXCEPT
int available() FL_NO_EXCEPT

References istream_real(), fl::available(), fl::FL_NO_EXCEPT, mBuffer, mBufferLen, mPos, and fl::read().

Referenced by fl::istream::getline().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: