FastLED 3.9.15
Loading...
Searching...
No Matches

◆ getline()

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

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

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