summaryrefslogtreecommitdiff
path: root/indra/llcommon/llstreamqueue.h
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2012-01-12 12:19:27 -0500
committerNat Goodspeed <nat@lindenlab.com>2012-01-12 12:19:27 -0500
commit39a86eda8d6d810bd7f4dd6b96f022548a496ba1 (patch)
treea2ec5e25a034443a9b5828392a1ce6e99a2ab9ef /indra/llcommon/llstreamqueue.h
parent61b5f3143e4ea53c9f64e5a1a5ad19f2edf3e776 (diff)
Add LLStreamQueue::size() and tests to exercise it.
Diffstat (limited to 'indra/llcommon/llstreamqueue.h')
-rw-r--r--indra/llcommon/llstreamqueue.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/indra/llcommon/llstreamqueue.h b/indra/llcommon/llstreamqueue.h
index 2fbc2067d2..0726bad175 100644
--- a/indra/llcommon/llstreamqueue.h
+++ b/indra/llcommon/llstreamqueue.h
@@ -53,6 +53,7 @@ class LLGenericStreamQueue
{
public:
LLGenericStreamQueue():
+ mSize(0),
mClosed(false)
{}
@@ -134,6 +135,7 @@ public:
// we want this to scale to large data volumes, better to allocate
// individual pieces.
mBuffer.push_back(string(s, n));
+ mSize += n;
return n;
}
@@ -167,10 +169,17 @@ public:
/// at EOF we simply skip 0 characters.
std::streamsize skip(std::streamsize n);
+ /// How many characters do we currently have buffered?
+ std::streamsize size() const
+ {
+ return mSize;
+ }
+
private:
typedef std::basic_string<Ch> string;
typedef std::list<string> BufferList;
BufferList mBuffer;
+ std::streamsize mSize;
bool mClosed;
};
@@ -212,12 +221,14 @@ std::streamsize LLGenericStreamQueue<Ch>::skip(std::streamsize n)
std::streamsize chunk(bli->length());
typename BufferList::iterator zap(bli++);
mBuffer.erase(zap);
+ mSize -= chunk;
toskip -= chunk;
skipped += chunk;
}
if (bli != blend && toskip)
{
bli->erase(bli->begin(), bli->begin() + toskip);
+ mSize -= toskip;
skipped += toskip;
}
return skipped;