diff options
author | Steven Bennetts <steve@lindenlab.com> | 2009-08-29 06:23:41 +0000 |
---|---|---|
committer | Steven Bennetts <steve@lindenlab.com> | 2009-08-29 06:23:41 +0000 |
commit | a1ed9ccf7330354d5df5083b44643f2a7e56b748 (patch) | |
tree | 75caa29925495a74548111da1800d67126343d13 /indra/llcommon | |
parent | c4384d64a11fe96764f240a9e220989ad5546f16 (diff) |
Partial merge of: viewer-2.0.0-3@131138 texture-pipeline-3@131862 -> viewer-2.0.0-3
Includes:
* DEV-31909 VWR-13251: Revise lscript_library.cpp to allow localization of LSL editor hovertips
* DEV-21938 llSHA1String does not appear where expected in the dropdown "Insert" menu in the LSL editor
* Some cleanup to llerror so that it doesn't depend on llfixedbuffer
* A few misc. server specific changes not related to the texture-pipeline changes (llapp, lloptioninterface)
Diffstat (limited to 'indra/llcommon')
-rw-r--r-- | indra/llcommon/CMakeLists.txt | 2 | ||||
-rw-r--r-- | indra/llcommon/llapp.h | 5 | ||||
-rw-r--r-- | indra/llcommon/llerror.cpp | 17 | ||||
-rw-r--r-- | indra/llcommon/llerrorcontrol.h | 15 | ||||
-rw-r--r-- | indra/llcommon/llfixedbuffer.cpp | 13 | ||||
-rw-r--r-- | indra/llcommon/llfixedbuffer.h | 22 | ||||
-rw-r--r-- | indra/llcommon/lloptioninterface.cpp | 39 | ||||
-rw-r--r-- | indra/llcommon/lloptioninterface.h | 46 | ||||
-rw-r--r-- | indra/llcommon/llstring.h | 20 |
9 files changed, 143 insertions, 36 deletions
diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index 9f1b0b48d8..a93623d24e 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -52,6 +52,7 @@ set(llcommon_SOURCE_FILES llmemtype.cpp llmetrics.cpp llmortician.cpp + lloptioninterface.cpp llptrto.cpp llprocesslauncher.cpp llprocessor.cpp @@ -157,6 +158,7 @@ set(llcommon_HEADER_FILES llmetrics.h llmortician.h llnametable.h + lloptioninterface.h llpointer.h llpreprocessor.h llpriqueuemap.h diff --git a/indra/llcommon/llapp.h b/indra/llcommon/llapp.h index cc60ba0b80..e32a293f1c 100644 --- a/indra/llcommon/llapp.h +++ b/indra/llcommon/llapp.h @@ -37,6 +37,7 @@ #include "llapr.h" #include "llrun.h" #include "llsd.h" +#include "lloptioninterface.h" // Forward declarations class LLErrorThread; @@ -61,7 +62,7 @@ public: }; #endif -class LLApp +class LLApp : public LLOptionInterface { friend class LLErrorThread; public: @@ -110,7 +111,7 @@ public: * @param name The name of the option. * @return Returns the option data. */ - LLSD getOption(const std::string& name) const; + virtual LLSD getOption(const std::string& name) const; /** * @brief Parse command line options and insert them into diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index 8102eddb18..77c0c2294a 100644 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -53,12 +53,11 @@ #include "llapp.h" #include "llapr.h" #include "llfile.h" -#include "llfixedbuffer.h" #include "lllivefile.h" #include "llsd.h" #include "llsdserialize.h" #include "llstl.h" - +#include "lltimer.h" namespace { #if !LL_WINDOWS @@ -192,16 +191,16 @@ namespace { class RecordToFixedBuffer : public LLError::Recorder { public: - RecordToFixedBuffer(LLFixedBuffer& buffer) : mBuffer(buffer) { } + RecordToFixedBuffer(LLLineBuffer* buffer) : mBuffer(buffer) { } virtual void recordMessage(LLError::ELevel level, - const std::string& message) + const std::string& message) { - mBuffer.addLine(message); + mBuffer->addLine(message); } private: - LLFixedBuffer& mBuffer; + LLLineBuffer* mBuffer; }; #if LL_WINDOWS @@ -209,7 +208,7 @@ namespace { { public: virtual void recordMessage(LLError::ELevel level, - const std::string& message) + const std::string& message) { llutf16string utf16str = wstring_to_utf16str(utf8str_to_wstring(message)); @@ -792,7 +791,7 @@ namespace LLError addRecorder(f); } - void logToFixedBuffer(LLFixedBuffer* fixedBuffer) + void logToFixedBuffer(LLLineBuffer* fixedBuffer) { LLError::Settings& s = LLError::Settings::get(); @@ -805,7 +804,7 @@ namespace LLError return; } - s.fixedBufferRecorder = new RecordToFixedBuffer(*fixedBuffer); + s.fixedBufferRecorder = new RecordToFixedBuffer(fixedBuffer); addRecorder(s.fixedBufferRecorder); } diff --git a/indra/llcommon/llerrorcontrol.h b/indra/llcommon/llerrorcontrol.h index a14bcd2ae2..fab0a1ef9f 100644 --- a/indra/llcommon/llerrorcontrol.h +++ b/indra/llcommon/llerrorcontrol.h @@ -38,7 +38,6 @@ #include "boost/function.hpp" #include <string> -class LLFixedBuffer; class LLSD; /* @@ -49,6 +48,18 @@ class LLSD; These implementations are in llerror.cpp. */ +// Line buffer interface +class LLLineBuffer +{ +public: + LLLineBuffer() {}; + virtual ~LLLineBuffer() {}; + + virtual void clear() = 0; // Clear the buffer, and reset it. + + virtual void addLine(const std::string& utf8line) = 0; +}; + namespace LLError { @@ -144,7 +155,7 @@ namespace LLError // each error message is passed to each recorder via recordMessage() void logToFile(const std::string& filename); - void logToFixedBuffer(LLFixedBuffer*); + void logToFixedBuffer(LLLineBuffer*); // Utilities to add recorders for logging to a file or a fixed buffer // A second call to the same function will remove the logger added // with the first. diff --git a/indra/llcommon/llfixedbuffer.cpp b/indra/llcommon/llfixedbuffer.cpp index e9d6029378..1f6a06c247 100644 --- a/indra/llcommon/llfixedbuffer.cpp +++ b/indra/llcommon/llfixedbuffer.cpp @@ -32,20 +32,21 @@ #include "llfixedbuffer.h" +//////////////////////////////////////////////////////////////////////////// + LLFixedBuffer::LLFixedBuffer(const U32 max_lines) - : mMutex(NULL) + : LLLineBuffer(), + mMaxLines(max_lines), + mMutex(NULL) { - mMaxLines = max_lines; mTimer.reset(); } - LLFixedBuffer::~LLFixedBuffer() { clear(); } - void LLFixedBuffer::clear() { mMutex.lock() ; @@ -61,10 +62,10 @@ void LLFixedBuffer::clear() void LLFixedBuffer::addLine(const std::string& utf8line) { LLWString wstring = utf8str_to_wstring(utf8line); - LLFixedBuffer::addLine(wstring); + addWLine(wstring); } -void LLFixedBuffer::addLine(const LLWString& line) +void LLFixedBuffer::addWLine(const LLWString& line) { if (line.empty()) { diff --git a/indra/llcommon/llfixedbuffer.h b/indra/llcommon/llfixedbuffer.h index 992a024df1..01b46d327a 100644 --- a/indra/llcommon/llfixedbuffer.h +++ b/indra/llcommon/llfixedbuffer.h @@ -38,14 +38,14 @@ #include <string> #include "llstring.h" #include "llthread.h" +#include "llerrorcontrol.h" -// Fixed size buffer for console output and other things. - -class LLFixedBuffer +// fixed buffer implementation +class LLFixedBuffer : public LLLineBuffer { public: LLFixedBuffer(const U32 max_lines = 20); - virtual ~LLFixedBuffer(); + ~LLFixedBuffer(); LLTimer mTimer; U32 mMaxLines; @@ -53,22 +53,18 @@ public: std::deque<F32> mAddTimes; std::deque<S32> mLineLengths; - void clear(); // Clear the buffer, and reset it. + /*virtual*/ void clear(); // Clear the buffer, and reset it. - //do not make these two "virtual" - void addLine(const std::string& utf8line); - void addLine(const LLWString& line); + /*virtual*/ void addLine(const std::string& utf8line); - // Get lines currently in the buffer, up to max_size chars, max_length lines - char *getLines(U32 max_size = 0, U32 max_length = 0); void setMaxLines(S32 max_lines); + protected: - virtual void removeExtraLines(); + void removeExtraLines(); + void addWLine(const LLWString& line); protected: LLMutex mMutex ; }; -const U32 FIXED_BUF_MAX_LINE_LEN = 255; // Not including termnating 0 - #endif //LL_FIXED_BUFFER_H diff --git a/indra/llcommon/lloptioninterface.cpp b/indra/llcommon/lloptioninterface.cpp new file mode 100644 index 0000000000..68c1ff1c41 --- /dev/null +++ b/indra/llcommon/lloptioninterface.cpp @@ -0,0 +1,39 @@ +/** + * @file lloptioninterface.cpp + * @brief + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * + * Copyright (c) 2009, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#include "lloptioninterface.h" + + +LLOptionInterface::~LLOptionInterface() +{ + +} diff --git a/indra/llcommon/lloptioninterface.h b/indra/llcommon/lloptioninterface.h new file mode 100644 index 0000000000..4faf95f5e1 --- /dev/null +++ b/indra/llcommon/lloptioninterface.h @@ -0,0 +1,46 @@ +/** + * @file lloptioninterface.h + * @brief + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * + * Copyright (c) 2009, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#ifndef LL_LLOPTIONINTERFACE_H +#define LL_LLOPTIONINTERFACE_H + +#include "linden_common.h" + +class LLSD; +class LLOptionInterface +{ +public: + virtual ~LLOptionInterface() = 0; + virtual LLSD getOption(const std::string& name) const = 0; +}; + +#endif diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h index a15d6a9a14..c6dcdd6d12 100644 --- a/indra/llcommon/llstring.h +++ b/indra/llcommon/llstring.h @@ -281,7 +281,8 @@ public: static void replaceTabsWithSpaces( std::basic_string<T>& string, size_type spaces_per_tab ); static void replaceNonstandardASCII( std::basic_string<T>& string, T replacement ); static void replaceChar( std::basic_string<T>& string, T target, T replacement ); - + static void replaceString( std::basic_string<T>& string, std::basic_string<T> target, std::basic_string<T> replacement ); + static BOOL containsNonprintable(const std::basic_string<T>& string); static void stripNonprintable(std::basic_string<T>& string); @@ -1189,11 +1190,22 @@ template<class T> void LLStringUtilBase<T>::replaceChar( std::basic_string<T>& string, T target, T replacement ) { size_type found_pos = 0; - for (found_pos = string.find(target, found_pos); - found_pos != std::basic_string<T>::npos; - found_pos = string.find(target, found_pos)) + while( (found_pos = string.find(target, found_pos)) != std::basic_string<T>::npos ) { string[found_pos] = replacement; + found_pos++; // avoid infinite defeat if target == replacement + } +} + +//static +template<class T> +void LLStringUtilBase<T>::replaceString( std::basic_string<T>& string, std::basic_string<T> target, std::basic_string<T> replacement ) +{ + size_type found_pos = 0; + while( (found_pos = string.find(target, found_pos)) != std::basic_string<T>::npos ) + { + string.replace( found_pos, target.length(), replacement ); + found_pos += replacement.length(); // avoid infinite defeat if replacement contains target } } |