MCPcopy Create free account
hub / github.com/Icinga/icinga2 / ReadLine

Method ReadLine

lib/base/stream.cpp:80–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78}
79
80StreamReadStatus Stream::ReadLine(String *line, StreamReadContext& context, bool may_wait)
81{
82 if (context.Eof)
83 return StatusEof;
84
85 if (context.MustRead) {
86 if (!context.FillFromStream(this, may_wait)) {
87 context.Eof = true;
88
89 *line = String(context.Buffer, &(context.Buffer[context.Size]));
90 boost::algorithm::trim_right(*line);
91
92 return StatusNewItem;
93 }
94 }
95
96 for (size_t i = 0; i < context.Size; i++) {
97 if (context.Buffer[i] == '\n') {
98 *line = String(context.Buffer, context.Buffer + i);
99 boost::algorithm::trim_right(*line);
100
101 context.DropData(i + 1u);
102
103 context.MustRead = !context.Size;
104 return StatusNewItem;
105 }
106 }
107
108 context.MustRead = true;
109 return StatusNeedData;
110}
111
112bool StreamReadContext::FillFromStream(const Stream::Ptr& stream, bool may_wait)
113{

Callers 5

CommandPipeThreadMethod · 0.45
ClientHandlerMethod · 0.45
LivestatusQueryHelperFunction · 0.45
BOOST_AUTO_TEST_CASEFunction · 0.45
ProgramClass · 0.45

Calls 3

FillFromStreamMethod · 0.80
DropDataMethod · 0.80
StringClass · 0.70

Tested by

no test coverage detected