Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-02 09:14:13

0001 // Created on: 2002-01-16
0002 // Created by: Michael PONIKAROV
0003 // Copyright (c) 2002-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef _TDataStd_ExtStringArray_HeaderFile
0017 #define _TDataStd_ExtStringArray_HeaderFile
0018 
0019 #include <Standard.hxx>
0020 
0021 #include <TCollection_ExtendedString.hxx>
0022 #include <NCollection_Array1.hxx>
0023 #include <NCollection_HArray1.hxx>
0024 #include <TDF_Attribute.hxx>
0025 #include <Standard_Integer.hxx>
0026 #include <Standard_OStream.hxx>
0027 #include <Standard_GUID.hxx>
0028 
0029 class TDF_Label;
0030 class TCollection_ExtendedString;
0031 class TDF_RelocationTable;
0032 class TDF_DeltaOnModification;
0033 
0034 //! ExtStringArray Attribute. Handles an array of UNICODE strings (represented by the
0035 //! TCollection_ExtendedString class).
0036 class TDataStd_ExtStringArray : public TDF_Attribute
0037 {
0038   friend class TDataStd_DeltaOnModificationOfExtStringArray;
0039   DEFINE_STANDARD_RTTIEXT(TDataStd_ExtStringArray, TDF_Attribute)
0040 public:
0041   //! class methods
0042   //! =============
0043   //! Returns the GUID for the attribute.
0044   Standard_EXPORT static const Standard_GUID& GetID();
0045 
0046   //! Finds, or creates, an ExtStringArray attribute with <lower>
0047   //! and <upper> bounds on the specified label.
0048   //! If <isDelta> == False, DefaultDeltaOnModification is used.
0049   //! If <isDelta> == True, DeltaOnModification of the current attribute is used.
0050   //! If attribute is already set, all input parameters are refused and the found
0051   //! attribute is returned.
0052   Standard_EXPORT static occ::handle<TDataStd_ExtStringArray> Set(const TDF_Label& label,
0053                                                                   const int        lower,
0054                                                                   const int        upper,
0055                                                                   const bool       isDelta = false);
0056 
0057   //! Finds, or creates, an ExtStringArray attribute with explicit user defined <guid>.
0058   //! The ExtStringArray attribute is returned.
0059   Standard_EXPORT static occ::handle<TDataStd_ExtStringArray> Set(const TDF_Label&     label,
0060                                                                   const Standard_GUID& theGuid,
0061                                                                   const int            lower,
0062                                                                   const int            upper,
0063                                                                   const bool isDelta = false);
0064 
0065   //! Initializes the inner array with bounds from <lower> to <upper>
0066   Standard_EXPORT void Init(const int lower, const int upper);
0067 
0068   //! Sets the <Index>th element of the array to <Value>
0069   //! OutOfRange exception is raised if <Index> doesn't respect Lower and Upper bounds of the
0070   //! internal array.
0071   Standard_EXPORT void SetValue(const int Index, const TCollection_ExtendedString& Value);
0072 
0073   //! Sets the explicit GUID (user defined) for the attribute.
0074   Standard_EXPORT void SetID(const Standard_GUID& theGuid) override;
0075 
0076   //! Sets default GUID for the attribute.
0077   Standard_EXPORT void SetID() override;
0078 
0079   //! Returns the value of the <Index>th element of the array
0080   Standard_EXPORT const TCollection_ExtendedString& Value(const int Index) const;
0081 
0082   const TCollection_ExtendedString& operator()(const int Index) const { return Value(Index); }
0083 
0084   //! Return the lower bound.
0085   Standard_EXPORT int Lower() const;
0086 
0087   //! Return the upper bound
0088   Standard_EXPORT int Upper() const;
0089 
0090   //! Return the number of elements of <me>.
0091   Standard_EXPORT int Length() const;
0092 
0093   //! Sets the inner array <myValue> of the ExtStringArray attribute to <newArray>.
0094   //! If value of <newArray> differs from <myValue>, Backup performed and myValue
0095   //! refers to new instance of HArray1OfExtendedString that holds <newArray> values
0096   //! If <isCheckItems> equal True each item of <newArray> will be checked with each
0097   //! item of <myValue> for coincidence (to avoid backup).
0098   Standard_EXPORT void ChangeArray(
0099     const occ::handle<NCollection_HArray1<TCollection_ExtendedString>>& newArray,
0100     const bool                                                          isCheckItems = true);
0101 
0102   //! Return the inner array of the ExtStringArray attribute
0103   const occ::handle<NCollection_HArray1<TCollection_ExtendedString>>& Array() const
0104   {
0105     return myValue;
0106   }
0107 
0108   bool GetDelta() const { return myIsDelta; }
0109 
0110   //! for internal use only!
0111   void SetDelta(const bool isDelta) { myIsDelta = isDelta; }
0112 
0113   Standard_EXPORT TDataStd_ExtStringArray();
0114 
0115   Standard_EXPORT const Standard_GUID& ID() const override;
0116 
0117   Standard_EXPORT void Restore(const occ::handle<TDF_Attribute>& With) override;
0118 
0119   Standard_EXPORT occ::handle<TDF_Attribute> NewEmpty() const override;
0120 
0121   Standard_EXPORT void Paste(const occ::handle<TDF_Attribute>&       Into,
0122                              const occ::handle<TDF_RelocationTable>& RT) const override;
0123 
0124   Standard_EXPORT Standard_OStream& Dump(Standard_OStream& anOS) const override;
0125 
0126   //! Makes a DeltaOnModification between <me> and
0127   //! <anOldAttribute>.
0128   Standard_EXPORT occ::handle<TDF_DeltaOnModification> DeltaOnModification(
0129     const occ::handle<TDF_Attribute>& anOldAttribute) const override;
0130 
0131   //! Dumps the content of me into the stream
0132   Standard_EXPORT void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const override;
0133 
0134 private:
0135   void RemoveArray() { myValue.Nullify(); }
0136 
0137 private:
0138   occ::handle<NCollection_HArray1<TCollection_ExtendedString>> myValue;
0139   bool                                                         myIsDelta;
0140   Standard_GUID                                                myID;
0141 };
0142 
0143 #endif // _TDataStd_ExtStringArray_HeaderFile