libzypp: zypp-core/zyppng/io/private/iobuffer_p.h Source File

libzypp 17.36.6

iobuffer_p.h
Go to the documentation of this file.
1#ifndef ZYPPNG_IO_IOBUFFER_P_H
2#define ZYPPNG_IO_IOBUFFER_P_H
3
4#include <zypp-core/zyppng/core/ByteArray>
5#include <vector>
6#include <cstdint>
7
8namespace zyppng {
9
10 class IOBuffer {
11
12 struct Chunk {
13 ByteArray _buffer;
14
15 int64_t head = 0;
16 int64_t tail = 0;
17
18 char * data () {
19 return _buffer.data() + head;
20 }
21
22 const char * data () const {
23 return _buffer.data() + head;
24 }
25
26 int64_t available() const {
27 return _buffer.size() - tail;
28 }
29 int64_t len () const {
30 return tail - head;
31 }
32 };
33
34 public:
35 IOBuffer( int64_t chunkSize = 0 );
36
37 char *reserve( int64_t bytes );
38 char *front ();
39 int64_t frontSize () const;
40 void clear ( );
41 int64_t discard( int64_t bytes );
42 void chop ( int64_t bytes );
43 void append ( const char *data, int64_t count );
44 void append ( const ByteArray &data );
45 int64_t read ( char *buffer, int64_t max );
46 int64_t size ( ) const;
47 std::vector<Chunk>::size_type chunks () const;
48 inline int64_t indexOf ( const char c ) const { return indexOf( c, size() ); }
49 int64_t indexOf (const char c, int64_t maxCount, int64_t pos = 0 ) const;
50 ByteArray readUntil ( const char delim, const int64_t max = 0 );
51 int64_t readUntil( char *buffer, const char delim, int64_t max );
52 ByteArray readLine ( const int64_t max = 0 );
53 int64_t readLine( char *buffer, int64_t max );
54 bool canReadUntil ( const char delim ) const;
55 bool canReadLine () const;
56
57 private:
58 int64_t _defaultChunkSize;
59 std::vector<Chunk> _chunks;
60 };
61
62}
63
64#endif
zypp::ByteArray
Definition ByteArray.h:19
zyppng::IOBuffer::_chunks
std::vector< Chunk > _chunks
Definition iobuffer_p.h:59
zyppng::IOBuffer::readUntil
ByteArray readUntil(const char delim, const int64_t max=0)
Definition iobuffer.cc:205
zyppng::IOBuffer::canReadUntil
bool canReadUntil(const char delim) const
Definition iobuffer.cc:238
zyppng::IOBuffer::canReadLine
bool canReadLine() const
Definition iobuffer.cc:243
zyppng::IOBuffer::_defaultChunkSize
int64_t _defaultChunkSize
Definition iobuffer_p.h:58
zyppng::IOBuffer::readLine
ByteArray readLine(const int64_t max=0)
Definition iobuffer.cc:228
zyppng::IOBuffer::chop
void chop(int64_t bytes)
Definition iobuffer.cc:87
zyppng::IOBuffer::size
int64_t size() const
Definition iobuffer.cc:154
zyppng::IOBuffer::front
char * front()
Definition iobuffer.cc:35
zyppng::IOBuffer::chunks
std::vector< Chunk >::size_type chunks() const
Definition iobuffer.cc:162
zyppng::IOBuffer::read
int64_t read(char *buffer, int64_t max)
Definition iobuffer.cc:133
zyppng::IOBuffer::append
void append(const char *data, int64_t count)
Definition iobuffer.cc:113
zyppng::IOBuffer::indexOf
int64_t indexOf(const char c) const
Definition iobuffer_p.h:48
zyppng::IOBuffer::reserve
char * reserve(int64_t bytes)
Definition iobuffer.cc:14
zyppng::IOBuffer::IOBuffer
IOBuffer(int64_t chunkSize=0)
Definition iobuffer.cc:11
zyppng::IOBuffer::discard
int64_t discard(int64_t bytes)
Definition iobuffer.cc:55
zyppng::IOBuffer::frontSize
int64_t frontSize() const
Definition iobuffer.cc:43
zyppng::IOBuffer::clear
void clear()
Definition iobuffer.cc:50
zyppng
Definition MediaCurl2.h:22
zyppng::IOBuffer::Chunk
Definition iobuffer_p.h:12
zyppng::IOBuffer::Chunk::_buffer
ByteArray _buffer
Definition iobuffer_p.h:13
zyppng::IOBuffer::Chunk::available
int64_t available() const
Definition iobuffer_p.h:26
zyppng::IOBuffer::Chunk::data
char * data()
Definition iobuffer_p.h:18
zyppng::IOBuffer::Chunk::len
int64_t len() const
Definition iobuffer_p.h:29
zyppng::IOBuffer::Chunk::data
const char * data() const
Definition iobuffer_p.h:22
zyppng::IOBuffer::Chunk::tail
int64_t tail
Definition iobuffer_p.h:16
zyppng::IOBuffer::Chunk::head
int64_t head
Definition iobuffer_p.h:15