xref: /aoo42x/main/idl/inc/bastype.hxx (revision 67e470da)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _BASTYPE_HXX
25 #define _BASTYPE_HXX
26 
27 
28 #include <tools/globname.hxx>
29 #include <tools/gen.hxx>
30 #include <tools/stream.hxx>
31 #include <tools/unqid.hxx>
32 #include <tools/string.hxx>
33 
34 class SvStringHashEntry;
35 class SvIdlDataBase;
36 class SvTokenStream;
37 
38 /******************** class SvUINT32 **********************************/
39 class SvUINT32
40 {
41     sal_uInt32  nVal;
42 public:
SvUINT32()43                 SvUINT32() { nVal = 0; }
SvUINT32(sal_uInt32 n)44                 SvUINT32( sal_uInt32 n ) : nVal( n ) {}
operator =(sal_uInt32 n)45     SvUINT32 &  operator = ( sal_uInt32 n ) { nVal = n; return *this; }
46 
operator sal_uInt32&()47     operator    sal_uInt32 &() { return nVal; }
48 
49     static sal_uInt32  Read( SvStream & rStm );
50     static void    Write( SvStream & rStm, sal_uInt32 nVal );
51 
operator <<(SvStream & rStm,const SvUINT32 & r)52     friend SvStream& operator << (SvStream & rStm, const SvUINT32 & r )
53                 { SvUINT32::Write( rStm, r.nVal ); return rStm; }
operator >>(SvStream & rStm,SvUINT32 & r)54     friend SvStream& operator >> (SvStream & rStm, SvUINT32 & r )
55                 { r.nVal = SvUINT32::Read( rStm ); return rStm; }
56 };
57 
58 
59 /******************** class SvINT16 **********************************/
60 class SvINT16
61 {
62     short   nVal;
63 public:
SvINT16()64                 SvINT16() { nVal = 0; }
SvINT16(short n)65                 SvINT16( short n ) : nVal( n ) {}
operator =(short n)66     SvINT16 &   operator = ( short n ) { nVal = n; return *this; }
67 
68     operator    short &() { return nVal; }
69 
operator <<(SvStream & rStm,const SvINT16 & r)70     friend SvStream& operator << (SvStream & rStm, const SvINT16 & r )
71                 { SvUINT32::Write( rStm, (sal_uInt32)r.nVal ); return rStm; }
operator >>(SvStream & rStm,SvINT16 & r)72     friend SvStream& operator >> (SvStream & rStm, SvINT16 & r )
73                 { r.nVal = (short)SvUINT32::Read( rStm ); return rStm; }
74 };
75 
76 
77 /******************** class SvUINT16 **********************************/
78 class SvUINT16
79 {
80     sal_uInt16  nVal;
81 public:
SvUINT16()82                 SvUINT16() { nVal = 0; }
SvUINT16(sal_uInt16 n)83                 SvUINT16( sal_uInt16 n ) : nVal( n ) {}
operator =(sal_uInt16 n)84     SvUINT16 &  operator = ( sal_uInt16 n ) { nVal = n; return *this; }
85 
operator sal_uInt16&()86     operator    sal_uInt16 &() { return nVal; }
87 
operator <<(SvStream & rStm,const SvUINT16 & r)88     friend SvStream& operator << (SvStream & rStm, const SvUINT16 & r )
89                 { SvUINT32::Write( rStm, (sal_uInt32)r.nVal ); return rStm; }
operator >>(SvStream & rStm,SvUINT16 & r)90     friend SvStream& operator >> (SvStream & rStm, SvUINT16 & r )
91                 { r.nVal = (sal_uInt16)SvUINT32::Read( rStm ); return rStm; }
92 };
93 
94 
95 /******************** class SvINT32 **********************************/
96 class SvINT32
97 {
98     sal_Int32   nVal;
99 public:
SvINT32()100                 SvINT32() { nVal = 0; }
SvINT32(sal_Int32 n)101                 SvINT32( sal_Int32 n ) : nVal( n ) {}
operator =(sal_Int32 n)102     SvINT32 &   operator = ( sal_Int32 n ) { nVal = n; return *this; }
103 
operator sal_Int32&()104     operator    sal_Int32 &() { return nVal; }
105 
operator <<(SvStream & rStm,const SvINT32 & r)106     friend SvStream& operator << (SvStream & rStm, const SvINT32 & r )
107                 { SvUINT32::Write( rStm, (sal_uInt32)r.nVal ); return rStm; }
operator >>(SvStream & rStm,SvINT32 & r)108     friend SvStream& operator >> (SvStream & rStm, SvINT32 & r )
109                 { r.nVal = (sal_Int32)SvUINT32::Read( rStm ); return rStm; }
110 };
111 
112 
113 /******************** class Svint **********************************/
114 class Svint
115 {
116     int  	nVal;
117 	sal_Bool	bSet;
118 public:
Svint()119                 Svint() { nVal = bSet = 0; }
Svint(int n)120                 Svint( int n ) : nVal( n ), bSet( sal_True ) {}
Svint(int n,sal_Bool bSetP)121                 Svint( int n, sal_Bool bSetP ) : nVal( n ), bSet( bSetP ) {}
operator =(int n)122     Svint    &  operator = ( int n ) { nVal = n; bSet = sal_True; return *this; }
123 
124     operator    int ()const { return nVal; }
IsSet() const125     sal_Bool        IsSet() const { return bSet; }
126 
operator <<(SvStream & rStm,const Svint & r)127     friend SvStream& operator << (SvStream & rStm, const Svint & r )
128                 { SvUINT32::Write( rStm, (sal_uInt32)r.nVal ); rStm << r.bSet; return rStm; }
operator >>(SvStream & rStm,Svint & r)129     friend SvStream& operator >> (SvStream & rStm, Svint & r )
130                 { r.nVal = (int)SvUINT32::Read( rStm ); rStm >> r.bSet ; return rStm; }
131 };
132 
133 
134 /******************** class SvBOOL **********************************/
135 class SvBOOL
136 {
137     sal_Bool  nVal:1,
138           bSet:1;
139 public:
SvBOOL()140                 SvBOOL() { bSet = nVal = sal_False; }
SvBOOL(sal_Bool n)141                 SvBOOL( sal_Bool n ) : nVal( n ), bSet( sal_True ) {}
SvBOOL(sal_Bool n,sal_Bool bSetP)142                 SvBOOL( sal_Bool n, sal_Bool bSetP ) : nVal( n ), bSet( bSetP ) {}
operator =(sal_Bool n)143     SvBOOL &    operator = ( sal_Bool n ) { nVal = n; bSet = sal_True; return *this; }
144 
operator sal_Bool() const145     operator    sal_Bool() const { return nVal; }
146 #ifdef STC
147     operator    int() const { return nVal; }
148 #endif
Is() const149     sal_Bool        Is() const { return nVal; }
IsSet() const150     sal_Bool        IsSet() const { return bSet; }
151 
152     friend SvStream& operator << (SvStream &, const SvBOOL &);
153     friend SvStream& operator >> (SvStream &, SvBOOL &);
154 
155 #ifdef IDL_COMPILER
156     sal_Bool        ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm );
157     sal_Bool        WriteSvIdl( SvStringHashEntry * pName, SvStream & rOutStm );
158     ByteString      GetSvIdlString( SvStringHashEntry * pName );
159 #endif
160 };
161 
162 
163 /******************** class SvIdentifier **********************************/
164 class SvIdentifier : public ByteString
165 {
166 public:
SvIdentifier()167                 SvIdentifier(){};
operator =(const ByteString & rStr)168     SvIdentifier & operator = ( const ByteString & rStr )
169                 { ByteString::operator =( rStr ); return *this; }
170     friend SvStream& operator << (SvStream &, const SvIdentifier &);
171     friend SvStream& operator >> (SvStream &, SvIdentifier &);
172 
IsSet() const173     sal_Bool        IsSet() const { return Len() != 0; }
174 #ifdef IDL_COMPILER
175     sal_Bool        ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm );
176     sal_Bool        WriteSvIdl( SvStringHashEntry * pName, SvStream & rOutStm,
177                             sal_uInt16 nTab );
178 #endif
179 };
180 
181 
182 /******************** class SvIdentifier **********************************/
183 class SvNumberIdentifier : public SvIdentifier
184 {
185     sal_uInt32  nValue;
186     // darf nicht benutzt werden
187     sal_Bool    ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm );
188 public:
SvNumberIdentifier()189                 SvNumberIdentifier() : nValue( 0 ) {};
IsSet() const190     sal_Bool        IsSet() const
191 				{
192 					return SvIdentifier::IsSet() || nValue != 0;
193 				}
GetValue() const194     sal_uInt32      GetValue() const { return nValue; }
SetValue(sal_uInt32 nVal)195     void		SetValue( sal_uInt32 nVal ) { nValue = nVal; }
196 
197     friend SvStream& operator << (SvStream &, const SvNumberIdentifier &);
198     friend SvStream& operator >> (SvStream &, SvNumberIdentifier &);
199 #ifdef IDL_COMPILER
200     sal_Bool        ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm );
201     sal_Bool        ReadSvIdl( SvIdlDataBase &, SvStringHashEntry * pName,
202                            SvTokenStream & rInStm );
203 #endif
204 };
205 
206 
207 /******************** class SvString **********************************/
208 class SvString : public ByteString
209 {
210 public:
SvString()211                 SvString(){};
operator =(const ByteString & rStr)212     SvString &  operator = ( const ByteString & rStr )
213                 { ByteString::operator =( rStr ); return *this; }
IsSet() const214     sal_Bool        IsSet() const { return Len() != 0; }
215     friend SvStream& operator << (SvStream &, const SvString &);
216     friend SvStream& operator >> (SvStream &, SvString &);
217 
218 #ifdef IDL_COMPILER
219     sal_Bool        ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm );
220     sal_Bool        WriteSvIdl( SvStringHashEntry * pName, SvStream & rOutStm,
221                             sal_uInt16 nTab );
222 #endif
223 };
224 
225 
226 /******************** class SvHelpText **********************************/
227 class SvHelpText : public SvString
228 {
229 public:
SvHelpText()230                 SvHelpText() {}
231 #ifdef IDL_COMPILER
232     sal_Bool        ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm );
233     sal_Bool        WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm,
234                             sal_uInt16 nTab );
235 #endif
236 };
237 
238 
239 /******************** class SvHelpContext *******************************/
240 class SvHelpContext : public SvNumberIdentifier
241 {
242 };
243 
244 /******************** class SvUUId *************************************/
245 class SvUUId : public SvGlobalName
246 {
247 public:
SvUUId()248                 SvUUId() {}
249 #ifdef IDL_COMPILER
250     sal_Bool        ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm );
251     sal_Bool        WriteSvIdl( SvStream & rOutStm );
252 #endif
253 };
254 
255 
256 /******************** class SvVersion **********************************/
257 class SvVersion
258 {
259     sal_uInt16  nMajorVersion;
260     sal_uInt16  nMinorVersion;
261 public:
SvVersion()262                 SvVersion() : nMajorVersion( 1 ), nMinorVersion( 0 ) {}
operator ==(const SvVersion & r)263     sal_Bool        operator == ( const SvVersion & r )
264 				{
265 					return (r.nMajorVersion == nMajorVersion)
266 							 && (r.nMinorVersion == nMinorVersion);
267 				}
operator !=(const SvVersion & r)268     sal_Bool        operator != ( const SvVersion & r )
269 				{
270 					return !(*this == r);
271 				}
272 
GetMajorVersion() const273     sal_uInt16      GetMajorVersion() const { return nMajorVersion; }
GetMinorVersion() const274     sal_uInt16      GetMinorVersion() const { return nMinorVersion; }
275 
276     friend SvStream& operator << (SvStream &, const SvVersion &);
277     friend SvStream& operator >> (SvStream &, SvVersion &);
278 #ifdef IDL_COMPILER
279     sal_Bool        ReadSvIdl( SvTokenStream & rInStm );
280     sal_Bool        WriteSvIdl( SvStream & rOutStm );
281 #endif
282 };
283 
284 
285 #endif // _BASTYPE_HXX
286 
287