0027232: Configuration - fix mblen missing building issue on Android
[occt.git] / src / XmlObjMgt / XmlObjMgt_Array1.cxx
CommitLineData
b311480e 1// Created on: 2001-08-01
2// Created by: Julia DOROVSKIKH
973c2be1 3// Copyright (c) 2001-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
d5f74e42 7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
b311480e 15
16//AGV 130202: Changed prototype LDOM_Node::getOwnerDocument()
7fd59977 17
42cf5bc1 18#include <TCollection_AsciiString.hxx>
7fd59977 19#include <XmlObjMgt.hxx>
42cf5bc1 20#include <XmlObjMgt_Array1.hxx>
3804f298 21#include <XmlObjMgt_Document.hxx>
42cf5bc1 22#include <XmlObjMgt_DOMString.hxx>
7fd59977 23
24IMPLEMENT_DOMSTRING (LowerString, "lower")
25IMPLEMENT_DOMSTRING (UpperString, "upper")
26IMPLEMENT_DOMSTRING (IndString, "index")
27
28//=======================================================================
29//function : XmlObjMgt_Array1
30//purpose : Constructor
31//=======================================================================
32
33XmlObjMgt_Array1::XmlObjMgt_Array1 (const XmlObjMgt_Element& theParent,
34 const XmlObjMgt_DOMString& theName)
35 : myElement (XmlObjMgt::FindChildByName (theParent, theName)),
36 myFirst (1),
37 myLast (0)
38{
39 if (myElement != NULL) {
40 if (!myElement.getAttribute(::LowerString()).GetInteger(myFirst))
41 myFirst = 1;
42 if (!myElement.getAttribute(::UpperString()).GetInteger (myLast))
43 myLast = 1;
44 }
45}
46
47//=======================================================================
48//function : XmlObjMgt_Array1
49//purpose : Constructor
50//=======================================================================
51
52XmlObjMgt_Array1::XmlObjMgt_Array1 (const Standard_Integer aFirst,
53 const Standard_Integer aLast)
54 : myFirst (aFirst), myLast (aLast)
55{}
56
57//=======================================================================
58//function : CreateArrayElement
59//purpose : Create DOM_Element representing the array, under 'theParent'
60//=======================================================================
61
62void XmlObjMgt_Array1::CreateArrayElement (XmlObjMgt_Element& theParent,
63 const XmlObjMgt_DOMString& theName)
64{
65 if (myLast > 0)
66 {
67//AGV XmlObjMgt_Document& anOwnerDoc =
68//AGV (XmlObjMgt_Document&)theParent.getOwnerDocument();
69 XmlObjMgt_Document anOwnerDoc =
70 XmlObjMgt_Document (theParent.getOwnerDocument());
71 myElement = anOwnerDoc.createElement (theName);
72 theParent.appendChild (myElement);
73 if (myLast > 1) {
74 myElement.setAttribute (::UpperString(), myLast);
75 if (myFirst != 1)
76 myElement.setAttribute (::LowerString(), myFirst);
77 }
78 }
79}
80
81//=======================================================================
82//function : SetValue
83//purpose :
84//=======================================================================
85
86void XmlObjMgt_Array1::SetValue
87 (const Standard_Integer theIndex, XmlObjMgt_Element& theValue)
88{
89 myElement.appendChild (theValue);
90 theValue.setAttribute(::IndString(), theIndex);
91}
92
93//=======================================================================
94//function : Value
95//purpose :
96//=======================================================================
97
98XmlObjMgt_Element XmlObjMgt_Array1::Value(const Standard_Integer theIndex) const
99{
100 XmlObjMgt_Element anElem;
101
102 if (theIndex >= myFirst && theIndex <= myLast)
103 {
104 Standard_Integer ind;
105 LDOM_Node aNode = myElement.getFirstChild();
106 while (!aNode.isNull())
107 {
108 if (aNode.getNodeType() == LDOM_Node::ELEMENT_NODE)
109 {
110 anElem = (XmlObjMgt_Element &) aNode;
111 if (anElem.getAttribute(::IndString()).GetInteger(ind))
112 if (ind == theIndex)
113 break;
114 }
115 aNode = aNode.getNextSibling();
116 }
117 }
118 return anElem;
119}