FastLED 3.10.6
Loading...
Searching...
No Matches

◆ getline()

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

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

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

References istream_real(), fl::string::append(), fl::available(), fl::basic_string::clear(), 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: