Loading files
// Created on: 2001-08-01
// Created by: Julia DOROVSKIKH
// Copyright (c) 2001-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
// AGV 130202: Changed prototype LDOM_Node::getOwnerDocument()
#include <XmlObjMgt.hxx>
#include <XmlObjMgt_Array1.hxx>
#include <XmlObjMgt_Document.hxx>
#include <XmlObjMgt_DOMString.hxx>
IMPLEMENT_DOMSTRING(LowerString, "lower")
IMPLEMENT_DOMSTRING(UpperString, "upper")
IMPLEMENT_DOMSTRING(IndString, "index")
//=================================================================================================
XmlObjMgt_Array1::XmlObjMgt_Array1(const XmlObjMgt_Element& theParent,
const XmlObjMgt_DOMString& theName)
: myElement(XmlObjMgt::FindChildByName(theParent, theName)),
myFirst(1),
myLast(0)
{
if (myElement != nullptr)
{
if (!myElement.getAttribute(::LowerString()).GetInteger(myFirst))
{
myFirst = 1;
}
if (!myElement.getAttribute(::UpperString()).GetInteger(myLast))
{
myLast = 1;
}
}
}
//=================================================================================================
XmlObjMgt_Array1::XmlObjMgt_Array1(const int aFirst, const int aLast)
: myFirst(aFirst),
myLast(aLast)
{
}
//=================================================================================================
void XmlObjMgt_Array1::CreateArrayElement(XmlObjMgt_Element& theParent,
const XmlObjMgt_DOMString& theName)
{
if (myLast > 0)
{
// AGV XmlObjMgt_Document& anOwnerDoc =
// AGV (XmlObjMgt_Document&)theParent.getOwnerDocument();
XmlObjMgt_Document anOwnerDoc = XmlObjMgt_Document(theParent.getOwnerDocument());
myElement = anOwnerDoc.createElement(theName);
theParent.appendChild(myElement);
if (myLast > 1)
{
myElement.setAttribute(::UpperString(), myLast);
if (myFirst != 1)
{
myElement.setAttribute(::LowerString(), myFirst);
}
}
}
}
//=================================================================================================
void XmlObjMgt_Array1::SetValue(const int theIndex, XmlObjMgt_Element& theValue)
{
myElement.appendChild(theValue);
theValue.setAttribute(::IndString(), theIndex);
}
//=================================================================================================
XmlObjMgt_Element XmlObjMgt_Array1::Value(const int theIndex) const
{
XmlObjMgt_Element anElem;
if (theIndex >= myFirst && theIndex <= myLast)
{
int ind;
LDOM_Node aNode = myElement.getFirstChild();
while (!aNode.isNull())
{
if (aNode.getNodeType() == LDOM_Node::ELEMENT_NODE)
{
anElem = (XmlObjMgt_Element&)aNode;
if (anElem.getAttribute(::IndString()).GetInteger(ind))
{
if (ind == theIndex)
{
break;
}
}
}
aNode = aNode.getNextSibling();
}
}
return anElem;
}
f2929057eThis file is pinned to the selected release. Download the original to open it in your design tool.