28 #ifndef Tools_cluster_SshOutputCollector_h
29 #define Tools_cluster_SshOutputCollector_h
34 #include <boost/iterator/iterator_facade.hpp>
69 void add(
const char *data,
size_t len) {
71 memcpy(
ptr, data, len);
83 class iterator :
public boost::iterator_facade<iterator, const std::string, boost::forward_traversal_tag> {
88 iterator(std::vector<Buffer> &buffers,
size_t index=0)
200 #endif // Tools_cluster_SshOutputCollector_h
void increment()
Increment to next output line.
Collects buffers of output from execution of remote SSH command.
std::vector< Buffer > m_buffers
Vector of buffers.
friend class boost::iterator_core_access
size_t m_next_offset
Offset within next buffer of start of next line of output.
iterator end()
Returns iterator at end of output collector.
PageArena memory allocator.
iterator begin()
Returns iterator at beginning of output collector.
size_t m_next_index
Index of buffer in m_buffers holding start of next line of output.
CharArena m_arena
Character arena from which buffers are allocated.
size_t remain() const
Returns amount of unused space remaining in buffer.
size_t size
Size of allocated buffer.
bool equal(iterator const &other) const
Equality comparison.
const std::string & dereference() const
Returns next line.
CharT * alloc(size_t sz)
Allocate sz bytes.
void add(Buffer buf)
Adds filled buffer to collector.
Fixed-size buffer to hold a portion of output.
Logging routines and macros.
std::string m_line
Current line of output.
The PageArena allocator is simple and fast, avoiding individual mallocs/frees.
iterator(std::vector< Buffer > &buffers, size_t index=0)
Constructor.
Iterator for traversing output line-by-line.
char * base
Pointer to beginning of buffer memory.
Buffer(char *buffer, size_t sz=0)
Constructor with allocated page argument.
SshOutputCollector(size_t buffer_size)
Constructor.
void add(const char *data, size_t len)
Adds data to buffer.
char * ptr
Pointer to next unused position in buffer memory.
bool empty() const
Returns true if no output has been collected Returns true if there are no collected buffers or if non...
size_t m_buffer_size
Buffer size
std::vector< Buffer > & m_buffers
Output buffers.
size_t fill() const
Returns amount of buffer filled.
bool last_line_is_partial()
Returns true if last line collected is partial.
size_t m_offset
Offset within current buffer of start of current line of output.
Buffer allocate_buffer()
Allocate a buffer.
size_t buffer_size()
Returns buffer size.
size_t m_index
Index of buffer in m_buffers holding start of current line of output.