diff options
author | Leyla Farazha <leyla@lindenlab.com> | 2011-10-10 17:09:31 -0700 |
---|---|---|
committer | Leyla Farazha <leyla@lindenlab.com> | 2011-10-10 17:09:31 -0700 |
commit | 5b1301ea8a0e50f2d15700a7e93be7628f6feec8 (patch) | |
tree | f536cbca14fa0cd81d75e7d354bd75b370c18091 /indra/llxuixml/llxuiparser.cpp | |
parent | fd03ae299bfaf83789e511912d99d204c0833e7f (diff) | |
parent | 2d1431b2f0bb903be9259cbcae630f605d9c208c (diff) |
merge
Diffstat (limited to 'indra/llxuixml/llxuiparser.cpp')
-rw-r--r-- | indra/llxuixml/llxuiparser.cpp | 76 |
1 files changed, 32 insertions, 44 deletions
diff --git a/indra/llxuixml/llxuiparser.cpp b/indra/llxuixml/llxuiparser.cpp index c60f656c2c..aee8fa8d8f 100644 --- a/indra/llxuixml/llxuiparser.cpp +++ b/indra/llxuixml/llxuiparser.cpp @@ -513,7 +513,6 @@ static LLInitParam::Parser::parser_inspect_func_map_t sXUIInspectFuncs; // LLXUIParser::LLXUIParser() : Parser(sXUIReadFuncs, sXUIWriteFuncs, sXUIInspectFuncs), - mLastWriteGeneration(-1), mCurReadDepth(0) { if (sXUIReadFuncs.empty()) @@ -583,7 +582,7 @@ bool LLXUIParser::readXUIImpl(LLXMLNodePtr nodep, LLInitParam::BaseBlock& block) if (!text_contents.empty()) { mCurReadNode = nodep; - mNameStack.push_back(std::make_pair(std::string("value"), newParseGeneration())); + mNameStack.push_back(std::make_pair(std::string("value"), true)); // child nodes are not necessarily valid parameters (could be a child widget) // so don't complain once we've recursed if (!block.submitValue(mNameStack, *this, true)) @@ -618,7 +617,7 @@ bool LLXUIParser::readXUIImpl(LLXMLNodePtr nodep, LLInitParam::BaseBlock& block) // since there is no widget named "rect" if (child_name.find(".") == std::string::npos) { - mNameStack.push_back(std::make_pair(child_name, newParseGeneration())); + mNameStack.push_back(std::make_pair(child_name, true)); num_tokens_pushed++; } else @@ -654,7 +653,7 @@ bool LLXUIParser::readXUIImpl(LLXMLNodePtr nodep, LLInitParam::BaseBlock& block) // copy remaining tokens on to our running token list for(tokenizer::iterator token_to_push = name_token_it; token_to_push != name_tokens.end(); ++token_to_push) { - mNameStack.push_back(std::make_pair(*token_to_push, newParseGeneration())); + mNameStack.push_back(std::make_pair(*token_to_push, true)); num_tokens_pushed++; } } @@ -704,7 +703,7 @@ bool LLXUIParser::readAttributes(LLXMLNodePtr nodep, LLInitParam::BaseBlock& blo // copy remaining tokens on to our running token list for(tokenizer::iterator token_to_push = name_tokens.begin(); token_to_push != name_tokens.end(); ++token_to_push) { - mNameStack.push_back(std::make_pair(*token_to_push, newParseGeneration())); + mNameStack.push_back(std::make_pair(*token_to_push, true)); num_tokens_pushed++; } @@ -728,24 +727,13 @@ void LLXUIParser::writeXUI(LLXMLNodePtr node, const LLInitParam::BaseBlock &bloc } // go from a stack of names to a specific XML node -LLXMLNodePtr LLXUIParser::getNode(const name_stack_t& stack) +LLXMLNodePtr LLXUIParser::getNode(name_stack_t& stack) { - name_stack_t name_stack; - for (name_stack_t::const_iterator it = stack.begin(); - it != stack.end(); - ++it) - { - if (!it->first.empty()) - { - name_stack.push_back(*it); - } - } - LLXMLNodePtr out_node = mWriteRootNode; - name_stack_t::const_iterator next_it = name_stack.begin(); - for (name_stack_t::const_iterator it = name_stack.begin(); - it != name_stack.end(); + name_stack_t::iterator next_it = stack.begin(); + for (name_stack_t::iterator it = stack.begin(); + it != stack.end(); it = next_it) { ++next_it; @@ -754,17 +742,18 @@ LLXMLNodePtr LLXUIParser::getNode(const name_stack_t& stack) continue; } - out_nodes_t::iterator found_it = mOutNodes.lower_bound(it->second); + out_nodes_t::iterator found_it = mOutNodes.find(it->first); // node with this name not yet written - if (found_it == mOutNodes.end() || mOutNodes.key_comp()(found_it->first, it->second)) + if (found_it == mOutNodes.end() || it->second) { // make an attribute if we are the last element on the name stack - bool is_attribute = next_it == name_stack.end(); + bool is_attribute = next_it == stack.end(); LLXMLNodePtr new_node = new LLXMLNode(it->first.c_str(), is_attribute); out_node->addChild(new_node); - mOutNodes.insert(found_it, std::make_pair(it->second, new_node)); + mOutNodes[it->first] = new_node; out_node = new_node; + it->second = false; } else { @@ -781,7 +770,7 @@ bool LLXUIParser::readFlag(Parser& parser, void* val_ptr) return self.mCurReadNode == DUMMY_NODE; } -bool LLXUIParser::writeFlag(Parser& parser, const void* val_ptr, const name_stack_t& stack) +bool LLXUIParser::writeFlag(Parser& parser, const void* val_ptr, name_stack_t& stack) { // just create node LLXUIParser& self = static_cast<LLXUIParser&>(parser); @@ -798,7 +787,7 @@ bool LLXUIParser::readBoolValue(Parser& parser, void* val_ptr) return success; } -bool LLXUIParser::writeBoolValue(Parser& parser, const void* val_ptr, const name_stack_t& stack) +bool LLXUIParser::writeBoolValue(Parser& parser, const void* val_ptr, name_stack_t& stack) { LLXUIParser& self = static_cast<LLXUIParser&>(parser); LLXMLNodePtr node = self.getNode(stack); @@ -817,7 +806,7 @@ bool LLXUIParser::readStringValue(Parser& parser, void* val_ptr) return true; } -bool LLXUIParser::writeStringValue(Parser& parser, const void* val_ptr, const name_stack_t& stack) +bool LLXUIParser::writeStringValue(Parser& parser, const void* val_ptr, name_stack_t& stack) { LLXUIParser& self = static_cast<LLXUIParser&>(parser); LLXMLNodePtr node = self.getNode(stack); @@ -855,7 +844,7 @@ bool LLXUIParser::readU8Value(Parser& parser, void* val_ptr) return self.mCurReadNode->getByteValue(1, (U8*)val_ptr); } -bool LLXUIParser::writeU8Value(Parser& parser, const void* val_ptr, const name_stack_t& stack) +bool LLXUIParser::writeU8Value(Parser& parser, const void* val_ptr, name_stack_t& stack) { LLXUIParser& self = static_cast<LLXUIParser&>(parser); LLXMLNodePtr node = self.getNode(stack); @@ -879,7 +868,7 @@ bool LLXUIParser::readS8Value(Parser& parser, void* val_ptr) return false; } -bool LLXUIParser::writeS8Value(Parser& parser, const void* val_ptr, const name_stack_t& stack) +bool LLXUIParser::writeS8Value(Parser& parser, const void* val_ptr, name_stack_t& stack) { LLXUIParser& self = static_cast<LLXUIParser&>(parser); LLXMLNodePtr node = self.getNode(stack); @@ -903,7 +892,7 @@ bool LLXUIParser::readU16Value(Parser& parser, void* val_ptr) return false; } -bool LLXUIParser::writeU16Value(Parser& parser, const void* val_ptr, const name_stack_t& stack) +bool LLXUIParser::writeU16Value(Parser& parser, const void* val_ptr, name_stack_t& stack) { LLXUIParser& self = static_cast<LLXUIParser&>(parser); LLXMLNodePtr node = self.getNode(stack); @@ -927,7 +916,7 @@ bool LLXUIParser::readS16Value(Parser& parser, void* val_ptr) return false; } -bool LLXUIParser::writeS16Value(Parser& parser, const void* val_ptr, const name_stack_t& stack) +bool LLXUIParser::writeS16Value(Parser& parser, const void* val_ptr, name_stack_t& stack) { LLXUIParser& self = static_cast<LLXUIParser&>(parser); LLXMLNodePtr node = self.getNode(stack); @@ -945,7 +934,7 @@ bool LLXUIParser::readU32Value(Parser& parser, void* val_ptr) return self.mCurReadNode->getUnsignedValue(1, (U32*)val_ptr); } -bool LLXUIParser::writeU32Value(Parser& parser, const void* val_ptr, const name_stack_t& stack) +bool LLXUIParser::writeU32Value(Parser& parser, const void* val_ptr, name_stack_t& stack) { LLXUIParser& self = static_cast<LLXUIParser&>(parser); LLXMLNodePtr node = self.getNode(stack); @@ -963,7 +952,7 @@ bool LLXUIParser::readS32Value(Parser& parser, void* val_ptr) return self.mCurReadNode->getIntValue(1, (S32*)val_ptr); } -bool LLXUIParser::writeS32Value(Parser& parser, const void* val_ptr, const name_stack_t& stack) +bool LLXUIParser::writeS32Value(Parser& parser, const void* val_ptr, name_stack_t& stack) { LLXUIParser& self = static_cast<LLXUIParser&>(parser); LLXMLNodePtr node = self.getNode(stack); @@ -981,7 +970,7 @@ bool LLXUIParser::readF32Value(Parser& parser, void* val_ptr) return self.mCurReadNode->getFloatValue(1, (F32*)val_ptr); } -bool LLXUIParser::writeF32Value(Parser& parser, const void* val_ptr, const name_stack_t& stack) +bool LLXUIParser::writeF32Value(Parser& parser, const void* val_ptr, name_stack_t& stack) { LLXUIParser& self = static_cast<LLXUIParser&>(parser); LLXMLNodePtr node = self.getNode(stack); @@ -999,7 +988,7 @@ bool LLXUIParser::readF64Value(Parser& parser, void* val_ptr) return self.mCurReadNode->getDoubleValue(1, (F64*)val_ptr); } -bool LLXUIParser::writeF64Value(Parser& parser, const void* val_ptr, const name_stack_t& stack) +bool LLXUIParser::writeF64Value(Parser& parser, const void* val_ptr, name_stack_t& stack) { LLXUIParser& self = static_cast<LLXUIParser&>(parser); LLXMLNodePtr node = self.getNode(stack); @@ -1023,7 +1012,7 @@ bool LLXUIParser::readColor4Value(Parser& parser, void* val_ptr) return false; } -bool LLXUIParser::writeColor4Value(Parser& parser, const void* val_ptr, const name_stack_t& stack) +bool LLXUIParser::writeColor4Value(Parser& parser, const void* val_ptr, name_stack_t& stack) { LLXUIParser& self = static_cast<LLXUIParser&>(parser); LLXMLNodePtr node = self.getNode(stack); @@ -1050,7 +1039,7 @@ bool LLXUIParser::readUIColorValue(Parser& parser, void* val_ptr) return false; } -bool LLXUIParser::writeUIColorValue(Parser& parser, const void* val_ptr, const name_stack_t& stack) +bool LLXUIParser::writeUIColorValue(Parser& parser, const void* val_ptr, name_stack_t& stack) { LLXUIParser& self = static_cast<LLXUIParser&>(parser); LLXMLNodePtr node = self.getNode(stack); @@ -1079,7 +1068,7 @@ bool LLXUIParser::readUUIDValue(Parser& parser, void* val_ptr) return false; } -bool LLXUIParser::writeUUIDValue(Parser& parser, const void* val_ptr, const name_stack_t& stack) +bool LLXUIParser::writeUUIDValue(Parser& parser, const void* val_ptr, name_stack_t& stack) { LLXUIParser& self = static_cast<LLXUIParser&>(parser); LLXMLNodePtr node = self.getNode(stack); @@ -1098,7 +1087,7 @@ bool LLXUIParser::readSDValue(Parser& parser, void* val_ptr) return true; } -bool LLXUIParser::writeSDValue(Parser& parser, const void* val_ptr, const name_stack_t& stack) +bool LLXUIParser::writeSDValue(Parser& parser, const void* val_ptr, name_stack_t& stack) { LLXUIParser& self = static_cast<LLXUIParser&>(parser); @@ -1207,7 +1196,6 @@ const char* NO_VALUE_MARKER = "no_value"; LLSimpleXUIParser::LLSimpleXUIParser(LLSimpleXUIParser::element_start_callback_t element_cb) : Parser(sSimpleXUIReadFuncs, sSimpleXUIWriteFuncs, sSimpleXUIInspectFuncs), - mLastWriteGeneration(-1), mCurReadDepth(0), mElementCB(element_cb) { @@ -1338,7 +1326,7 @@ void LLSimpleXUIParser::startElement(const char *name, const char **atts) { // compound attribute if (child_name.find(".") == std::string::npos) { - mNameStack.push_back(std::make_pair(child_name, newParseGeneration())); + mNameStack.push_back(std::make_pair(child_name, true)); num_tokens_pushed++; mScope.push_back(child_name); } @@ -1365,7 +1353,7 @@ void LLSimpleXUIParser::startElement(const char *name, const char **atts) // copy remaining tokens on to our running token list for(tokenizer::iterator token_to_push = name_token_it; token_to_push != name_tokens.end(); ++token_to_push) { - mNameStack.push_back(std::make_pair(*token_to_push, newParseGeneration())); + mNameStack.push_back(std::make_pair(*token_to_push, true)); num_tokens_pushed++; } mScope.push_back(mNameStack.back().first); @@ -1398,7 +1386,7 @@ bool LLSimpleXUIParser::readAttributes(const char **atts) // copy remaining tokens on to our running token list for(tokenizer::iterator token_to_push = name_tokens.begin(); token_to_push != name_tokens.end(); ++token_to_push) { - mNameStack.push_back(std::make_pair(*token_to_push, newParseGeneration())); + mNameStack.push_back(std::make_pair(*token_to_push, true)); num_tokens_pushed++; } @@ -1420,7 +1408,7 @@ bool LLSimpleXUIParser::processText() LLStringUtil::trim(mTextContents); if (!mTextContents.empty()) { - mNameStack.push_back(std::make_pair(std::string("value"), newParseGeneration())); + mNameStack.push_back(std::make_pair(std::string("value"), true)); mCurAttributeValueBegin = mTextContents.c_str(); mOutputStack.back().first->submitValue(mNameStack, *this, mParseSilently); mNameStack.pop_back(); |