From 4edf34ed01611d75bdcd98aa065a2b286845ebd9 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 15 Mar 2012 23:30:36 -0400 Subject: Promote LLProcess::ReadPipe::size() to BasePipe (hence WritePipe). Certain use cases need to know whether the WritePipe buffer has been flushed to the pipe, or is still pending. --- indra/llcommon/llprocess.cpp | 1 + indra/llcommon/llprocess.h | 24 ++++++++++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-) (limited to 'indra/llcommon') diff --git a/indra/llcommon/llprocess.cpp b/indra/llcommon/llprocess.cpp index bd08c3ab51..d4786035ce 100644 --- a/indra/llcommon/llprocess.cpp +++ b/indra/llcommon/llprocess.cpp @@ -163,6 +163,7 @@ public: } virtual std::ostream& get_ostream() { return mStream; } + virtual size_type size() const { return mStreambuf.size(); } bool tick(const LLSD&) { diff --git a/indra/llcommon/llprocess.h b/indra/llcommon/llprocess.h index 06ada83698..51010966f9 100644 --- a/indra/llcommon/llprocess.h +++ b/indra/llcommon/llprocess.h @@ -340,6 +340,20 @@ public: typedef std::size_t size_type; static const size_type npos; + + /** + * Get accumulated buffer length. + * + * For WritePipe, is there still pending data to send to child? + * + * For ReadPipe, we often need to refrain from actually reading the + * std::istream returned by get_istream() until we've accumulated + * enough data to make it worthwhile. For instance, if we're expecting + * a number from the child, but the child happens to flush "12" before + * emitting "3\n", get_istream() >> myint could return 12 rather than + * 123! + */ + virtual size_type size() const = 0; }; /// As returned by getWritePipe() or getOptWritePipe() @@ -387,16 +401,6 @@ public: */ virtual std::string read(size_type len) = 0; - /** - * Get accumulated buffer length. - * Often we need to refrain from actually reading the std::istream - * returned by get_istream() until we've accumulated enough data to - * make it worthwhile. For instance, if we're expecting a number from - * the child, but the child happens to flush "12" before emitting - * "3\n", get_istream() >> myint could return 12 rather than 123! - */ - virtual size_type size() const = 0; - /** * Peek at accumulated buffer data without consuming it. Optional * parameters give you substr() functionality. -- cgit v1.2.3