QtPass 2.0.0
Developer documentation
Loading...
Searching...
No Matches
Executor::CappedOutput Class Reference

A stream of bytes held as its first and last kMaxStderrBytes / 2 bytes, with its gpg status records counted whole. More...

#include <executor.h>

Public Member Functions

void append (const QByteArray &chunk)
 Add what the process wrote next.
auto take () -> QByteArray
 Everything kept, and start over.
auto statusCounts () const -> QHash< QString, qint64 >
 How many complete lines of each gpg status keyword came by since the last take(), the left-out ones included.
void clear ()
 Drop everything, counts included, for the next command.

Static Public Attributes

static constexpr qsizetype kMaxStatusLineBytes = 1024
 Longest line still looked at for a status keyword.
static constexpr int kMaxStatusKeywords = 64
 Most distinct status keywords counted.

Private Member Functions

void countStatus (const QByteArray &line)
 Count line if it is a status record.

Private Attributes

QByteArray m_line
 The line not ended yet; empty once it ran too long.
bool m_lineTooLong = false
 The line not ended yet ran past kMaxStatusLineBytes.
QHash< QString, qint64 > m_status
 Status keyword to count, see statusCounts().
QByteArray m_head
 The first bytes, up to half the cap.
QByteArray m_tail
 The latest bytes, up to half the cap.
qint64 m_dropped = 0
 Bytes that fell out between head and tail.

Detailed Description

A stream of bytes held as its first and last kMaxStderrBytes / 2 bytes, with its gpg status records counted whole.

What is left out of the text is still counted: a caller that judges a run by its status records (RealPass counting END_ENCRYPTION against the entries pass re-encrypted) reads statusCounts(), not the capped text.

Definition at line 193 of file executor.h.

Member Function Documentation

◆ append()

void Executor::CappedOutput::append ( const QByteArray & chunk)

Add what the process wrote next.

Parameters
chunkThe bytes, in order.

Definition at line 89 of file executor.cpp.

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

◆ clear()

void Executor::CappedOutput::clear ( )
inline

Drop everything, counts included, for the next command.

Definition at line 221 of file executor.h.

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

◆ countStatus()

void Executor::CappedOutput::countStatus ( const QByteArray & line)
private

Count line if it is a status record.

Parameters
lineOne line, without its line end.

Definition at line 72 of file executor.cpp.

Here is the caller graph for this function:

◆ statusCounts()

auto Executor::CappedOutput::statusCounts ( ) const -> QHash< QString, qint64 >
inlinenodiscard

How many complete lines of each gpg status keyword came by since the last take(), the left-out ones included.

A line counts when it starts with "[GNUPG:] "; its keyword is the word after that. Lines longer than kMaxStatusLineBytes, and keywords past the first kMaxStatusKeywords, are not counted: gpg's own status lines are short and few in kind.

Returns
Keyword to count.

Definition at line 217 of file executor.h.

Here is the caller graph for this function:

◆ take()

auto Executor::CappedOutput::take ( ) -> QByteArray

Everything kept, and start over.

Returns
The bytes as written when nothing was left out; otherwise the head, a line saying how many bytes were left out, and the tail, each cut at a UTF-8 character boundary.

Definition at line 131 of file executor.cpp.

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

Member Data Documentation

◆ kMaxStatusKeywords

int Executor::CappedOutput::kMaxStatusKeywords = 64
staticconstexpr

Most distinct status keywords counted.

Definition at line 228 of file executor.h.

◆ kMaxStatusLineBytes

qsizetype Executor::CappedOutput::kMaxStatusLineBytes = 1024
staticconstexpr

Longest line still looked at for a status keyword.

Definition at line 226 of file executor.h.

◆ m_dropped

qint64 Executor::CappedOutput::m_dropped = 0
private

Bytes that fell out between head and tail.

Definition at line 247 of file executor.h.

◆ m_head

QByteArray Executor::CappedOutput::m_head
private

The first bytes, up to half the cap.

Definition at line 243 of file executor.h.

◆ m_line

QByteArray Executor::CappedOutput::m_line
private

The line not ended yet; empty once it ran too long.

Definition at line 237 of file executor.h.

◆ m_lineTooLong

bool Executor::CappedOutput::m_lineTooLong = false
private

The line not ended yet ran past kMaxStatusLineBytes.

Definition at line 239 of file executor.h.

◆ m_status

QHash<QString, qint64> Executor::CappedOutput::m_status
private

Status keyword to count, see statusCounts().

Definition at line 241 of file executor.h.

◆ m_tail

QByteArray Executor::CappedOutput::m_tail
private

The latest bytes, up to half the cap.

Definition at line 245 of file executor.h.


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