diff options
author | Mark Palange (Mani) <palange@lindenlab.com> | 2010-06-07 13:16:39 -0700 |
---|---|---|
committer | Mark Palange (Mani) <palange@lindenlab.com> | 2010-06-07 13:16:39 -0700 |
commit | 09e1f88cc6a7dc0f52ad9d620a27cd54b4af021c (patch) | |
tree | af6fb655a9dff65772855d1bf9d67b1f6acb0f01 /indra/llui/lltextparser.cpp | |
parent | 71f39136795609700a6eb46aad7b0f1397a860d0 (diff) | |
parent | 474832b084891df42d731e6d48770b9e969d7b2a (diff) |
Automated merge with ssh://hg.lindenlab.com/palange/viewer-2-0
Diffstat (limited to 'indra/llui/lltextparser.cpp')
-rw-r--r-- | indra/llui/lltextparser.cpp | 40 |
1 files changed, 14 insertions, 26 deletions
diff --git a/indra/llui/lltextparser.cpp b/indra/llui/lltextparser.cpp index 76a39e3094..2493afcb5d 100644 --- a/indra/llui/lltextparser.cpp +++ b/indra/llui/lltextparser.cpp @@ -43,29 +43,14 @@ #include "v4color.h" #include "lldir.h" -// Routines used for parsing text for TextParsers and html - -LLTextParser* LLTextParser::sInstance = NULL; - // // Member Functions // -LLTextParser::~LLTextParser() -{ - sInstance=NULL; -} +LLTextParser::LLTextParser() +: mLoaded(false) +{} -// static -LLTextParser* LLTextParser::getInstance() -{ - if (!sInstance) - { - sInstance = new LLTextParser(); - sInstance->loadFromDisk(); - } - return sInstance; -} // Moved triggerAlerts() to llfloaterchat.cpp to break llui/llaudio library dependency. @@ -105,6 +90,8 @@ S32 LLTextParser::findPattern(const std::string &text, LLSD highlight) LLSD LLTextParser::parsePartialLineHighlights(const std::string &text, const LLColor4 &color, EHighlightPosition part, S32 index) { + loadKeywords(); + //evil recursive string atomizer. LLSD ret_llsd, start_llsd, middle_llsd, end_llsd; @@ -195,6 +182,8 @@ LLSD LLTextParser::parsePartialLineHighlights(const std::string &text, const LLC bool LLTextParser::parseFullLineHighlights(const std::string &text, LLColor4 *color) { + loadKeywords(); + for (S32 i=0;i<mHighlights.size();i++) { if ((S32)mHighlights[i]["highlight"]==ALL || (S32)mHighlights[i]["condition"]==MATCHES) @@ -221,14 +210,14 @@ std::string LLTextParser::getFileName() return path; } -LLSD LLTextParser::loadFromDisk() +void LLTextParser::loadKeywords() { - std::string filename=getFileName(); - if (filename.empty()) - { - llwarns << "LLTextParser::loadFromDisk() no valid user directory." << llendl; + if (mLoaded) + {// keywords already loaded + return; } - else + std::string filename=getFileName(); + if (!filename.empty()) { llifstream file; file.open(filename.c_str()); @@ -237,9 +226,8 @@ LLSD LLTextParser::loadFromDisk() LLSDSerialize::fromXML(mHighlights, file); } file.close(); + mLoaded = true; } - - return mHighlights; } bool LLTextParser::saveToDisk(LLSD highlights) |