0024805: Eliminate unused static functions and methods: ShallowDump(), ShallowCopy...
[occt.git] / src / TCollection / TCollection_HAsciiString.cxx
CommitLineData
b311480e 1// Copyright (c) 1992-1999 Matra Datavision
973c2be1 2// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 3//
973c2be1 4// This file is part of Open CASCADE Technology software library.
b311480e 5//
d5f74e42 6// This library is free software; you can redistribute it and/or modify it under
7// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 8// by the Free Software Foundation, with special exception defined in the file
9// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10// distribution for complete text of the license and disclaimer of any warranty.
7fd59977 11//
973c2be1 12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
7fd59977 14
7fd59977 15#include <TCollection_HAsciiString.ixx>
16#include <TCollection_HExtendedString.hxx>
7fd59977 17
18// ----------------------------------------------------------------------------
19// Create
20// ----------------------------------------------------------------------------
21TCollection_HAsciiString::TCollection_HAsciiString():myString(){}
22
23
24// ----------------------------------------------------------------------------
25// Create
26// ----------------------------------------------------------------------------
27TCollection_HAsciiString::TCollection_HAsciiString
28 (const Standard_CString message):myString(message)
29{}
30
31// ----------------------------------------------------------------------------
32// Create
33// ----------------------------------------------------------------------------
34TCollection_HAsciiString::TCollection_HAsciiString
35 (const TCollection_AsciiString& astring):myString(astring)
36{}
37
38// ----------------------------------------------------------------------------
39// Create
40// ----------------------------------------------------------------------------
41TCollection_HAsciiString::TCollection_HAsciiString
42 (const Standard_Character aChar):myString(aChar)
43{}
44
45// ----------------------------------------------------------------------------
46// Create
47// ----------------------------------------------------------------------------
48TCollection_HAsciiString::TCollection_HAsciiString
49 (const Standard_Integer length,const Standard_Character filler ):myString(length,filler)
50{}
51
52// ----------------------------------------------------------------------------
53// Create
54// ----------------------------------------------------------------------------
55TCollection_HAsciiString::TCollection_HAsciiString
56 (const Standard_Integer aValue):myString(aValue)
57{}
58
59// ----------------------------------------------------------------------------
60// Create
61// ----------------------------------------------------------------------------
62TCollection_HAsciiString::TCollection_HAsciiString
63 (const Standard_Real aValue):myString(aValue)
64{}
65
66// ----------------------------------------------------------------------------
67// Create
68// ----------------------------------------------------------------------------
69TCollection_HAsciiString::TCollection_HAsciiString
70 (const Handle(TCollection_HAsciiString)& astring):myString(astring->String())
71{
72}
73
74// ----------------------------------------------------------------------------
75// Create
76// ----------------------------------------------------------------------------
77TCollection_HAsciiString::TCollection_HAsciiString
78 (const Handle(TCollection_HExtendedString)& astring,
79 const Standard_Character replaceNonAscii)
80: myString(astring->String(), replaceNonAscii)
81{
82}
83
84
85// ---------------------------------------------------------------------------
86// Capitalize
87// ----------------------------------------------------------------------------
88void TCollection_HAsciiString::Capitalize()
89{
90 myString.Capitalize();
91}
92
93// ---------------------------------------------------------------------------
94// Cat
95// ----------------------------------------------------------------------------
96Handle(TCollection_HAsciiString)
97 TCollection_HAsciiString::Cat(const Standard_CString other) const
98{
99 return new TCollection_HAsciiString(myString.Cat(other));
100}
101
102// ---------------------------------------------------------------------------
103// Cat
104// ----------------------------------------------------------------------------
105Handle(TCollection_HAsciiString)
106 TCollection_HAsciiString::Cat(const Handle(TCollection_HAsciiString)& other)
107const
108{
109 return new TCollection_HAsciiString(myString.Cat(other->String() ) );
110}
111
112// ---------------------------------------------------------------------------
113// Center
114// ----------------------------------------------------------------------------
115void TCollection_HAsciiString::Center
116 (const Standard_Integer Width ,
117 const Standard_Character Filler)
118{
119 if (Width < 0) Standard_NegativeValue::Raise();
120 myString.Center(Width,Filler);
121}
122
123// ----------------------------------------------------------------------------
124// ChangeAll
125// ----------------------------------------------------------------------------
126void TCollection_HAsciiString::ChangeAll
127 (const Standard_Character aChar,
128 const Standard_Character NewChar,
129 const Standard_Boolean CaseSensitive)
130{
131 myString.ChangeAll(aChar,NewChar,CaseSensitive);
132}
133
134// ----------------------------------------------------------------------------
135// Clear
136// ----------------------------------------------------------------------------
137void TCollection_HAsciiString::Clear()
138{
139 myString.Clear();
140}
141
142// ----------------------------------------------------------------------------
143// FirstLocationInSet
144// ----------------------------------------------------------------------------
145Standard_Integer TCollection_HAsciiString::FirstLocationInSet
146 (const Handle(TCollection_HAsciiString)& Set,
147 const Standard_Integer FromIndex,
148 const Standard_Integer ToIndex) const
149{
150 if (Length() == 0 || Set->Length() == 0) return 0;
151 if (ToIndex > Length() || FromIndex <= 0 || FromIndex > ToIndex )
152 Standard_OutOfRange::Raise();
153 return (myString.FirstLocationInSet(Set->String(),FromIndex,ToIndex));
154}
155
156// ----------------------------------------------------------------------------
157// FirstLocationNotInSet
158// ----------------------------------------------------------------------------
159Standard_Integer TCollection_HAsciiString::FirstLocationNotInSet
160 (const Handle(TCollection_HAsciiString)& Set,
161 const Standard_Integer FromIndex,
162 const Standard_Integer ToIndex) const
163{
164 if (Length() == 0 || Set->Length() == 0) return 0;
165 if (ToIndex > Length() || FromIndex <= 0 || FromIndex > ToIndex )
166 Standard_OutOfRange::Raise();
167 return (myString.FirstLocationNotInSet(Set->String(),FromIndex,ToIndex));
168}
169
170// ----------------------------------------------------------------------------
171// Insert a Standard_Character before 'where'th Standard_Character
172// ----------------------------------------------------------------------------
173void TCollection_HAsciiString::Insert(const Standard_Integer where,
174 const Standard_Character what)
175{
176 myString.Insert(where,what);
177}
178
179// ----------------------------------------------------------------------------
180// Insert
181// ----------------------------------------------------------------------------
182void TCollection_HAsciiString::Insert(const Standard_Integer where,
183 const Standard_CString what)
184{
185 myString.Insert(where,what);
186}
187
188// ----------------------------------------------------------------------------
189// Insert
190// ----------------------------------------------------------------------------
191void TCollection_HAsciiString::Insert(const Standard_Integer where,
192 const Handle(TCollection_HAsciiString)& what)
193{
194 myString.Insert(where,what->String());
195}
196
197//------------------------------------------------------------------------
198// InsertAfter
199//------------------------------------------------------------------------
200void TCollection_HAsciiString::InsertAfter
201 (const Standard_Integer Index, const Handle(TCollection_HAsciiString)& S)
202{
203 Standard_Integer size1 = Length();
204#ifndef NOBOUNDCHECK
205 if (Index < 0 || Index > size1) Standard_OutOfRange::Raise();
206#endif
207 myString.InsertAfter(Index,S->String());
208}
209
210//------------------------------------------------------------------------
211// InsertBefore
212//------------------------------------------------------------------------
213void TCollection_HAsciiString::InsertBefore
214 (const Standard_Integer Index, const Handle(TCollection_HAsciiString)& S)
215{
216 Standard_Integer size1 = Length();
217#ifndef NOBOUNDCHECK
218 if (Index < 1 || Index > size1) Standard_OutOfRange::Raise();
219#endif
220 myString.InsertBefore(Index,S->String());
221}
222
223// ----------------------------------------------------------------------------
224// IsEmpty
225// ----------------------------------------------------------------------------
226Standard_Boolean TCollection_HAsciiString::IsEmpty() const
227{
228 return (myString.Length() == 0);
229}
230
231// ----------------------------------------------------------------------------
232// IsLess
233// ----------------------------------------------------------------------------
234Standard_Boolean
235TCollection_HAsciiString::IsLess(const Handle(TCollection_HAsciiString)& other) const
236{
237 return myString.IsLess(other->String());
238}
239
240// ----------------------------------------------------------------------------
241// IsGreater
242// ----------------------------------------------------------------------------
243Standard_Boolean
244TCollection_HAsciiString::IsGreater(const Handle(TCollection_HAsciiString)& other) const
245{
246 return myString.IsGreater(other->String());
247}
248
249// ----------------------------------------------------------------------------
250// IntegerValue
251// ----------------------------------------------------------------------------
252Standard_Integer TCollection_HAsciiString::IntegerValue() const
253{
254 return myString.IntegerValue();
255}
256
257// ----------------------------------------------------------------------------
258// IsIntegerValue
259// ----------------------------------------------------------------------------
260Standard_Boolean TCollection_HAsciiString::IsIntegerValue() const
261{
262 return myString.IsIntegerValue();
263}
264
265
266// ----------------------------------------------------------------------------
267// IsRealvalue
268// ----------------------------------------------------------------------------
269Standard_Boolean TCollection_HAsciiString::IsRealValue() const
270{
271 return myString.IsRealValue();
272}
273
274// ----------------------------------------------------------------------------
275// IsAscii
276// ----------------------------------------------------------------------------
277Standard_Boolean TCollection_HAsciiString::IsAscii() const
278{
279 return myString.IsAscii();
280}
281
282// ----------------------------------------------------------------------------
283// IsDifferent
284// ----------------------------------------------------------------------------
285Standard_Boolean TCollection_HAsciiString::IsDifferent
286 (const Handle(TCollection_HAsciiString)& S) const
287{
7fd59977 288 if(S.IsNull()) Standard_NullObject::Raise("TCollection_HAsciiString::IsDifferent");
29cb310a 289 if(S->Length() != myString.Length() ) return Standard_True;
290 return ( strncmp( myString.ToCString(), S->ToCString(), myString.Length() ) != 0 );
7fd59977 291}
292
293// ----------------------------------------------------------------------------
294// IsSameString
295// ----------------------------------------------------------------------------
296Standard_Boolean TCollection_HAsciiString::IsSameString
297 (const Handle(TCollection_HAsciiString)& S) const
298{
7fd59977 299 if(S.IsNull()) Standard_NullObject::Raise("TCollection_HAsciiString::IsSameString");
29cb310a 300 if ( myString.Length() == S->Length() )
301 return ( strncmp( myString.ToCString(), S->ToCString(), myString.Length() ) == 0 );
7fd59977 302 else
303 return Standard_False ;
7fd59977 304}
305
306// ----------------------------------------------------------------------------
307// IsSameString
308// ----------------------------------------------------------------------------
309Standard_Boolean TCollection_HAsciiString::IsSameString
310 (const Handle(TCollection_HAsciiString)& S ,
311 const Standard_Boolean CaseSensitive) const
312{
7fd59977 313 if(S.IsNull()) Standard_NullObject::Raise("TCollection_HAsciiString::IsSameString");
314
29cb310a 315 const Standard_Integer size1 = Length();
7fd59977 316 if ( size1 != S->Length() ) return Standard_False;
7fd59977 317 if ( CaseSensitive ) {
29cb310a 318 return ( strncmp( myString.ToCString(), S->ToCString(), size1 ) == 0 );
7fd59977 319 }
320 else {
321 for ( Standard_Integer i = 1 ; i <= size1; i++) {
322 if ( toupper( Value(i) ) != toupper( S->Value(i) ) )
323 return Standard_False;
324 }
325 return Standard_True ;
326 }
7fd59977 327}
328
329//------------------------------------------------------------------------
330// LeftAdjust
331//------------------------------------------------------------------------
332void TCollection_HAsciiString::LeftAdjust ()
333{
334 myString.LeftAdjust();
335}
336
337//------------------------------------------------------------------------
338// LeftJustify
339//------------------------------------------------------------------------
340void TCollection_HAsciiString::LeftJustify
341 (const Standard_Integer Width, const Standard_Character Filler)
342{
343 if (Width < 0) Standard_NegativeValue::Raise();
344 myString.LeftJustify(Width,Filler);
345}
346
347//------------------------------------------------------------------------
348// Location
349//------------------------------------------------------------------------
350Standard_Integer TCollection_HAsciiString::Location
351 (const Standard_Integer N, const Standard_Character C,
352 const Standard_Integer FromIndex, const Standard_Integer ToIndex) const
353{
354 if (ToIndex > Length() || FromIndex <= 0 || FromIndex > ToIndex )
355 Standard_OutOfRange::Raise();
356 return myString.Location(N,C,FromIndex,ToIndex);
357}
358
359//------------------------------------------------------------------------
360// Location
361//------------------------------------------------------------------------
362Standard_Integer TCollection_HAsciiString::Location
363 (const Handle(TCollection_HAsciiString)& S, const Standard_Integer FromIndex,
364 const Standard_Integer ToIndex) const
365{
366 if (Length() == 0 || S->Length() == 0) return 0;
367 if (ToIndex > Length() || FromIndex <= 0 || FromIndex > ToIndex )
368 Standard_OutOfRange::Raise();
369 return myString.Location(S->String(),FromIndex,ToIndex);
370}
371
372// ----------------------------------------------------------------------------
373// LowerCase
374// ----------------------------------------------------------------------------
375void TCollection_HAsciiString::LowerCase()
376{
377 myString.LowerCase();
378}
379
380//------------------------------------------------------------------------
381// Prepend
382//------------------------------------------------------------------------
383void TCollection_HAsciiString::Prepend
384 (const Handle(TCollection_HAsciiString)& S)
385{
386 myString.Prepend(S->String());
387}
388
389//---------------------------------------------------------------------
390// Print
391//---------------------------------------------------------------------
392void TCollection_HAsciiString::Print(Standard_OStream& S) const
393{
394 myString.Print(S);
395}
396
397// ----------------------------------------------------------------------------
398// RealValue
399// ----------------------------------------------------------------------------
400Standard_Real TCollection_HAsciiString::RealValue() const
401{
402 return myString.RealValue();
403}
404
405// ----------------------------------------------------------------------------
406// RemoveAll
407// ----------------------------------------------------------------------------
408void TCollection_HAsciiString::RemoveAll
409 (const Standard_Character what,
410 const Standard_Boolean CaseSensitive)
411{
412 myString.RemoveAll(what,CaseSensitive);
413}
414
415// ----------------------------------------------------------------------------
416// RemoveAll
417// ----------------------------------------------------------------------------
418void TCollection_HAsciiString::RemoveAll(const Standard_Character what)
419{
420 myString.RemoveAll(what);
421}
422
423// ----------------------------------------------------------------------------
424// Remove
425// ----------------------------------------------------------------------------
426void TCollection_HAsciiString::Remove (const Standard_Integer where,
427 const Standard_Integer ahowmany)
428{
429 myString.Remove(where,ahowmany);
430}
431
432//------------------------------------------------------------------------
433// RightAdjust
434//------------------------------------------------------------------------
435void TCollection_HAsciiString::RightAdjust ()
436{
437 myString.RightAdjust();
438}
439
440//------------------------------------------------------------------------
441// RightJustify
442//------------------------------------------------------------------------
443void TCollection_HAsciiString::RightJustify
444 (const Standard_Integer Width, const Standard_Character Filler)
445{
446 if (Width < 0) Standard_NegativeValue::Raise();
447 myString.RightJustify(Width,Filler);
448}
449
450// ----------------------------------------------------------------------------
451// Search
452// ----------------------------------------------------------------------------
453Standard_Integer TCollection_HAsciiString::Search(const Standard_CString what)const
454{
455 return myString.Search(what);
456}
457
458// ----------------------------------------------------------------------------
459// Search
460// ----------------------------------------------------------------------------
461Standard_Integer TCollection_HAsciiString::Search
462 (const Handle(TCollection_HAsciiString)& what) const
463{
464 return myString.Search(what->String());
465}
466
467// ----------------------------------------------------------------------------
468// SearchFromEnd
469// ----------------------------------------------------------------------------
470Standard_Integer TCollection_HAsciiString::SearchFromEnd(const Standard_CString what)const
471{
472 return myString.SearchFromEnd(what);
473}
474
475// ----------------------------------------------------------------------------
476// SearchFromEnd
477// ----------------------------------------------------------------------------
478Standard_Integer TCollection_HAsciiString::SearchFromEnd
479 (const Handle(TCollection_HAsciiString)& what) const
480{
481 return myString.SearchFromEnd(what->String());
482}
483
484// ----------------------------------------------------------------------------
485// SetValue
486// ----------------------------------------------------------------------------
487void TCollection_HAsciiString::SetValue(const Standard_Integer where,
488 const Standard_Character what)
489{
490 myString.SetValue(where,what);
491}
492
493// ----------------------------------------------------------------------------
494// SetValue
495// ----------------------------------------------------------------------------
496void TCollection_HAsciiString::SetValue(const Standard_Integer where,const Standard_CString what)
497{
498 myString.SetValue(where,what);
499}
500
501// ----------------------------------------------------------------------------
502// SetValue
503// ---------------------------------------------------------------------------
504void TCollection_HAsciiString::SetValue(const Standard_Integer where,
505 const Handle(TCollection_HAsciiString)& what)
506{
507 myString.SetValue(where, what->String());
508}
509
510// ----------------------------------------------------------------------------
511// Split
512// ----------------------------------------------------------------------------
513Handle(TCollection_HAsciiString)
514 TCollection_HAsciiString::Split(const Standard_Integer where)
515{
516 return new TCollection_HAsciiString(myString.Split(where));
517}
518
519// ----------------------------------------------------------------------------
520// SubString
521// ----------------------------------------------------------------------------
522Handle(TCollection_HAsciiString)
523 TCollection_HAsciiString::SubString(const Standard_Integer FromIndex,
524 const Standard_Integer ToIndex) const
525{
526 return new TCollection_HAsciiString(myString.SubString(FromIndex,ToIndex));
527}
528
529
530// ----------------------------------------------------------------------------
531// Token
532// ----------------------------------------------------------------------------
533Handle(TCollection_HAsciiString) TCollection_HAsciiString::Token
534 (const Standard_CString separators,const Standard_Integer whichone) const
535{
536 return new TCollection_HAsciiString(myString.Token(separators,whichone));
537}
538
539// ----------------------------------------------------------------------------
540// Trunc
541// ----------------------------------------------------------------------------
542void TCollection_HAsciiString::Trunc(const Standard_Integer ahowmany)
543{
544 myString.Trunc(ahowmany);
545}
546
547// ----------------------------------------------------------------------------
548// UpperCase
549// ----------------------------------------------------------------------------
550void TCollection_HAsciiString::UpperCase()
551{
552 myString.UpperCase();
553}
554
555// ----------------------------------------------------------------------------
556// UsefullLength
557// ----------------------------------------------------------------------------
558Standard_Integer TCollection_HAsciiString::UsefullLength() const
559{
560 return myString.UsefullLength();
561}
562
563// ----------------------------------------------------------------------------
564// Value
565// ----------------------------------------------------------------------------
566Standard_Character TCollection_HAsciiString::Value(const Standard_Integer where) const
567{
568 return myString.Value(where);
569}
570
7fd59977 571// ----------------------------------------------------------------------------
572// IsSameState
573// ----------------------------------------------------------------------------
574Standard_Boolean TCollection_HAsciiString::IsSameState
575 (const Handle(TCollection_HAsciiString)& other) const
29cb310a 576{
577 if ( myString.Length() == other->Length() )
578 return ( strncmp( myString.mystring, other->ToCString(), myString.Length() ) == 0 );
7fd59977 579 else
580 return Standard_False ;
29cb310a 581}
7fd59977 582