UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
LineBuffer Class Reference

#include <line_buffer.hpp>

Collaboration diagram for LineBuffer:
Collaboration graph

Public Member Functions

bool hasLine () const
 
std::string_view peek () const
 
void pop ()
 
void write (std::string_view str)
 

Private Member Functions

void reduceBuf ()
 

Private Attributes

std::string buf
 
size_t endIdx = 0
 
size_t startIdx = 0
 

Detailed Description

Definition at line 7 of file line_buffer.hpp.

Member Function Documentation

◆ hasLine()

bool LineBuffer::hasLine ( ) const
inline

Definition at line 11 of file line_buffer.hpp.

11{ return startIdx != endIdx; }
size_t endIdx
size_t startIdx

References endIdx, and startIdx.

Referenced by LaunchContext::processOutput(), ControlPort::readReady(), and write().

◆ peek()

std::string_view LineBuffer::peek ( ) const
inline

Definition at line 14 of file line_buffer.hpp.

14 {
15 return std::string_view(buf.data() + startIdx, endIdx - startIdx);
16 }
std::string buf

References buf, endIdx, and startIdx.

Referenced by LaunchContext::processOutput(), and ControlPort::readReady().

◆ pop()

void LineBuffer::pop ( )

Definition at line 14 of file line_buffer.cpp.

14 {
16 auto idx = buf.find('\n', endIdx);
17 if(idx != buf.npos){
18 endIdx = idx + 1;
19 }
20}

References buf, endIdx, and startIdx.

Referenced by LaunchContext::processOutput(), ControlPort::readReady(), and write().

◆ reduceBuf()

void LineBuffer::reduceBuf ( )
private

Definition at line 22 of file line_buffer.cpp.

22 {
23 assert(startIdx <= endIdx);
24 buf.erase(0, startIdx);
26 startIdx = 0;
27}

References buf, endIdx, and startIdx.

Referenced by write().

◆ write()

void LineBuffer::write ( std::string_view str)

Definition at line 4 of file line_buffer.cpp.

4 {
5 reduceBuf();
6
7 buf += str;
8
9 if(!hasLine()){
10 pop();
11 }
12}
bool hasLine() const
void reduceBuf()

References buf, hasLine(), pop(), and reduceBuf().

Referenced by LaunchContext::processOutput(), and ControlPort::readReady().

Here is the call graph for this function:

Member Data Documentation

◆ buf

std::string LineBuffer::buf
private

Definition at line 23 of file line_buffer.hpp.

Referenced by peek(), pop(), reduceBuf(), and write().

◆ endIdx

size_t LineBuffer::endIdx = 0
private

Definition at line 25 of file line_buffer.hpp.

Referenced by hasLine(), peek(), pop(), and reduceBuf().

◆ startIdx

size_t LineBuffer::startIdx = 0
private

Definition at line 24 of file line_buffer.hpp.

Referenced by hasLine(), peek(), pop(), and reduceBuf().


The documentation for this class was generated from the following files: