diff options
author | James Cook <james@lindenlab.com> | 2007-01-02 08:33:20 +0000 |
---|---|---|
committer | James Cook <james@lindenlab.com> | 2007-01-02 08:33:20 +0000 |
commit | 420b91db29485df39fd6e724e782c449158811cb (patch) | |
tree | b471a94563af914d3ed3edd3e856d21cb1b69945 /indra/llcommon/llfixedbuffer.cpp |
Print done when done.
Diffstat (limited to 'indra/llcommon/llfixedbuffer.cpp')
-rw-r--r-- | indra/llcommon/llfixedbuffer.cpp | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/indra/llcommon/llfixedbuffer.cpp b/indra/llcommon/llfixedbuffer.cpp new file mode 100644 index 0000000000..ca7bf1ce48 --- /dev/null +++ b/indra/llcommon/llfixedbuffer.cpp @@ -0,0 +1,71 @@ +/** + * @file llfixedbuffer.cpp + * + * Copyright (c) 2001-$CurrentYear$, Linden Research, Inc. + * $License$ + */ +#include "linden_common.h" + +#include "llfixedbuffer.h" + +LLFixedBuffer::LLFixedBuffer(const U32 max_lines) +{ + mMaxLines = max_lines; + mTimer.reset(); +} + + +LLFixedBuffer::~LLFixedBuffer() +{ + clear(); +} + + +void LLFixedBuffer::clear() +{ + mLines.clear(); + mAddTimes.clear(); + mLineLengths.clear(); + + mTimer.reset(); +} + + +void LLFixedBuffer::addLine(const LLString& utf8line) +{ + LLWString wstring = utf8str_to_wstring(utf8line); + LLFixedBuffer::addLine(wstring); +} + +void LLFixedBuffer::addLine(const LLWString& line) +{ + if (line.empty()) + { + return; + } + + removeExtraLines(); + + mLines.push_back(line); + mLineLengths.push_back((S32)line.length()); + mAddTimes.push_back(mTimer.getElapsedTimeF32()); +} + + +void LLFixedBuffer::setMaxLines(S32 max_lines) +{ + mMaxLines = max_lines; + + removeExtraLines(); +} + + +void LLFixedBuffer::removeExtraLines() +{ + while ((S32)mLines.size() > llmax(0, (S32)(mMaxLines - 1))) + { + mLines.pop_front(); + mAddTimes.pop_front(); + mLineLengths.pop_front(); + } +} |