MCPcopy Create free account
hub / github.com/SoarGroup/Soar / MakeCopy

Method MakeCopy

Core/ElementXML/src/ElementXMLImpl.cpp:504–551  ·  view source on GitHub ↗

* @brief Returns a copy of this object. * Generally, this shouldn't be necessary as ref counting * allows multiple clients to point to the same object. * * Call ReleaseRef() on the returned object when you are done with it. *************************************************************/

Source from the content-addressed store, hash-verified

502* Call ReleaseRef() on the returned object when you are done with it.
503*************************************************************/
504ElementXMLImpl* ElementXMLImpl::MakeCopy() const
505{
506 ElementXMLImpl* pCopy = new ElementXMLImpl() ;
507
508 pCopy->m_ErrorCode = m_ErrorCode ;
509 pCopy->m_UseCData = m_UseCData ;
510
511 pCopy->m_RefCount = 1 ;
512
513 // Start with a null parent and override this later
514 pCopy->m_pParent = NULL ;
515
516 // Copy the comment
517 pCopy->SetComment(m_Comment) ;
518
519 // Copy the tag name
520 pCopy->SetTagName(m_TagName) ;
521
522 // Copy the character data
523 if (m_DataIsBinary)
524 {
525 pCopy->SetBinaryCharacterData(m_CharacterData, m_BinaryDataLength) ;
526 }
527 else
528 {
529 pCopy->SetCharacterData(m_CharacterData) ;
530 }
531
532 // Copy the attributes
533 for (xmlAttributeMapConstIter mapIter = m_AttributeMap.begin() ; mapIter != m_AttributeMap.end() ; mapIter++)
534 {
535 xmlStringConst att = mapIter->first ;
536 xmlStringConst val = mapIter->second ;
537
538 pCopy->AddAttribute(att, val) ;
539 }
540
541 // Copy all of the children, overwriting the parent field for them so that everything connects up correctly.
542 for (xmlListConstIter iterChildren = m_Children.begin() ; iterChildren != m_Children.end() ; iterChildren++)
543 {
544 ElementXMLImpl* pChild = *iterChildren ;
545 ElementXMLImpl* pChildCopy = pChild->MakeCopy() ;
546 pChildCopy->m_pParent = pCopy ;
547 pCopy->AddChild(pChildCopy) ;
548 }
549
550 return pCopy ;
551}
552
553/*************************************************************
554* @brief Release our reference to this object, possibly

Callers 2

soarxml_MakeCopyFunction · 0.80

Calls 7

SetCommentMethod · 0.80
SetTagNameMethod · 0.80
SetCharacterDataMethod · 0.80
endMethod · 0.80
AddAttributeMethod · 0.45
AddChildMethod · 0.45

Tested by

no test coverage detected