0031668: Visualization - WebGL sample doesn't work on Emscripten 1.39
[occt.git] / src / TDataStd / TDataStd_ExtStringArray.hxx
CommitLineData
42cf5bc1 1// Created on: 2002-01-16
2// Created by: Michael PONIKAROV
3// Copyright (c) 2002-2014 OPEN CASCADE SAS
4//
5// This file is part of Open CASCADE Technology software library.
6//
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.
12//
13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
15
16#ifndef _TDataStd_ExtStringArray_HeaderFile
17#define _TDataStd_ExtStringArray_HeaderFile
18
19#include <Standard.hxx>
20#include <Standard_Type.hxx>
21
22#include <TColStd_HArray1OfExtendedString.hxx>
23#include <Standard_Boolean.hxx>
24#include <TDF_Attribute.hxx>
25#include <Standard_Integer.hxx>
26#include <Standard_OStream.hxx>
5a1271c8 27#include <Standard_GUID.hxx>
28
42cf5bc1 29class TDataStd_DeltaOnModificationOfExtStringArray;
30class Standard_GUID;
31class TDF_Label;
32class TCollection_ExtendedString;
33class TDF_Attribute;
34class TDF_RelocationTable;
35class TDF_DeltaOnModification;
36
37
38class TDataStd_ExtStringArray;
39DEFINE_STANDARD_HANDLE(TDataStd_ExtStringArray, TDF_Attribute)
40
7c1a9a46 41//! ExtStringArray Attribute. Handles an array of UNICODE strings (represented by the TCollection_ExtendedString class).
42cf5bc1 42class TDataStd_ExtStringArray : public TDF_Attribute
43{
7c1a9a46 44 friend class TDataStd_DeltaOnModificationOfExtStringArray;
45 DEFINE_STANDARD_RTTIEXT(TDataStd_ExtStringArray, TDF_Attribute)
42cf5bc1 46public:
47
42cf5bc1 48 //! class methods
49 //! =============
50 //! Returns the GUID for the attribute.
51 Standard_EXPORT static const Standard_GUID& GetID();
52
53 //! Finds, or creates, an ExtStringArray attribute with <lower>
54 //! and <upper> bounds on the specified label.
55 //! If <isDelta> == False, DefaultDeltaOnModification is used.
56 //! If <isDelta> == True, DeltaOnModification of the current attribute is used.
57 //! If attribute is already set, all input parameters are refused and the found
58 //! attribute is returned.
59 Standard_EXPORT static Handle(TDataStd_ExtStringArray) Set (const TDF_Label& label, const Standard_Integer lower, const Standard_Integer upper, const Standard_Boolean isDelta = Standard_False);
5a1271c8 60
61 //! Finds, or creates, an ExtStringArray attribute with explicit user defined <guid>.
62 //! The ExtStringArray attribute is returned.
63 Standard_EXPORT static Handle(TDataStd_ExtStringArray) Set (const TDF_Label& label, const Standard_GUID& theGuid,
64 const Standard_Integer lower, const Standard_Integer upper,
65 const Standard_Boolean isDelta = Standard_False);
66
67
42cf5bc1 68 //! Initializes the inner array with bounds from <lower> to <upper>
69 Standard_EXPORT void Init (const Standard_Integer lower, const Standard_Integer upper);
70
71 //! Sets the <Index>th element of the array to <Value>
72 //! OutOfRange exception is raised if <Index> doesn't respect Lower and Upper bounds of the internal array.
73 Standard_EXPORT void SetValue (const Standard_Integer Index, const TCollection_ExtendedString& Value);
5a1271c8 74
75 //! Sets the explicit GUID (user defined) for the attribute.
76 Standard_EXPORT void SetID( const Standard_GUID& theGuid) Standard_OVERRIDE;
77
78 //! Sets default GUID for the attribute.
79 Standard_EXPORT void SetID() Standard_OVERRIDE;
80
42cf5bc1 81 //! Returns the value of the <Index>th element of the array
82 Standard_EXPORT const TCollection_ExtendedString& Value (const Standard_Integer Index) const;
5a1271c8 83
84 const TCollection_ExtendedString& operator () (const Standard_Integer Index) const
85 {
86 return Value(Index);
87 }
42cf5bc1 88
89 //! Return the lower bound.
90 Standard_EXPORT Standard_Integer Lower() const;
91
92 //! Return the upper bound
93 Standard_EXPORT Standard_Integer Upper() const;
94
95 //! Return the number of elements of <me>.
96 Standard_EXPORT Standard_Integer Length() const;
97
98 //! Sets the inner array <myValue> of the ExtStringArray attribute to <newArray>.
99 //! If value of <newArray> differs from <myValue>, Backup performed and myValue
100 //! refers to new instance of HArray1OfExtendedString that holds <newArray> values
101 //! If <isCheckItems> equal True each item of <newArray> will be checked with each
102 //! item of <myValue> for coincidence (to avoid backup).
103 Standard_EXPORT void ChangeArray (const Handle(TColStd_HArray1OfExtendedString)& newArray, const Standard_Boolean isCheckItems = Standard_True);
7c1a9a46 104
42cf5bc1 105 //! Return the inner array of the ExtStringArray attribute
7c1a9a46 106 const Handle(TColStd_HArray1OfExtendedString)& Array() const { return myValue; }
107
108 Standard_Boolean GetDelta() const { return myIsDelta; }
109
42cf5bc1 110 //! for internal use only!
7c1a9a46 111 void SetDelta (const Standard_Boolean isDelta) { myIsDelta = isDelta; }
112
42cf5bc1 113 Standard_EXPORT TDataStd_ExtStringArray();
114
79104795 115 Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
42cf5bc1 116
79104795 117 Standard_EXPORT void Restore (const Handle(TDF_Attribute)& With) Standard_OVERRIDE;
42cf5bc1 118
79104795 119 Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
42cf5bc1 120
79104795 121 Standard_EXPORT void Paste (const Handle(TDF_Attribute)& Into, const Handle(TDF_RelocationTable)& RT) const Standard_OVERRIDE;
42cf5bc1 122
123 Standard_EXPORT virtual Standard_OStream& Dump (Standard_OStream& anOS) const Standard_OVERRIDE;
124
125 //! Makes a DeltaOnModification between <me> and
126 //! <anOldAttribute>.
127 Standard_EXPORT virtual Handle(TDF_DeltaOnModification) DeltaOnModification (const Handle(TDF_Attribute)& anOldAttribute) const Standard_OVERRIDE;
bc73b006 128
129 //! Dumps the content of me into the stream
130 Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
42cf5bc1 131
7c1a9a46 132private:
42cf5bc1 133
7c1a9a46 134 void RemoveArray() { myValue.Nullify(); }
42cf5bc1 135
136private:
137
42cf5bc1 138 Handle(TColStd_HArray1OfExtendedString) myValue;
139 Standard_Boolean myIsDelta;
5a1271c8 140 Standard_GUID myID;
42cf5bc1 141
42cf5bc1 142};
143
42cf5bc1 144#endif // _TDataStd_ExtStringArray_HeaderFile