1 // Copyright (c) 1992-1999 Matra Datavision
2 // Copyright (c) 1999-2012 OPEN CASCADE SAS
4 // The content of this file is subject to the Open CASCADE Technology Public
5 // License Version 6.5 (the "License"). You may not use the content of this file
6 // except in compliance with the License. Please obtain a copy of the License
7 // at http://www.opencascade.org and read it completely before using this file.
9 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 // The Original Code and all software distributed under the License is
13 // distributed on an "AS IS" basis, without warranty of any kind, and the
14 // Initial Developer hereby disclaims all such warranties, including without
15 // limitation, any warranties of merchantability, fitness for a particular
16 // purpose or non-infringement. Please see the License for the specific terms
17 // and conditions governing the rights and limitations under the License.
19 //Modified: C. LEYNADIER Nov,21 1997 (Token et ChangeString)
21 #include <TCollection_AsciiString.hxx>
22 #include <TCollection_HExtendedString.ixx>
23 #include <TCollection_HAsciiString.hxx>
24 #include <Standard_ExtCharacter.hxx>
25 #include <Standard_ExtString.hxx>
27 // ----------------------------------------------------------------------------
29 // ----------------------------------------------------------------------------
30 TCollection_HExtendedString::TCollection_HExtendedString(){}
33 // ----------------------------------------------------------------------------
35 // ----------------------------------------------------------------------------
36 TCollection_HExtendedString::TCollection_HExtendedString
37 (const Standard_CString message):myString(message)
40 // ----------------------------------------------------------------------------
42 // ----------------------------------------------------------------------------
43 TCollection_HExtendedString::TCollection_HExtendedString
44 (const Standard_ExtString message):myString(message)
47 // ----------------------------------------------------------------------------
49 // ----------------------------------------------------------------------------
50 TCollection_HExtendedString::TCollection_HExtendedString
51 (const Standard_ExtCharacter aChar):myString(aChar)
54 // ----------------------------------------------------------------------------
56 // ----------------------------------------------------------------------------
57 TCollection_HExtendedString::TCollection_HExtendedString
58 (const Standard_Integer length,const Standard_ExtCharacter filler )
59 :myString(length,filler)
62 // ----------------------------------------------------------------------------
64 // ----------------------------------------------------------------------------
65 TCollection_HExtendedString::TCollection_HExtendedString
66 (const TCollection_ExtendedString& astring):myString(astring)
69 // ----------------------------------------------------------------------------
71 // ----------------------------------------------------------------------------
72 TCollection_HExtendedString::TCollection_HExtendedString
73 (const Handle(TCollection_HAsciiString)& astring)
74 :myString(astring->String())
78 // ----------------------------------------------------------------------------
80 // ----------------------------------------------------------------------------
81 TCollection_HExtendedString::TCollection_HExtendedString
82 (const Handle(TCollection_HExtendedString)& astring)
83 :myString(astring->ChangeString())
87 // ---------------------------------------------------------------------------
89 // ----------------------------------------------------------------------------
90 void TCollection_HExtendedString::AssignCat
91 (const Handle(TCollection_HExtendedString)& other)
93 myString.AssignCat(other->ChangeString());
96 // ---------------------------------------------------------------------------
98 // ----------------------------------------------------------------------------
99 Handle(TCollection_HExtendedString) TCollection_HExtendedString::Cat
100 (const Handle(TCollection_HExtendedString)& other) const
102 return new TCollection_HExtendedString(myString.Cat(other->ChangeString() ) );
105 // ----------------------------------------------------------------------------
107 // ----------------------------------------------------------------------------
108 void TCollection_HExtendedString::ChangeAll
109 (const Standard_ExtCharacter aChar,
110 const Standard_ExtCharacter NewChar)
112 myString.ChangeAll(aChar,NewChar);
115 // ----------------------------------------------------------------------------
117 // ----------------------------------------------------------------------------
118 Standard_Boolean TCollection_HExtendedString::IsEmpty() const
120 return (myString.Length() == 0);
123 // ----------------------------------------------------------------------------
125 // ----------------------------------------------------------------------------
126 void TCollection_HExtendedString::Clear()
131 // ----------------------------------------------------------------------------
132 // Insert a Standard_ExtCharacter before 'where'th Standard_ExtCharacter
133 // ----------------------------------------------------------------------------
134 void TCollection_HExtendedString::Insert(const Standard_Integer where,
135 const Standard_ExtCharacter what)
137 myString.Insert(where,what);
140 // ----------------------------------------------------------------------------
142 // ----------------------------------------------------------------------------
143 void TCollection_HExtendedString::Insert(const Standard_Integer where,
144 const Handle(TCollection_HExtendedString)& what)
146 myString.Insert(where,what->ChangeString());
149 // ----------------------------------------------------------------------------
151 // ----------------------------------------------------------------------------
152 Standard_Boolean TCollection_HExtendedString::IsLess(
153 const Handle(TCollection_HExtendedString)& other) const
155 return myString.IsLess(other->ChangeString());
158 // ----------------------------------------------------------------------------
160 // ----------------------------------------------------------------------------
161 Standard_Boolean TCollection_HExtendedString::IsGreater
162 (const Handle(TCollection_HExtendedString)& other) const
164 return myString.IsGreater(other->ChangeString());
167 // ----------------------------------------------------------------------------
169 // ----------------------------------------------------------------------------
170 Standard_Boolean TCollection_HExtendedString::IsAscii() const
172 return myString.IsAscii();
175 // ----------------------------------------------------------------------------
177 // ----------------------------------------------------------------------------
178 Standard_Integer TCollection_HExtendedString::Length() const
180 return myString.Length();
183 // ----------------------------------------------------------------------------
185 // ----------------------------------------------------------------------------
186 void TCollection_HExtendedString::Remove (const Standard_Integer where,
187 const Standard_Integer ahowmany)
189 myString.Remove(where,ahowmany);
192 // ----------------------------------------------------------------------------
194 // ----------------------------------------------------------------------------
195 void TCollection_HExtendedString::RemoveAll(const Standard_ExtCharacter what)
197 myString.RemoveAll(what);
200 // ----------------------------------------------------------------------------
202 // ----------------------------------------------------------------------------
203 void TCollection_HExtendedString::SetValue(
204 const Standard_Integer where,const Standard_ExtCharacter what)
206 myString.SetValue(where,what);
209 // ----------------------------------------------------------------------------
211 // ---------------------------------------------------------------------------
212 void TCollection_HExtendedString::SetValue(const Standard_Integer where,
213 const Handle(TCollection_HExtendedString)& what)
215 myString.SetValue(where, what->ChangeString());
218 // ----------------------------------------------------------------------------
220 // ----------------------------------------------------------------------------
221 Handle(TCollection_HExtendedString) TCollection_HExtendedString::Split
222 (const Standard_Integer where)
224 return new TCollection_HExtendedString(myString.Split(where));
227 // ----------------------------------------------------------------------------
229 // ----------------------------------------------------------------------------
230 Standard_Integer TCollection_HExtendedString::Search
231 (const Handle(TCollection_HExtendedString)& what) const
233 return myString.Search(what->ChangeString());
236 // ----------------------------------------------------------------------------
238 // ----------------------------------------------------------------------------
239 Standard_Integer TCollection_HExtendedString::SearchFromEnd
240 (const Handle(TCollection_HExtendedString)& what) const
242 return myString.SearchFromEnd(what->ChangeString());
245 // ----------------------------------------------------------------------------
247 // ----------------------------------------------------------------------------
248 Handle(TCollection_HExtendedString) TCollection_HExtendedString::Token
249 (const Standard_ExtString separators,const Standard_Integer whichone) const
251 return new TCollection_HExtendedString(myString.Token(separators,whichone));
254 // ----------------------------------------------------------------------------
256 // ----------------------------------------------------------------------------
257 const Standard_ExtString TCollection_HExtendedString::ToExtString() const
259 return (myString.ToExtString());
262 // ----------------------------------------------------------------------------
264 // ----------------------------------------------------------------------------
265 void TCollection_HExtendedString::Trunc(const Standard_Integer ahowmany)
267 myString.Trunc(ahowmany);
270 // ----------------------------------------------------------------------------
272 // ----------------------------------------------------------------------------
273 Standard_ExtCharacter TCollection_HExtendedString::Value
274 (const Standard_Integer where) const
276 return myString.Value(where);
279 // ----------------------------------------------------------------------------
281 // ----------------------------------------------------------------------------
282 const TCollection_ExtendedString& TCollection_HExtendedString::String() const
288 //---------------------------------------------------------------------
290 //---------------------------------------------------------------------
291 void TCollection_HExtendedString::Print(Standard_OStream& S) const
293 S << "begin class HExtendedString "<<endl;
297 // ----------------------------------------------------------------------------
299 // ----------------------------------------------------------------------------
300 Handle(TCollection_HExtendedString) TCollection_HExtendedString::ShallowCopy() const
302 Handle(TCollection_HExtendedString) thecopy =
303 new TCollection_HExtendedString;
304 for (Standard_Integer i = 1 ; i <= Length() ; i++)
305 thecopy->Insert(i,Value(i));
309 //---------------------------------------------------------------------
311 //---------------------------------------------------------------------
312 void TCollection_HExtendedString::ShallowDump(Standard_OStream& S) const
314 S << "begin class HExtendedString "<<endl;
318 // ----------------------------------------------------------------------------
320 // ----------------------------------------------------------------------------
321 Standard_Boolean TCollection_HExtendedString::IsSameState
322 (const Handle(TCollection_HExtendedString)& other) const
324 Handle(TCollection_HExtendedString) H;
325 H = Handle(TCollection_HExtendedString)::DownCast(other);
326 return ( myString == H->ChangeString() );
330 TCollection_ExtendedString& TCollection_HExtendedString::ChangeString() const
332 return (TCollection_ExtendedString&)myString;