1 // Created on: 2017-02-16
2 // Created by: Sergey NIKONOV
3 // Copyright (c) 2000-2017 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <XCAFDoc_AssemblyItemId.hxx>
18 XCAFDoc_AssemblyItemId::XCAFDoc_AssemblyItemId()
23 XCAFDoc_AssemblyItemId::XCAFDoc_AssemblyItemId(const TColStd_ListOfAsciiString& thePath)
28 XCAFDoc_AssemblyItemId::XCAFDoc_AssemblyItemId(const TCollection_AsciiString& theString)
34 XCAFDoc_AssemblyItemId::Init(const TColStd_ListOfAsciiString& thePath)
40 XCAFDoc_AssemblyItemId::Init(const TCollection_AsciiString& theString)
44 for (Standard_Integer iEntry = 1; ; ++iEntry)
46 TCollection_AsciiString anEntry = theString.Token("/", iEntry);
47 if (anEntry.IsEmpty())
50 myPath.Append(anEntry);
55 XCAFDoc_AssemblyItemId::IsNull() const
57 return myPath.IsEmpty();
61 XCAFDoc_AssemblyItemId::Nullify()
67 XCAFDoc_AssemblyItemId::IsChild(const XCAFDoc_AssemblyItemId& theOther) const
69 if (myPath.Size() <= theOther.myPath.Size())
70 return Standard_False;
72 TColStd_ListOfAsciiString::Iterator anIt(myPath), anItOther(theOther.myPath);
73 for (; anItOther.More(); anIt.Next(), anItOther.Next())
75 if (anIt.Value() != anItOther.Value())
76 return Standard_False;
83 XCAFDoc_AssemblyItemId::IsDirectChild(const XCAFDoc_AssemblyItemId& theOther) const
85 return ((myPath.Size() == theOther.myPath.Size() - 1) && IsChild(theOther));
89 XCAFDoc_AssemblyItemId::IsEqual(const XCAFDoc_AssemblyItemId& theOther) const
91 if (this == &theOther)
94 if (myPath.Size() != theOther.myPath.Size())
95 return Standard_False;
97 TColStd_ListOfAsciiString::Iterator anIt(myPath), anItOther(theOther.myPath);
98 for (; anIt.More() && anItOther.More(); anIt.Next(), anItOther.Next())
100 if (anIt.Value() != anItOther.Value())
101 return Standard_False;
104 return Standard_True;
108 TColStd_ListOfAsciiString& XCAFDoc_AssemblyItemId::GetPath() const
113 TCollection_AsciiString
114 XCAFDoc_AssemblyItemId::ToString() const
116 TCollection_AsciiString aStr;
117 for (TColStd_ListOfAsciiString::Iterator anIt(myPath); anIt.More(); anIt.Next())
120 aStr += anIt.Value();