0025790: Drop unimplemented method ShallowCopy() from TCollection_HSequence.cdl
[occt.git] / src / TCollection / TCollection_AsciiString.lxx
1 // Copyright (c) 1998-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
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
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.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15 #include <Standard_OutOfRange.hxx>
16 #include <Standard_CString.hxx>
17
18 //definition global methods for using in NCollection
19 //------------------------------------------------------------------------
20 //  HashCode
21 //------------------------------------------------------------------------
22 inline Standard_Integer HashCode(const TCollection_AsciiString& astring,
23                                                    const Standard_Integer Upper)
24 {
25   return TCollection_AsciiString::HashCode(astring,Upper);
26 }
27
28
29 //------------------------------------------------------------------------
30 //  IsEqual
31 //------------------------------------------------------------------------
32 inline Standard_Boolean IsEqual(const TCollection_AsciiString& string1,
33                                                   const TCollection_AsciiString& string2)
34 {
35   return TCollection_AsciiString::IsEqual(string1,string2);
36 }
37
38
39
40 // ----------------------------------------------------------------------------
41 // ToCString
42 // ----------------------------------------------------------------------------
43 inline Standard_CString TCollection_AsciiString::ToCString()const
44 {
45   return mystring;
46 }
47
48 // ----------------------------------------------------------------------------
49 inline Standard_Integer TCollection_AsciiString::Length() const
50 {
51  return mylength;
52 }
53
54 inline TCollection_AsciiString TCollection_AsciiString::Cat(const TCollection_AsciiString& other) const
55 {
56   return TCollection_AsciiString( *this , other ) ;
57 }
58
59 inline TCollection_AsciiString TCollection_AsciiString::Cat(const Standard_CString other) const 
60 {
61  return TCollection_AsciiString( *this , other ) ;
62 }
63
64 inline TCollection_AsciiString TCollection_AsciiString::Cat(const Standard_Character other) const 
65 {
66  return TCollection_AsciiString( *this , other ) ;
67 }
68
69 inline TCollection_AsciiString TCollection_AsciiString::Cat(const Standard_Integer other) const 
70 {
71
72  return TCollection_AsciiString( *this , TCollection_AsciiString(other) ) ;
73 }
74
75 inline TCollection_AsciiString TCollection_AsciiString::Cat(const Standard_Real other) const 
76 {
77
78  return TCollection_AsciiString( *this , TCollection_AsciiString(other) ) ;
79 }
80
81 //------------------------------------------------------------------------
82 //  HashCode
83 //------------------------------------------------------------------------
84 inline Standard_Integer TCollection_AsciiString::HashCode(const TCollection_AsciiString& astring,
85                                                    const Standard_Integer Upper)
86 {
87   return ::HashCode(astring.ToCString(),Upper);
88 }
89
90
91 //------------------------------------------------------------------------
92 //  IsEqual
93 //------------------------------------------------------------------------
94 inline Standard_Boolean TCollection_AsciiString::IsEqual(const TCollection_AsciiString& string1,
95                                                   const TCollection_AsciiString& string2)
96 {
97   return string1.IsEqual(string2);
98 }
99
100 //------------------------------------------------------------------------
101 //  IsEqual
102 //------------------------------------------------------------------------
103 inline Standard_Boolean TCollection_AsciiString::IsEqual(const TCollection_AsciiString& string1,
104                                                   const Standard_CString string2)
105 {
106   return string1.IsEqual( string2 );
107 }
108
109 // ----------------------------------------------------------------------------
110 // SubString
111 // ----------------------------------------------------------------------------
112 inline TCollection_AsciiString TCollection_AsciiString::SubString(const Standard_Integer FromIndex,
113                                                            const Standard_Integer ToIndex) const
114 {
115
116   if (ToIndex > mylength || FromIndex <= 0 || FromIndex > ToIndex ) Standard_OutOfRange::Raise();
117
118   return TCollection_AsciiString( &mystring [ FromIndex - 1 ] ,
119                                   ToIndex - FromIndex + 1 ) ;
120 }