00001 00030 #include "linden_common.h" 00031 00032 #include "llfixedbuffer.h" 00033 00034 LLFixedBuffer::LLFixedBuffer(const U32 max_lines) 00035 { 00036 mMaxLines = max_lines; 00037 mTimer.reset(); 00038 } 00039 00040 00041 LLFixedBuffer::~LLFixedBuffer() 00042 { 00043 clear(); 00044 } 00045 00046 00047 void LLFixedBuffer::clear() 00048 { 00049 mLines.clear(); 00050 mAddTimes.clear(); 00051 mLineLengths.clear(); 00052 00053 mTimer.reset(); 00054 } 00055 00056 00057 void LLFixedBuffer::addLine(const LLString& utf8line) 00058 { 00059 LLWString wstring = utf8str_to_wstring(utf8line); 00060 LLFixedBuffer::addLine(wstring); 00061 } 00062 00063 void LLFixedBuffer::addLine(const LLWString& line) 00064 { 00065 if (line.empty()) 00066 { 00067 return; 00068 } 00069 00070 removeExtraLines(); 00071 00072 mLines.push_back(line); 00073 mLineLengths.push_back((S32)line.length()); 00074 mAddTimes.push_back(mTimer.getElapsedTimeF32()); 00075 } 00076 00077 00078 void LLFixedBuffer::setMaxLines(S32 max_lines) 00079 { 00080 mMaxLines = max_lines; 00081 00082 removeExtraLines(); 00083 } 00084 00085 00086 void LLFixedBuffer::removeExtraLines() 00087 { 00088 while ((S32)mLines.size() > llmax((S32)0, (S32)(mMaxLines - 1))) 00089 { 00090 mLines.pop_front(); 00091 mAddTimes.pop_front(); 00092 mLineLengths.pop_front(); 00093 } 00094 }