3 #ifndef CRYPTOPP_QUEUE_H
4 #define CRYPTOPP_QUEUE_H
9 NAMESPACE_BEGIN(CryptoPP)
24 {
return CurrentSize();}
29 byte * CreatePutSpace(
size_t &size);
30 size_t Put2(
const byte *inString,
size_t length,
int messageEnd,
bool blocking);
32 size_t Get(byte &outByte);
33 size_t Get(byte *outString,
size_t getMax);
35 size_t Peek(byte &outByte)
const;
36 size_t Peek(byte *outString,
size_t peekMax)
const;
38 size_t TransferTo2(BufferedTransformation &target, lword &transferBytes,
const std::string &channel=
DEFAULT_CHANNEL,
bool blocking=
true);
39 size_t CopyRangeTo2(BufferedTransformation &target, lword &begin, lword end=LWORD_MAX,
const std::string &channel=
DEFAULT_CHANNEL,
bool blocking=
true)
const;
42 void SetNodeSize(
size_t nodeSize);
44 lword CurrentSize()
const;
49 void Unget(byte inByte);
50 void Unget(
const byte *inString,
size_t length);
52 const byte * Spy(
size_t &contiguousSize)
const;
54 void LazyPut(
const byte *inString,
size_t size);
55 void LazyPutModifiable(byte *inString,
size_t size);
56 void UndoLazyPut(
size_t size);
57 void FinalizeLazyPut();
60 bool operator==(
const ByteQueue &rhs)
const;
61 byte operator[](lword i)
const;
68 : m_queue(queue) {Initialize();}
70 lword GetCurrentPosition() {
return m_position;}
73 {
return m_queue.CurrentSize() - m_position;}
77 size_t Get(byte &outByte);
78 size_t Get(byte *outString,
size_t getMax);
80 size_t Peek(byte &outByte)
const;
81 size_t Peek(byte *outString,
size_t peekMax)
const;
83 size_t TransferTo2(BufferedTransformation &target, lword &transferBytes,
const std::string &channel=
DEFAULT_CHANNEL,
bool blocking=
true);
84 size_t CopyRangeTo2(BufferedTransformation &target, lword &begin, lword end=LWORD_MAX,
const std::string &channel=
DEFAULT_CHANNEL,
bool blocking=
true)
const;
88 const ByteQueueNode *m_node;
91 const byte *m_lazyString;
98 void CleanupUsedNodes();
104 ByteQueueNode *m_head, *m_tail;
107 bool m_lazyStringModifiable;
115 : m_bq(bq) {bq.LazyPut(inString, size);}
117 {
try {m_bq.FinalizeLazyPut();}
catch(...) {}}
129 :
LazyPutter(bq) {bq.LazyPutModifiable(inString, size);}
use this to make sure LazyPut is finalized in event of exception
like LazyPutter, but does a LazyPutModifiable instead
lword MaxRetrievable() const
returns number of bytes that is currently ready for retrieval
const std::string DEFAULT_CHANNEL
the default channel for BufferedTransformation, equal to the empty string
lword MaxRetrievable() const
returns number of bytes that is currently ready for retrieval
bool AnyRetrievable() const
returns whether any bytes are currently ready for retrieval
interface for retrieving values given their names