Bump version to 4.1-6
[LibreOffice.git] / idl / inc / bastype.hxx
blobf97672372dc4bab55cf86cd988cc165f9f36e77d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef _BASTYPE_HXX
21 #define _BASTYPE_HXX
24 #include <sal/types.h>
25 #include <tools/globname.hxx>
26 #include <tools/stream.hxx>
27 #include <tools/string.hxx>
29 class SvStringHashEntry;
30 class SvIdlDataBase;
31 class SvTokenStream;
33 class SvUINT32
35 sal_uInt32 nVal;
36 public:
37 SvUINT32() { nVal = 0; }
38 SvUINT32( sal_uInt32 n ) : nVal( n ) {}
39 SvUINT32 & operator = ( sal_uInt32 n ) { nVal = n; return *this; }
41 operator sal_uInt32 &() { return nVal; }
43 static sal_uInt32 Read( SvStream & rStm );
44 static void Write( SvStream & rStm, sal_uInt32 nVal );
46 friend SvStream& operator << (SvStream & rStm, const SvUINT32 & r )
47 { SvUINT32::Write( rStm, r.nVal ); return rStm; }
48 friend SvStream& operator >> (SvStream & rStm, SvUINT32 & r )
49 { r.nVal = SvUINT32::Read( rStm ); return rStm; }
53 class Svint
55 int nVal;
56 sal_Bool bSet;
57 public:
58 Svint() { nVal = bSet = 0; }
59 Svint( int n ) : nVal( n ), bSet( sal_True ) {}
60 Svint( int n, sal_Bool bSetP ) : nVal( n ), bSet( bSetP ) {}
61 Svint & operator = ( int n ) { nVal = n; bSet = sal_True; return *this; }
63 operator int ()const { return nVal; }
64 sal_Bool IsSet() const { return bSet; }
66 friend SvStream& operator << (SvStream & rStm, const Svint & r )
67 { SvUINT32::Write( rStm, (sal_uInt32)r.nVal ); rStm << r.bSet; return rStm; }
68 friend SvStream& operator >> (SvStream & rStm, Svint & r )
69 { r.nVal = (int)SvUINT32::Read( rStm ); rStm >> r.bSet ; return rStm; }
73 class SvBOOL
75 sal_Bool nVal:1,
76 bSet:1;
77 public:
78 SvBOOL() { bSet = nVal = sal_False; }
79 SvBOOL( sal_Bool n ) : nVal( n ), bSet( sal_True ) {}
80 SvBOOL( sal_Bool n, sal_Bool bSetP ) : nVal( n ), bSet( bSetP ) {}
81 SvBOOL & operator = ( sal_Bool n ) { nVal = n; bSet = sal_True; return *this; }
83 operator sal_Bool() const { return nVal; }
84 #ifdef STC
85 operator int() const { return nVal; }
86 #endif
87 sal_Bool Is() const { return nVal; }
88 sal_Bool IsSet() const { return bSet; }
90 friend SvStream& operator << (SvStream &, const SvBOOL &);
91 friend SvStream& operator >> (SvStream &, SvBOOL &);
93 sal_Bool ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm );
94 sal_Bool WriteSvIdl( SvStringHashEntry * pName, SvStream & rOutStm );
95 OString GetSvIdlString( SvStringHashEntry * pName );
99 class SvIdentifier
101 private:
102 OString m_aStr;
103 public:
104 SvIdentifier()
107 void setString(const OString& rStr)
109 m_aStr = rStr;
111 const OString& getString() const
113 return m_aStr;
115 friend SvStream& operator << (SvStream &, const SvIdentifier &);
116 friend SvStream& operator >> (SvStream &, SvIdentifier &);
118 sal_Bool IsSet() const
120 return !m_aStr.isEmpty();
122 sal_Bool ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm );
123 sal_Bool WriteSvIdl( SvStringHashEntry * pName, SvStream & rOutStm,
124 sal_uInt16 nTab );
128 class SvNumberIdentifier : public SvIdentifier
130 sal_uInt32 nValue;
131 // must not be used
132 sal_Bool ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm );
133 public:
134 SvNumberIdentifier() : nValue( 0 ) {};
135 sal_Bool IsSet() const
137 return SvIdentifier::IsSet() || nValue != 0;
139 sal_uInt32 GetValue() const { return nValue; }
140 void SetValue( sal_uInt32 nVal ) { nValue = nVal; }
142 friend SvStream& operator << (SvStream &, const SvNumberIdentifier &);
143 friend SvStream& operator >> (SvStream &, SvNumberIdentifier &);
144 sal_Bool ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm );
145 sal_Bool ReadSvIdl( SvIdlDataBase &, SvStringHashEntry * pName,
146 SvTokenStream & rInStm );
150 class SvString
152 private:
153 OString m_aStr;
154 public:
155 SvString() {}
156 void setString(const OString& rStr)
158 m_aStr = rStr;
160 const OString& getString() const
162 return m_aStr;
164 sal_Bool IsSet() const
166 return !m_aStr.isEmpty();
168 friend SvStream& operator << (SvStream &, const SvString &);
169 friend SvStream& operator >> (SvStream &, SvString &);
171 sal_Bool ReadSvIdl( SvStringHashEntry * pName, SvTokenStream & rInStm );
172 sal_Bool WriteSvIdl( SvStringHashEntry * pName, SvStream & rOutStm,
173 sal_uInt16 nTab );
177 class SvHelpText : public SvString
179 public:
180 SvHelpText() {}
181 sal_Bool ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm );
182 sal_Bool WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm,
183 sal_uInt16 nTab );
187 class SvHelpContext : public SvNumberIdentifier
191 class SvUUId : public SvGlobalName
193 public:
194 SvUUId() {}
195 sal_Bool ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm );
196 sal_Bool WriteSvIdl( SvStream & rOutStm );
200 class SvVersion
202 sal_uInt16 nMajorVersion;
203 sal_uInt16 nMinorVersion;
204 public:
205 SvVersion() : nMajorVersion( 1 ), nMinorVersion( 0 ) {}
206 sal_Bool operator == ( const SvVersion & r )
208 return (r.nMajorVersion == nMajorVersion)
209 && (r.nMinorVersion == nMinorVersion);
211 sal_Bool operator != ( const SvVersion & r )
213 return !(*this == r);
216 sal_uInt16 GetMajorVersion() const { return nMajorVersion; }
217 sal_uInt16 GetMinorVersion() const { return nMinorVersion; }
219 friend SvStream& operator << (SvStream &, const SvVersion &);
220 friend SvStream& operator >> (SvStream &, SvVersion &);
221 sal_Bool ReadSvIdl( SvTokenStream & rInStm );
222 sal_Bool WriteSvIdl( SvStream & rOutStm );
226 #endif // _BASTYPE_HXX
228 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */