Bump for 3.6-28
[LibreOffice.git] / idl / inc / bastype.hxx
blob08d955713bd0e11cbb625b47a221911f93cedc53
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 ************************************************************************/
29 #ifndef _BASTYPE_HXX
30 #define _BASTYPE_HXX
33 #include <tools/globname.hxx>
34 #include <tools/gen.hxx>
35 #include <tools/stream.hxx>
36 #include <tools/string.hxx>
38 class SvStringHashEntry;
39 class SvIdlDataBase;
40 class SvTokenStream;
42 class SvUINT32
44 sal_uInt32 nVal;
45 public:
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; }
62 class SvINT16
64 short nVal;
65 public:
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; }
79 class SvUINT16
81 sal_uInt16 nVal;
82 public:
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; }
96 class SvINT32
98 sal_Int32 nVal;
99 public:
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; }
113 class Svint
115 int nVal;
116 sal_Bool bSet;
117 public:
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; }
133 class SvBOOL
135 sal_Bool nVal:1,
136 bSet:1;
137 public:
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; }
144 #ifdef STC
145 operator int() const { return nVal; }
146 #endif
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 );
159 class SvIdentifier
161 private:
162 rtl::OString m_aStr;
163 public:
164 SvIdentifier()
167 void setString(const rtl::OString& rStr)
169 m_aStr = rStr;
171 const rtl::OString& getString() const
173 return m_aStr;
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,
184 sal_uInt16 nTab );
188 class SvNumberIdentifier : public SvIdentifier
190 sal_uInt32 nValue;
191 // must not be used
192 sal_Bool ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm );
193 public:
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 );
210 class SvString
212 private:
213 rtl::OString m_aStr;
214 public:
215 SvString() {}
216 void setString(const rtl::OString& rStr)
218 m_aStr = rStr;
220 const rtl::OString& getString() const
222 return m_aStr;
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,
233 sal_uInt16 nTab );
237 class SvHelpText : public SvString
239 public:
240 SvHelpText() {}
241 sal_Bool ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm );
242 sal_Bool WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm,
243 sal_uInt16 nTab );
247 class SvHelpContext : public SvNumberIdentifier
251 class SvUUId : public SvGlobalName
253 public:
254 SvUUId() {}
255 sal_Bool ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm );
256 sal_Bool WriteSvIdl( SvStream & rOutStm );
260 class SvVersion
262 sal_uInt16 nMajorVersion;
263 sal_uInt16 nMinorVersion;
264 public:
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: */