1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
33 #include <tools/globname.hxx>
34 #include <tools/gen.hxx>
35 #include <tools/stream.hxx>
36 #include <tools/string.hxx>
38 class SvStringHashEntry
;
46 SvUINT32() { nVal
= 0; }
47 SvUINT32( sal_uInt32 n
) : nVal( n
) {}
48 SvUINT32
& operator = ( sal_uInt32 n
) { nVal
= n
; return *this; }
50 operator sal_uInt32
&() { return nVal
; }
52 static sal_uInt32
Read( SvStream
& rStm
);
53 static void Write( SvStream
& rStm
, sal_uInt32 nVal
);
55 friend SvStream
& operator << (SvStream
& rStm
, const SvUINT32
& r
)
56 { SvUINT32::Write( rStm
, r
.nVal
); return rStm
; }
57 friend SvStream
& operator >> (SvStream
& rStm
, SvUINT32
& r
)
58 { r
.nVal
= SvUINT32::Read( rStm
); return rStm
; }
66 SvINT16() { nVal
= 0; }
67 SvINT16( short n
) : nVal( n
) {}
68 SvINT16
& operator = ( short n
) { nVal
= n
; return *this; }
70 operator short &() { return nVal
; }
72 friend SvStream
& operator << (SvStream
& rStm
, const SvINT16
& r
)
73 { SvUINT32::Write( rStm
, (sal_uInt32
)r
.nVal
); return rStm
; }
74 friend SvStream
& operator >> (SvStream
& rStm
, SvINT16
& r
)
75 { r
.nVal
= (short)SvUINT32::Read( rStm
); return rStm
; }
83 SvUINT16() { nVal
= 0; }
84 SvUINT16( sal_uInt16 n
) : nVal( n
) {}
85 SvUINT16
& operator = ( sal_uInt16 n
) { nVal
= n
; return *this; }
87 operator sal_uInt16
&() { return nVal
; }
89 friend SvStream
& operator << (SvStream
& rStm
, const SvUINT16
& r
)
90 { SvUINT32::Write( rStm
, (sal_uInt32
)r
.nVal
); return rStm
; }
91 friend SvStream
& operator >> (SvStream
& rStm
, SvUINT16
& r
)
92 { r
.nVal
= (sal_uInt16
)SvUINT32::Read( rStm
); return rStm
; }
100 SvINT32() { nVal
= 0; }
101 SvINT32( sal_Int32 n
) : nVal( n
) {}
102 SvINT32
& operator = ( sal_Int32 n
) { nVal
= n
; return *this; }
104 operator sal_Int32
&() { return nVal
; }
106 friend SvStream
& operator << (SvStream
& rStm
, const SvINT32
& r
)
107 { SvUINT32::Write( rStm
, (sal_uInt32
)r
.nVal
); return rStm
; }
108 friend SvStream
& operator >> (SvStream
& rStm
, SvINT32
& r
)
109 { r
.nVal
= (sal_Int32
)SvUINT32::Read( rStm
); return rStm
; }
118 Svint() { nVal
= bSet
= 0; }
119 Svint( int n
) : nVal( n
), bSet( sal_True
) {}
120 Svint( int n
, sal_Bool bSetP
) : nVal( n
), bSet( bSetP
) {}
121 Svint
& operator = ( int n
) { nVal
= n
; bSet
= sal_True
; return *this; }
123 operator int ()const { return nVal
; }
124 sal_Bool
IsSet() const { return bSet
; }
126 friend SvStream
& operator << (SvStream
& rStm
, const Svint
& r
)
127 { SvUINT32::Write( rStm
, (sal_uInt32
)r
.nVal
); rStm
<< r
.bSet
; return rStm
; }
128 friend SvStream
& operator >> (SvStream
& rStm
, Svint
& r
)
129 { r
.nVal
= (int)SvUINT32::Read( rStm
); rStm
>> r
.bSet
; return rStm
; }
138 SvBOOL() { bSet
= nVal
= sal_False
; }
139 SvBOOL( sal_Bool n
) : nVal( n
), bSet( sal_True
) {}
140 SvBOOL( sal_Bool n
, sal_Bool bSetP
) : nVal( n
), bSet( bSetP
) {}
141 SvBOOL
& operator = ( sal_Bool n
) { nVal
= n
; bSet
= sal_True
; return *this; }
143 operator sal_Bool() const { return nVal
; }
145 operator int() const { return nVal
; }
147 sal_Bool
Is() const { return nVal
; }
148 sal_Bool
IsSet() const { return bSet
; }
150 friend SvStream
& operator << (SvStream
&, const SvBOOL
&);
151 friend SvStream
& operator >> (SvStream
&, SvBOOL
&);
153 sal_Bool
ReadSvIdl( SvStringHashEntry
* pName
, SvTokenStream
& rInStm
);
154 sal_Bool
WriteSvIdl( SvStringHashEntry
* pName
, SvStream
& rOutStm
);
155 rtl::OString
GetSvIdlString( SvStringHashEntry
* pName
);
167 void setString(const rtl::OString
& rStr
)
171 const rtl::OString
& getString() const
175 friend SvStream
& operator << (SvStream
&, const SvIdentifier
&);
176 friend SvStream
& operator >> (SvStream
&, SvIdentifier
&);
178 sal_Bool
IsSet() const
180 return !m_aStr
.isEmpty();
182 sal_Bool
ReadSvIdl( SvStringHashEntry
* pName
, SvTokenStream
& rInStm
);
183 sal_Bool
WriteSvIdl( SvStringHashEntry
* pName
, SvStream
& rOutStm
,
188 class SvNumberIdentifier
: public SvIdentifier
192 sal_Bool
ReadSvIdl( SvStringHashEntry
* pName
, SvTokenStream
& rInStm
);
194 SvNumberIdentifier() : nValue( 0 ) {};
195 sal_Bool
IsSet() const
197 return SvIdentifier::IsSet() || nValue
!= 0;
199 sal_uInt32
GetValue() const { return nValue
; }
200 void SetValue( sal_uInt32 nVal
) { nValue
= nVal
; }
202 friend SvStream
& operator << (SvStream
&, const SvNumberIdentifier
&);
203 friend SvStream
& operator >> (SvStream
&, SvNumberIdentifier
&);
204 sal_Bool
ReadSvIdl( SvIdlDataBase
&, SvTokenStream
& rInStm
);
205 sal_Bool
ReadSvIdl( SvIdlDataBase
&, SvStringHashEntry
* pName
,
206 SvTokenStream
& rInStm
);
216 void setString(const rtl::OString
& rStr
)
220 const rtl::OString
& getString() const
224 sal_Bool
IsSet() const
226 return !m_aStr
.isEmpty();
228 friend SvStream
& operator << (SvStream
&, const SvString
&);
229 friend SvStream
& operator >> (SvStream
&, SvString
&);
231 sal_Bool
ReadSvIdl( SvStringHashEntry
* pName
, SvTokenStream
& rInStm
);
232 sal_Bool
WriteSvIdl( SvStringHashEntry
* pName
, SvStream
& rOutStm
,
237 class SvHelpText
: public SvString
241 sal_Bool
ReadSvIdl( SvIdlDataBase
&, SvTokenStream
& rInStm
);
242 sal_Bool
WriteSvIdl( SvIdlDataBase
& rBase
, SvStream
& rOutStm
,
247 class SvHelpContext
: public SvNumberIdentifier
251 class SvUUId
: public SvGlobalName
255 sal_Bool
ReadSvIdl( SvIdlDataBase
&, SvTokenStream
& rInStm
);
256 sal_Bool
WriteSvIdl( SvStream
& rOutStm
);
262 sal_uInt16 nMajorVersion
;
263 sal_uInt16 nMinorVersion
;
265 SvVersion() : nMajorVersion( 1 ), nMinorVersion( 0 ) {}
266 sal_Bool
operator == ( const SvVersion
& r
)
268 return (r
.nMajorVersion
== nMajorVersion
)
269 && (r
.nMinorVersion
== nMinorVersion
);
271 sal_Bool
operator != ( const SvVersion
& r
)
273 return !(*this == r
);
276 sal_uInt16
GetMajorVersion() const { return nMajorVersion
; }
277 sal_uInt16
GetMinorVersion() const { return nMinorVersion
; }
279 friend SvStream
& operator << (SvStream
&, const SvVersion
&);
280 friend SvStream
& operator >> (SvStream
&, SvVersion
&);
281 sal_Bool
ReadSvIdl( SvTokenStream
& rInStm
);
282 sal_Bool
WriteSvIdl( SvStream
& rOutStm
);
286 #endif // _BASTYPE_HXX
288 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */