0024186: Eliminate remaining compiler warnings in MSVC++ 2010 64 bit with warning...
[occt.git] / src / PCollection / PCollection_HAsciiString.cxx
CommitLineData
b311480e 1// Copyright (c) 1998-1999 Matra Datavision
2// Copyright (c) 1999-2012 OPEN CASCADE SAS
3//
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.
8//
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.
11//
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.
18
7fd59977 19
20#include <PCollection_HAsciiString.ixx>
21#include <PCollection_HExtendedString.hxx>
22#include <TCollection_HAsciiString.hxx>
23#include <Standard_NumericError.hxx>
24#include <Standard_NegativeValue.hxx>
25#include <Standard_OutOfRange.hxx>
26
27#ifdef HAVE_CONFIG_H
28# include <config.h>
29#endif
30#if defined(HAVE_STRING_H)
31# include <string.h>
32#endif
33#include <stdio.h>
34#if defined(HAVE_STDLIB_H)
35# include <stdlib.h>
36#endif
37#if defined(HAVE_LIBC_H)
38# include <libc.h>
39#endif
40
41//------------------------------------
42// Conversion functions and variables
43//------------------------------------
44
45#define MAXLENGTH 80
46static char cnvbuf[MAXLENGTH];
47static Standard_Integer cnvint;
48static Standard_Real cnvreal;
49
50//-----------------------------------------------------------------------
51// intstr
52//-----------------------------------------------------------------------
53static int intstr(Standard_Integer V,Standard_CString F)
54{
55 sprintf(cnvbuf,F,V);
7dc9e047 56 return (int)strlen(cnvbuf);
7fd59977 57}
58
59//-----------------------------------------------------------------------
60// realstr
61//----------------------------------------------------------------------
62static int realstr(Standard_Real V, Standard_CString F)
63{
64 sprintf(cnvbuf,F,V);
7dc9e047 65 return (int)strlen(cnvbuf);
7fd59977 66}
67
68//-----------------------------------------------------------------------
69// Create : from a CString
70//-----------------------------------------------------------------------
71PCollection_HAsciiString::PCollection_HAsciiString(const Standard_CString S)
60be1f9b 72 : Data((Standard_Integer) strlen(S))
7fd59977 73{
74 for( Standard_Integer i = 0 ; i < Data.Length() ; i++)
75 Data.SetValue(i, S[i]) ;
76}
77
78//------------------------------------------------------------------------
79// Create from an AsciiString of TCollection
80//------------------------------------------------------------------------
81PCollection_HAsciiString::PCollection_HAsciiString
82 (const TCollection_AsciiString& S):Data(S.Length())
83{
84 for( Standard_Integer i = 1; i <= Data.Length() ; i++)
85 Data.SetValue(i-1, S.Value(i)) ;
86}
87
88//------------------------------------------------------------------------
89// Create from a Character
90//------------------------------------------------------------------------
91PCollection_HAsciiString::PCollection_HAsciiString(const Standard_Character C)
92 : Data(1)
93{
94 Data.SetValue(0, C);
95}
96
97//------------------------------------------------------------------------
98// Create from a range of an HAsciiString of PCollection
99//------------------------------------------------------------------------
100PCollection_HAsciiString::PCollection_HAsciiString
101 (const Handle(PCollection_HAsciiString)& S,
102 const Standard_Integer FromIndex, const Standard_Integer ToIndex) : Data(ToIndex-FromIndex+1)
103{
104 for( Standard_Integer i = 0 , k = FromIndex; i < Data.Length() ; i++, k++)
105 Data.SetValue(i, S->Value(k));
106}
107
108//------------------------------------------------------------------------
109// Create from an HExtendedString from PCollection
110//------------------------------------------------------------------------
111PCollection_HAsciiString::PCollection_HAsciiString
112 (const Handle(PCollection_HExtendedString)& S) : Data(S->Length())
113{
114 if (!S->IsAscii()) Standard_OutOfRange::Raise();
115 for( Standard_Integer i = 1; i <= Data.Length() ; i++) {
116// convert the character i of S
117 Standard_Character val = ToCharacter(S->Value(i)) ;
118 Data.SetValue(i-1,val ) ;
119 }
120}
121
122//------------------------------------------------------------------------
123// Create from a Real by converting it
124//------------------------------------------------------------------------
125PCollection_HAsciiString::PCollection_HAsciiString
126 (const Standard_Real R , const Standard_CString F) : Data(realstr(R,F))
127{
128 for( Standard_Integer i =0 ; i < Data.Length() ; i++)
129 Data.SetValue(i,cnvbuf[i] );
130}
131
132//------------------------------------------------------------------------
133// Create from an Integer by converting it
134//------------------------------------------------------------------------
135PCollection_HAsciiString::PCollection_HAsciiString
136 (const Standard_Integer I, const Standard_CString F) : Data(intstr(I,F))
137{
138 for( Standard_Integer i = 0 ; i < Data.Length() ; i++)
139 Data.SetValue(i,cnvbuf[i]) ;
140}
141
142
143//------------------------------------------------------------------------
144// Append
145//------------------------------------------------------------------------
146void PCollection_HAsciiString::Append
147 (const Handle(PCollection_HAsciiString)& S)
148{
149 InsertAfter(Length(),S);
150}
151
152//------------------------------------------------------------------------
153// Capitalize
154//------------------------------------------------------------------------
155void PCollection_HAsciiString::Capitalize ()
156{
157 for (Standard_Integer i = 0 ; i < Length() ; i++) {
158 if( i == 0) Data.SetValue(i, UpperCase(Data(i)) );
159 else Data.SetValue(i, LowerCase(Data(i)) );
160 }
161}
162
163//------------------------------------------------------------------------
164// Center
165//------------------------------------------------------------------------
166void PCollection_HAsciiString::Center
167 (const Standard_Integer Width, const Standard_Character Filler)
168{
169 if (Width < 0) Standard_NegativeValue::Raise();
170 Standard_Integer size1 = Length();
171 if(Width > size1) {
172 Standard_Integer size2 = size1 + ((Width - size1)/2);
173 LeftJustify(size2,Filler);
174 RightJustify(Width,Filler);
175 }
176}
177
178//------------------------------------------------------------------------
179// ChangeAll
180//------------------------------------------------------------------------
181void PCollection_HAsciiString::ChangeAll
182 (const Standard_Character C, const Standard_Character NewC, const Standard_Boolean CaseSensitive)
183{
184 for( Standard_Integer i = 0 ; i < Data.Length(); i++) {
185 if (CaseSensitive) {
186 if(Data(i) == C) Data.SetValue(i, NewC);
187 }
188 else {
189 if(UpperCase(Data(i)) == UpperCase(C)) Data.SetValue(i, NewC);
190 }
191 }
192}
193
194//------------------------------------------------------------------------
195// Clear
196//------------------------------------------------------------------------
197void PCollection_HAsciiString::Clear ()
198{
199 Data.Resize(0);
200}
201
202//------------------------------------------------------------------------
203// Convert
204//------------------------------------------------------------------------
205TCollection_AsciiString PCollection_HAsciiString::Convert() const
206{
207 Standard_Integer L = Length();
208 TCollection_AsciiString TString (L,' ');
209 for (Standard_Integer i = 1 ; i <= L ; i++) {
210 TString.SetValue(i,Value(i));
211 }
212 return TString;
213}
214
215//------------------------------------------------------------------------
216// FirstLocationInSet
217//------------------------------------------------------------------------
218Standard_Integer PCollection_HAsciiString::FirstLocationInSet
219 (const Handle(PCollection_HAsciiString)& Set,
220 const Standard_Integer FromIndex,
221 const Standard_Integer ToIndex) const
222{
223 if (Length() == 0 || Set->Length() == 0) return 0;
224 if (ToIndex > Length() || FromIndex <= 0 || FromIndex > ToIndex )
225 Standard_OutOfRange::Raise();
226 for(Standard_Integer i = FromIndex-1 ; i <= ToIndex-1; i++)
227 for(Standard_Integer j = 1; j <= Set->Length(); j++)
228 if(Data(i) == Set->Value(j)) return (i+1);
229 return 0;
230}
231
232//------------------------------------------------------------------------
233// FirstLocationNotInset
234//------------------------------------------------------------------------
235Standard_Integer PCollection_HAsciiString::FirstLocationNotInSet
236 (const Handle(PCollection_HAsciiString)& Set, const Standard_Integer FromIndex,
237 const Standard_Integer ToIndex) const
238{
239 if (Length() == 0 || Set->Length() == 0) return 0;
240 if (ToIndex > Length() || FromIndex <= 0 || FromIndex > ToIndex )
241 Standard_OutOfRange::Raise();
242 Standard_Boolean find;
243 for(Standard_Integer i = FromIndex-1 ; i <= ToIndex-1; i++) {
244 find = Standard_False;
245 for(Standard_Integer j = 1; j <= Set->Length(); j++) {
246 if (Data(i) == Set->Value(j)) find = Standard_True;
247 }
248 if (!find) return (i+1);
249 }
250 return 0;
251}
252
253//------------------------------------------------------------------------
254// InsertAfter
255//------------------------------------------------------------------------
256void PCollection_HAsciiString::InsertAfter
257 (const Standard_Integer Index, const Handle(PCollection_HAsciiString)& S)
258{
259 Standard_Integer i ;
260 Standard_Integer size1 = Length();
261 Standard_Integer size2 = S->Length();
262#ifndef NOBOUNDCHECK
263 if (Index < 0 || Index > size1) Standard_OutOfRange::Raise();
264#endif
265 Data.Resize(size1+size2);
266 for( i = size1-1 ; i >= Index; i--) Data.SetValue(size2+i,Data(i));
267 for( i = 1 ; i <= size2; i++) Data.SetValue(Index+i-1,S->Value(i));
268}
269
270//------------------------------------------------------------------------
271// InsertBefore
272//------------------------------------------------------------------------
273void PCollection_HAsciiString::InsertBefore
274 (const Standard_Integer Index, const Handle(PCollection_HAsciiString)& S)
275{
276 Standard_Integer i ;
277 Standard_Integer size1 = Length();
278 Standard_Integer size2 = S->Length();
279#ifndef NOBOUNDCHECK
280 if (Index < 0 || Index > size1) Standard_OutOfRange::Raise();
281#endif
282 Data.Resize(size1+size2);
283 for( i = size1-1 ; i >= Index-1 ; i--)
284 Data.SetValue(size2+i,Data(i));
285 for( i = 1 ; i <= size2; i++) Data.SetValue(Index+i-2, S->Value(i));
286}
287
288//------------------------------------------------------------------------
289// IntegerValue
290//------------------------------------------------------------------------
291Standard_Integer PCollection_HAsciiString::IntegerValue () const
292{
293 if (!IsIntegerValue()) Standard_NumericError::Raise();
294 return cnvint;
295}
296
297//------------------------------------------------------------------------
298// IsDifferent
299//------------------------------------------------------------------------
300Standard_Boolean PCollection_HAsciiString::IsDifferent
301 (const Handle(PCollection_HAsciiString)& S) const
302{
303 Standard_Integer size = Length();
304 if( size != S->Length()) return Standard_True;
305 Standard_Integer i = 1 ;
306 Standard_Boolean different = Standard_False;
307 while (i <= size && !different) {
308 if (Data(i-1) != S->Value(i)) different = Standard_True;
309 i++;
310 }
311 return different;
312}
313
314//------------------------------------------------------------------------
315// IsEmpty
316//------------------------------------------------------------------------
317Standard_Boolean PCollection_HAsciiString::IsEmpty () const
318{
319 return (Data.Length() == 0);
320}
321
322//------------------------------------------------------------------------
323// IsGreater
324//------------------------------------------------------------------------
325Standard_Boolean PCollection_HAsciiString::IsGreater
326 (const Handle(PCollection_HAsciiString)& S) const
327{
328 TCollection_AsciiString TMe = Convert();
329 TCollection_AsciiString TS = S->Convert();
330 return TMe.IsGreater(TS);
331}
332
333//------------------------------------------------------------------------
334// IsIntegervalue
335//------------------------------------------------------------------------
336Standard_Boolean PCollection_HAsciiString::IsIntegerValue () const
337{
338 Standard_Integer i ;
339#if defined(__osf__) || defined(DECOSF1)
340#ifdef OBJS
341 #pragma pointer_size (save)
342 #pragma pointer_size (long)
343 char *ptr;
344 #pragma pointer_size (restore)
345#else
346 char *ptr;
347#endif
348#else
349 char *ptr;
350#endif
351#ifndef NOBOUNDCHECK
352 if ( Data.Length() > MAXLENGTH ) return Standard_False;
353#endif
354 Handle(TCollection_HAsciiString) astring;
355 astring = new TCollection_HAsciiString (this->Convert());
356 astring->LeftAdjust();
357 astring->RightAdjust();
358 for(i = 0; i < astring->Length(); i++)
359 cnvbuf[i] = astring->Value(i+1);
360 cnvbuf[i] = 0;
361 cnvint = strtol(cnvbuf,&ptr,10);
362 if (ptr < cnvbuf+astring->Length()) return Standard_False;
363 else return Standard_True;
364}
365
366//------------------------------------------------------------------------
367// Isless
368//------------------------------------------------------------------------
369Standard_Boolean PCollection_HAsciiString::IsLess
370 (const Handle(PCollection_HAsciiString)& S) const
371{
372 TCollection_AsciiString TMe = Convert();
373 TCollection_AsciiString TS = S->Convert();
374 return TMe.IsLess(TS);
375}
376
377//------------------------------------------------------------------------
378// IsRealValue
379//------------------------------------------------------------------------
380Standard_Boolean PCollection_HAsciiString::IsRealValue () const
381{
382 Standard_Integer i ;
383#if defined(__osf__) || defined(DECOSF1)
384#ifdef OBJS
385 #pragma pointer_size (save)
386 #pragma pointer_size (long)
387 char *ptr;
388 #pragma pointer_size (restore)
389#else
390 char *ptr;
391#endif
392#else
393 char *ptr;
394#endif
395#ifndef NOBOUNDCHECK
396 if ( Data.Length() > MAXLENGTH ) return Standard_False;
397#endif
398 Handle(TCollection_HAsciiString) astring;
399 astring = new TCollection_HAsciiString (this->Convert());
400 astring->LeftAdjust();
401 astring->RightAdjust();
402 for(i = 0; i < astring->Length(); i++)
403 cnvbuf[i] = astring->Value(i+1);
404 cnvbuf[i] = 0;
91322f44 405 cnvreal = Strtod(cnvbuf,&ptr);
7fd59977 406 if (ptr < cnvbuf+astring->Length()) return Standard_False;
407 else return Standard_True;
408}
409
410//------------------------------------------------------------------------
411// IsSameString
412//------------------------------------------------------------------------
413Standard_Boolean PCollection_HAsciiString::IsSameString
414 (const Handle(PCollection_HAsciiString)& S) const
415{
416 Standard_Integer i ;
417 Standard_Integer size1 = Length();
418 if( size1 != S->Length()) return Standard_False;
419 for( i = 1 ; i <= size1; i++) {
420 if(Data(i-1) != S->Value(i)) return Standard_False;
421 }
422 return Standard_True;
423}
424
425//------------------------------------------------------------------------
426// IsSameString
427//------------------------------------------------------------------------
428Standard_Boolean PCollection_HAsciiString::IsSameString
429 (const Handle(PCollection_HAsciiString)& S, const Standard_Boolean CaseSensitive) const
430{
431 Standard_Integer size1 = Length();
432 if( size1 != S->Length()) return Standard_False;
433 for( Standard_Integer i = 1 ; i <= size1; i++) {
434 if(CaseSensitive){
435 if(Data(i-1) != S->Value(i)) return Standard_False;
436 }
437 else {
438 if(UpperCase(Data(i-1)) != UpperCase(S->Value(i))) return Standard_False;
439 }
440 }
441 return Standard_True;
442}
443
444//------------------------------------------------------------------------
445// LeftAdjust
446//------------------------------------------------------------------------
447void PCollection_HAsciiString::LeftAdjust ()
448{
449 Standard_Integer i ;
450 for(i = 0 ; i < Data.Length() ; i ++) if(!IsSpace(Data(i))) break;
451 if( i > 0 ) Remove(1,i);
452}
453
454//------------------------------------------------------------------------
455// LeftJustify
456//------------------------------------------------------------------------
457void PCollection_HAsciiString::LeftJustify
458 (const Standard_Integer Width, const Standard_Character Filler)
459{
460 if (Width < 0) Standard_NegativeValue::Raise();
461 Standard_Integer size1 = Length();
462 if(Width > size1) {
463 Data.Resize(Width);
464 for(Standard_Integer i = size1; i < Width ; i++) Data.SetValue(i, Filler);
465 }
466}
467
468//------------------------------------------------------------------------
469// Length
470//------------------------------------------------------------------------
471Standard_Integer PCollection_HAsciiString::Length () const
472{
473 return Data.Length();
474}
475
476//------------------------------------------------------------------------
477// Location
478//------------------------------------------------------------------------
479Standard_Integer PCollection_HAsciiString::Location
480 (const Standard_Integer N, const Standard_Character C,
481 const Standard_Integer FromIndex, const Standard_Integer ToIndex) const
482{
483 if (ToIndex > Length() || FromIndex <= 0 || FromIndex > ToIndex )
484 Standard_OutOfRange::Raise();
485 for(Standard_Integer i = FromIndex-1, count = 0; i <= ToIndex-1; i++)
486 if(Data(i) == C) {
487 count++;
488 if ( count == N ) return (i+1);
489 }
490 return 0 ;
491}
492
493//------------------------------------------------------------------------
494// Location
495//------------------------------------------------------------------------
496Standard_Integer PCollection_HAsciiString::Location
497 (const Handle(PCollection_HAsciiString)& S, const Standard_Integer FromIndex,
498 const Standard_Integer ToIndex) const
499{
500 if (Length() == 0 || S->Length() == 0) return 0;
501 if (ToIndex > Length() || FromIndex <= 0 || FromIndex > ToIndex )
502 Standard_OutOfRange::Raise();
503 for(Standard_Integer i = FromIndex-1, k = 1, l = FromIndex-2; i < ToIndex; i++){
504 if(Data(i) == S->Value(k)) {
505 k++;
506 if ( k > S->Length()) return l + 2;
507 }
508 else {
509 k = 1;
510 l = i;
511 }
512 }
513 return 0;
514}
515
516//------------------------------------------------------------------------
517// Lowercase
518//------------------------------------------------------------------------
519void PCollection_HAsciiString::Lowercase ()
520{
521 for( Standard_Integer i = 0 ; i < Data.Length() ; i++) {
522 Data.SetValue(i, LowerCase(Data(i)));
523 }
524}
525
526//------------------------------------------------------------------------
527// Prepend
528//------------------------------------------------------------------------
529void PCollection_HAsciiString::Prepend
530 (const Handle(PCollection_HAsciiString)& S)
531{
532 InsertAfter(0,S);
533}
534
535
536//------------------------------------------------------------------------
537// Print
538//------------------------------------------------------------------------
539void PCollection_HAsciiString::Print (Standard_OStream& S) const
540{
541 Standard_Integer len = Data.Length() ;
542 for(Standard_Integer i = 0; i < len ; i++) {
543 S << Data(i);
544 }
545}
546
547//------------------------------------------------------------------------
548// RealValue
549//------------------------------------------------------------------------
550Standard_Real PCollection_HAsciiString::RealValue () const
551{
552 if(!IsRealValue()) Standard_NumericError::Raise();
553 return cnvreal;
554}
555
556//------------------------------------------------------------------------
557// Remove
558//------------------------------------------------------------------------
559void PCollection_HAsciiString::Remove (const Standard_Integer Index)
560{
561 if (Index < 0 || Index > Length()) Standard_OutOfRange::Raise();
562 Remove(Index,Index);
563}
564
565//------------------------------------------------------------------------
566// Remove
567//------------------------------------------------------------------------
568void PCollection_HAsciiString::Remove
569 (const Standard_Integer FromIndex, const Standard_Integer ToIndex)
570{
571 if (ToIndex > Length() || FromIndex <= 0 || FromIndex > ToIndex )
572 Standard_OutOfRange::Raise();
573 Standard_Integer size1 = Length();
574 for( Standard_Integer i = ToIndex, j = FromIndex-1; i < size1 ; i++, j++)
575 Data.SetValue(j,Data(i));
576 Data.Resize(size1-(ToIndex-FromIndex+1));
577}
578
579//------------------------------------------------------------------------
580// RemoveAll
581//------------------------------------------------------------------------
582void PCollection_HAsciiString::RemoveAll
583 (const Standard_Character C, const Standard_Boolean CaseSensitive)
584{
585 Standard_Integer i ;
586 Standard_Integer j ;
587 Standard_Integer size1 = Length();
588 for( i = 0, j = 0; i < size1 ; i++){
589 if(CaseSensitive){
590 if(Data(i) == C) continue;
591 }
592 else {
593 if(UpperCase(Data(i)) == UpperCase(C)) continue;
594 }
595 Data.SetValue(j++, Data(i));
596 }
597 Data.Resize(j);
598}
599
600//------------------------------------------------------------------------
601// RightAdjust
602//------------------------------------------------------------------------
603void PCollection_HAsciiString::RightAdjust ()
604{
605 Standard_Integer i ;
606 for( i = Data.Length()-1 ; i >= 0 ; i--) if(!IsSpace(Data(i))) break;
607 if( i < Data.Length()-1 ) Remove(i+2,Data.Length());
608}
609
610//------------------------------------------------------------------------
611// RightJustify
612//------------------------------------------------------------------------
613void PCollection_HAsciiString::RightJustify
614 (const Standard_Integer Width, const Standard_Character Filler)
615{
616 Standard_Integer i ;
617 Standard_Integer k ;
618 if (Width < 0) Standard_NegativeValue::Raise();
619 Standard_Integer size1 = Length();
620 if(Width > size1) {
621 Data.Resize(Width);
622 for ( i = size1-1, k = Width-1 ; i >= 0 ; i--, k--)
623 Data.SetValue(k, Data(i));
624 for(; k >= 0 ; k--) Data.SetValue(k, Filler);
625 }
626}
627
628//------------------------------------------------------------------------
629// SetValue
630//------------------------------------------------------------------------
631void PCollection_HAsciiString::SetValue
632 (const Standard_Integer Index, const Handle(PCollection_HAsciiString)& S)
633{
634
635 Standard_Integer size1 = Length();
636 Standard_Integer size2 = S->Length();
637 Standard_Integer size3 = size2 + Index - 1;
638#ifndef NOBOUNDCHECK
639 if (Index < 0 || Index > size1) Standard_OutOfRange::Raise();
640#endif
641 if(size1 != size3) Data.Resize(size3);
642 for( Standard_Integer i = 1 ; i <= size2; i++) Data.SetValue(Index+i-2, S->Value(i));
643}
644
645//------------------------------------------------------------------------
646// SetValue
647//------------------------------------------------------------------------
648void PCollection_HAsciiString::SetValue
649 (const Standard_Integer Index, const Standard_Character C)
650{
651 if (Index < 0 || Index > Length()) Standard_OutOfRange::Raise();
652 Data(Index-1) = C;
653}
654
655//------------------------------------------------------------------------
656// Split
657//------------------------------------------------------------------------
658Handle(PCollection_HAsciiString) PCollection_HAsciiString::Split
659 (const Standard_Integer Index)
660{
661 if (Index < 0 || Index > Length()) Standard_OutOfRange::Raise();
662 Handle(PCollection_HAsciiString) S2;
663 if (Index != Length()) {
664 S2 = SubString(Index+1,Length());
665 Data.Resize(Index);
666 }
667 else {
668#ifndef OBJS
669 S2 = new PCollection_HAsciiString("");
670#else
671 S2 = new (os_segment::of(this)) PCollection_HAsciiString("");
672#endif
673 }
674 return S2;
675}
676
677//------------------------------------------------------------------------
678// SubString
679//------------------------------------------------------------------------
680Handle(PCollection_HAsciiString) PCollection_HAsciiString::SubString
681 (const Standard_Integer FromIndex, const Standard_Integer ToIndex) const
682{
683 if (ToIndex > Length() || FromIndex <= 0 || FromIndex > ToIndex )
684 Standard_OutOfRange::Raise();
685 Handle(PCollection_HAsciiString) S1;
686 Handle(PCollection_HAsciiString) S2;
687 S2 = this;
688#ifndef OBJS
689 S1 = new PCollection_HAsciiString(S2,FromIndex,ToIndex);
690#else
691 S1 = new (os_segment::of(this)) PCollection_HAsciiString(S2,FromIndex,ToIndex);
692
693#endif
694 return S1;
695}
696
697//------------------------------------------------------------------------
698// Token
699//------------------------------------------------------------------------
700Handle(PCollection_HAsciiString) PCollection_HAsciiString::Token
701 (const Standard_CString separators ,
702 const Standard_Integer whichone) const
703{
704 TCollection_AsciiString TMe = Convert();
705 Handle(PCollection_HAsciiString)
706#ifndef OBJS
707 TheToken = new PCollection_HAsciiString(TMe.Token(separators,whichone));
708#else
709 TheToken = new (os_segment::of(this)) PCollection_HAsciiString(TMe.Token(separators,whichone));
710#endif
711 return TheToken;
712}
713
714//------------------------------------------------------------------------
715// Uppercase
716//------------------------------------------------------------------------
717void PCollection_HAsciiString::Uppercase ()
718{
719 for( Standard_Integer i = 0 ; i < Data.Length() ; i++)
720 Data.SetValue(i, UpperCase(Data(i)));
721}
722
723//------------------------------------------------------------------------
724// UsefullLength
725//------------------------------------------------------------------------
726Standard_Integer PCollection_HAsciiString::UsefullLength () const
727{
728 Standard_Integer i ;
729 for( i = Data.Length() -1 ; i >= 0 ; i--)
730 if(IsGraphic(Data(i))) break;
731 return (i+1) ;
732}
733
734//------------------------------------------------------------------------
735// value
736//------------------------------------------------------------------------
737Standard_Character PCollection_HAsciiString::Value (const Standard_Integer Index) const
738{
739 if (Index < 0 || Index > Length()) Standard_OutOfRange::Raise();
740 return Data(Index-1);
741}
742
743
744
745//------------------------------------------------------------------------
746// Assign
747//------------------------------------------------------------------------
748void PCollection_HAsciiString::Assign(const DBC_VArrayOfCharacter& TheField)
749
750{
751 Data = TheField;
752}
753
754//------------------------------------------------------------------------
755// ShallowDump
756//------------------------------------------------------------------------
757void PCollection_HAsciiString::ShallowDump(Standard_OStream& S) const
758{
759 S << "begin class HAsciiString " << endl;
760 ::ShallowDump(Data, S);
761 S << "end class HAsciiString" << endl;
762}