diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/llcommon/llfixedbuffer.cpp | |
parent | README.txt (diff) | |
download | meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2 meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz |
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/llcommon/llfixedbuffer.cpp')
-rw-r--r-- | linden/indra/llcommon/llfixedbuffer.cpp | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/linden/indra/llcommon/llfixedbuffer.cpp b/linden/indra/llcommon/llfixedbuffer.cpp new file mode 100644 index 0000000..795273b --- /dev/null +++ b/linden/indra/llcommon/llfixedbuffer.cpp | |||
@@ -0,0 +1,90 @@ | |||
1 | /** | ||
2 | * @file llfixedbuffer.cpp | ||
3 | * | ||
4 | * Copyright (c) 2001-2007, Linden Research, Inc. | ||
5 | * | ||
6 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
7 | * to you under the terms of the GNU General Public License, version 2.0 | ||
8 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
9 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
10 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
11 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
12 | * | ||
13 | * There are special exceptions to the terms and conditions of the GPL as | ||
14 | * it is applied to this Source Code. View the full text of the exception | ||
15 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
16 | * online at http://secondlife.com/developers/opensource/flossexception | ||
17 | * | ||
18 | * By copying, modifying or distributing this software, you acknowledge | ||
19 | * that you have read and understood your obligations described above, | ||
20 | * and agree to abide by those obligations. | ||
21 | * | ||
22 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
23 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
24 | * COMPLETENESS OR PERFORMANCE. | ||
25 | */ | ||
26 | #include "linden_common.h" | ||
27 | |||
28 | #include "llfixedbuffer.h" | ||
29 | |||
30 | LLFixedBuffer::LLFixedBuffer(const U32 max_lines) | ||
31 | { | ||
32 | mMaxLines = max_lines; | ||
33 | mTimer.reset(); | ||
34 | } | ||
35 | |||
36 | |||
37 | LLFixedBuffer::~LLFixedBuffer() | ||
38 | { | ||
39 | clear(); | ||
40 | } | ||
41 | |||
42 | |||
43 | void LLFixedBuffer::clear() | ||
44 | { | ||
45 | mLines.clear(); | ||
46 | mAddTimes.clear(); | ||
47 | mLineLengths.clear(); | ||
48 | |||
49 | mTimer.reset(); | ||
50 | } | ||
51 | |||
52 | |||
53 | void LLFixedBuffer::addLine(const LLString& utf8line) | ||
54 | { | ||
55 | LLWString wstring = utf8str_to_wstring(utf8line); | ||
56 | LLFixedBuffer::addLine(wstring); | ||
57 | } | ||
58 | |||
59 | void LLFixedBuffer::addLine(const LLWString& line) | ||
60 | { | ||
61 | if (line.empty()) | ||
62 | { | ||
63 | return; | ||
64 | } | ||
65 | |||
66 | removeExtraLines(); | ||
67 | |||
68 | mLines.push_back(line); | ||
69 | mLineLengths.push_back((S32)line.length()); | ||
70 | mAddTimes.push_back(mTimer.getElapsedTimeF32()); | ||
71 | } | ||
72 | |||
73 | |||
74 | void LLFixedBuffer::setMaxLines(S32 max_lines) | ||
75 | { | ||
76 | mMaxLines = max_lines; | ||
77 | |||
78 | removeExtraLines(); | ||
79 | } | ||
80 | |||
81 | |||
82 | void LLFixedBuffer::removeExtraLines() | ||
83 | { | ||
84 | while ((S32)mLines.size() > llmax(0, (S32)(mMaxLines - 1))) | ||
85 | { | ||
86 | mLines.pop_front(); | ||
87 | mAddTimes.pop_front(); | ||
88 | mLineLengths.pop_front(); | ||
89 | } | ||
90 | } | ||