1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: bastype.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
35 #include <tools/globname.hxx>
36 #include <tools/gen.hxx>
37 #include <tools/stream.hxx>
38 #include <tools/unqid.hxx>
39 #include <tools/string.hxx>
41 class SvStringHashEntry
;
45 /******************** class SvUINT32 **********************************/
50 SvUINT32() { nVal
= 0; }
51 SvUINT32( UINT32 n
) : nVal( n
) {}
52 SvUINT32
& operator = ( UINT32 n
) { nVal
= n
; return *this; }
54 operator UINT32
&() { return nVal
; }
56 static UINT32
Read( SvStream
& rStm
);
57 static void Write( SvStream
& rStm
, UINT32 nVal
);
59 friend SvStream
& operator << (SvStream
& rStm
, const SvUINT32
& r
)
60 { SvUINT32::Write( rStm
, r
.nVal
); return rStm
; }
61 friend SvStream
& operator >> (SvStream
& rStm
, SvUINT32
& r
)
62 { r
.nVal
= SvUINT32::Read( rStm
); return rStm
; }
66 /******************** class SvINT16 **********************************/
71 SvINT16() { nVal
= 0; }
72 SvINT16( short n
) : nVal( n
) {}
73 SvINT16
& operator = ( short n
) { nVal
= n
; return *this; }
75 operator short &() { return nVal
; }
77 friend SvStream
& operator << (SvStream
& rStm
, const SvINT16
& r
)
78 { SvUINT32::Write( rStm
, (UINT32
)r
.nVal
); return rStm
; }
79 friend SvStream
& operator >> (SvStream
& rStm
, SvINT16
& r
)
80 { r
.nVal
= (short)SvUINT32::Read( rStm
); return rStm
; }
84 /******************** class SvUINT16 **********************************/
89 SvUINT16() { nVal
= 0; }
90 SvUINT16( USHORT n
) : nVal( n
) {}
91 SvUINT16
& operator = ( USHORT n
) { nVal
= n
; return *this; }
93 operator UINT16
&() { return nVal
; }
95 friend SvStream
& operator << (SvStream
& rStm
, const SvUINT16
& r
)
96 { SvUINT32::Write( rStm
, (UINT32
)r
.nVal
); return rStm
; }
97 friend SvStream
& operator >> (SvStream
& rStm
, SvUINT16
& r
)
98 { r
.nVal
= (USHORT
)SvUINT32::Read( rStm
); return rStm
; }
102 /******************** class SvINT32 **********************************/
107 SvINT32() { nVal
= 0; }
108 SvINT32( INT32 n
) : nVal( n
) {}
109 SvINT32
& operator = ( INT32 n
) { nVal
= n
; return *this; }
111 operator INT32
&() { return nVal
; }
113 friend SvStream
& operator << (SvStream
& rStm
, const SvINT32
& r
)
114 { SvUINT32::Write( rStm
, (UINT32
)r
.nVal
); return rStm
; }
115 friend SvStream
& operator >> (SvStream
& rStm
, SvINT32
& r
)
116 { r
.nVal
= (INT32
)SvUINT32::Read( rStm
); return rStm
; }
120 /******************** class Svint **********************************/
126 Svint() { nVal
= bSet
= 0; }
127 Svint( int n
) : nVal( n
), bSet( TRUE
) {}
128 Svint( int n
, BOOL bSetP
) : nVal( n
), bSet( bSetP
) {}
129 Svint
& operator = ( int n
) { nVal
= n
; bSet
= TRUE
; return *this; }
131 operator int ()const { return nVal
; }
132 BOOL
IsSet() const { return bSet
; }
134 friend SvStream
& operator << (SvStream
& rStm
, const Svint
& r
)
135 { SvUINT32::Write( rStm
, (UINT32
)r
.nVal
); rStm
<< r
.bSet
; return rStm
; }
136 friend SvStream
& operator >> (SvStream
& rStm
, Svint
& r
)
137 { r
.nVal
= (int)SvUINT32::Read( rStm
); rStm
>> r
.bSet
; return rStm
; }
141 /******************** class SvBOOL **********************************/
147 SvBOOL() { bSet
= nVal
= FALSE
; }
148 SvBOOL( BOOL n
) : nVal( n
), bSet( TRUE
) {}
149 SvBOOL( BOOL n
, BOOL bSetP
) : nVal( n
), bSet( bSetP
) {}
150 SvBOOL
& operator = ( BOOL n
) { nVal
= n
; bSet
= TRUE
; return *this; }
152 operator BOOL() const { return nVal
; }
154 operator int() const { return nVal
; }
156 BOOL
Is() const { return nVal
; }
157 BOOL
IsSet() const { return bSet
; }
159 friend SvStream
& operator << (SvStream
&, const SvBOOL
&);
160 friend SvStream
& operator >> (SvStream
&, SvBOOL
&);
163 BOOL
ReadSvIdl( SvStringHashEntry
* pName
, SvTokenStream
& rInStm
);
164 BOOL
WriteSvIdl( SvStringHashEntry
* pName
, SvStream
& rOutStm
);
165 ByteString
GetSvIdlString( SvStringHashEntry
* pName
);
170 /******************** class SvIdentifier **********************************/
171 class SvIdentifier
: public ByteString
175 SvIdentifier
& operator = ( const ByteString
& rStr
)
176 { ByteString::operator =( rStr
); return *this; }
177 friend SvStream
& operator << (SvStream
&, const SvIdentifier
&);
178 friend SvStream
& operator >> (SvStream
&, SvIdentifier
&);
180 BOOL
IsSet() const { return Len() != 0; }
182 BOOL
ReadSvIdl( SvStringHashEntry
* pName
, SvTokenStream
& rInStm
);
183 BOOL
WriteSvIdl( SvStringHashEntry
* pName
, SvStream
& rOutStm
,
189 /******************** class SvIdentifier **********************************/
190 class SvNumberIdentifier
: public SvIdentifier
193 // darf nicht benutzt werden
194 BOOL
ReadSvIdl( SvStringHashEntry
* pName
, SvTokenStream
& rInStm
);
196 SvNumberIdentifier() : nValue( 0 ) {};
199 return SvIdentifier::IsSet() || nValue
!= 0;
201 UINT32
GetValue() const { return nValue
; }
202 void SetValue( UINT32 nVal
) { nValue
= nVal
; }
204 friend SvStream
& operator << (SvStream
&, const SvNumberIdentifier
&);
205 friend SvStream
& operator >> (SvStream
&, SvNumberIdentifier
&);
207 BOOL
ReadSvIdl( SvIdlDataBase
&, SvTokenStream
& rInStm
);
208 BOOL
ReadSvIdl( SvIdlDataBase
&, SvStringHashEntry
* pName
,
209 SvTokenStream
& rInStm
);
214 /******************** class SvString **********************************/
215 class SvString
: public ByteString
219 SvString
& operator = ( const ByteString
& rStr
)
220 { ByteString::operator =( rStr
); return *this; }
221 BOOL
IsSet() const { return Len() != 0; }
222 friend SvStream
& operator << (SvStream
&, const SvString
&);
223 friend SvStream
& operator >> (SvStream
&, SvString
&);
226 BOOL
ReadSvIdl( SvStringHashEntry
* pName
, SvTokenStream
& rInStm
);
227 BOOL
WriteSvIdl( SvStringHashEntry
* pName
, SvStream
& rOutStm
,
233 /******************** class SvHelpText **********************************/
234 class SvHelpText
: public SvString
239 BOOL
ReadSvIdl( SvIdlDataBase
&, SvTokenStream
& rInStm
);
240 BOOL
WriteSvIdl( SvIdlDataBase
& rBase
, SvStream
& rOutStm
,
246 /******************** class SvHelpContext *******************************/
247 class SvHelpContext
: public SvNumberIdentifier
251 /******************** class SvUUId *************************************/
252 class SvUUId
: public SvGlobalName
257 BOOL
ReadSvIdl( SvIdlDataBase
&, SvTokenStream
& rInStm
);
258 BOOL
WriteSvIdl( SvStream
& rOutStm
);
263 /******************** class SvVersion **********************************/
266 USHORT nMajorVersion
;
267 USHORT nMinorVersion
;
269 SvVersion() : nMajorVersion( 1 ), nMinorVersion( 0 ) {}
270 BOOL
operator == ( const SvVersion
& r
)
272 return (r
.nMajorVersion
== nMajorVersion
)
273 && (r
.nMinorVersion
== nMinorVersion
);
275 BOOL
operator != ( const SvVersion
& r
)
277 return !(*this == r
);
280 USHORT
GetMajorVersion() const { return nMajorVersion
; }
281 USHORT
GetMinorVersion() const { return nMinorVersion
; }
283 friend SvStream
& operator << (SvStream
&, const SvVersion
&);
284 friend SvStream
& operator >> (SvStream
&, SvVersion
&);
286 BOOL
ReadSvIdl( SvTokenStream
& rInStm
);
287 BOOL
WriteSvIdl( SvStream
& rOutStm
);
292 #endif // _BASTYPE_HXX