xref: /aoo41x/main/rsc/inc/rscerror.h (revision 24c56ab9)
19eab2a37SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
39eab2a37SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
49eab2a37SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
59eab2a37SAndrew Rist  * distributed with this work for additional information
69eab2a37SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
79eab2a37SAndrew Rist  * to you under the Apache License, Version 2.0 (the
89eab2a37SAndrew Rist  * "License"); you may not use this file except in compliance
99eab2a37SAndrew Rist  * with the License.  You may obtain a copy of the License at
109eab2a37SAndrew Rist  *
119eab2a37SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
129eab2a37SAndrew Rist  *
139eab2a37SAndrew Rist  * Unless required by applicable law or agreed to in writing,
149eab2a37SAndrew Rist  * software distributed under the License is distributed on an
159eab2a37SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
169eab2a37SAndrew Rist  * KIND, either express or implied.  See the License for the
179eab2a37SAndrew Rist  * specific language governing permissions and limitations
189eab2a37SAndrew Rist  * under the License.
199eab2a37SAndrew Rist  *
209eab2a37SAndrew Rist  *************************************************************/
219eab2a37SAndrew Rist 
229eab2a37SAndrew Rist 
23cdf0e10cSrcweir #ifndef _RSCERROR_H
24cdf0e10cSrcweir #define _RSCERROR_H
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #ifndef _TOOLS_SOLAR_H
27cdf0e10cSrcweir #include <tools/solar.h>
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir 
30*24c56ab9SHerbert Dürr #include <rtl/string.hxx>
31*24c56ab9SHerbert Dürr 
32cdf0e10cSrcweir /****************** D E F I N I T I O N S ********************************/
33cdf0e10cSrcweir /******************* R e t u r n   E r r o r s		   *******************/
34cdf0e10cSrcweir #define ERR_OK				0xFFFFFFFF
35cdf0e10cSrcweir 
36cdf0e10cSrcweir #define ERR_ERROR			0x0100
37cdf0e10cSrcweir #define ERR_UNKNOWN_METHOD	0x0101	// Return
38cdf0e10cSrcweir #define ERR_OPENFILE		0x0102	// Return
39cdf0e10cSrcweir #define ERR_NOCHAR			0x0103	// Return
40cdf0e10cSrcweir #define ERR_NORSCINST		0x0104	// Return
41cdf0e10cSrcweir #define ERR_USAGE			0x0105	//
42cdf0e10cSrcweir #define ERR_NOINPUT 		0x0106	// Return
43cdf0e10cSrcweir #define ERR_UNKNOWNSW		0x0107	//
44cdf0e10cSrcweir #define ERR_REFTODEEP		0x0108	// Return
45cdf0e10cSrcweir #define ERR_FILEFORMAT		0x0109	// Return
46cdf0e10cSrcweir #define ERR_FILESIZE		0x010A	// Return
47cdf0e10cSrcweir #define ERR_RENAMEFILE		0x010B	// Return
48cdf0e10cSrcweir #define ERR_NOIMAGE			0x010C	// Return
49cdf0e10cSrcweir 
50cdf0e10cSrcweir #define ERR_RSCRANGE		0x0200	// Return
51cdf0e10cSrcweir #define ERR_RSCRANGE_OUTDEFSET	(ERR_RSCRANGE +1 )
52cdf0e10cSrcweir 
53cdf0e10cSrcweir #define ERR_RSCENUM 		0x0210	// Return
54cdf0e10cSrcweir #define ERR_RSCFLAG 		0x0220	// Return
55cdf0e10cSrcweir #define ERR_RSCCONT 		0x0240	// Return
56cdf0e10cSrcweir #define ERR_CONT_INVALIDPOS 	(ERR_RSCCONT +1 ) // Return
57cdf0e10cSrcweir #define ERR_CONT_INVALIDTYPE	(ERR_RSCCONT +2 ) // Return
58cdf0e10cSrcweir 
59cdf0e10cSrcweir #define ERR_RSCCMPED		0x0250
60cdf0e10cSrcweir #define ERR_RSCINST 		0x0260
61cdf0e10cSrcweir #define ERR_RSCINST_NOVARNAME	(ERR_RSCINST +1 ) // Return
62cdf0e10cSrcweir #define ERR_RSCINST_RESERVEDNAME (ERR_RSCINST +2 ) // Return
63cdf0e10cSrcweir 
64cdf0e10cSrcweir #define ERR_LEX 			0x0270
65cdf0e10cSrcweir #define ERR_YACC			0x0280	//
66cdf0e10cSrcweir #define ERR_DOUBLEID			(ERR_YACC	 +1 ) //
67cdf0e10cSrcweir #define ERR_FALSETYPE			(ERR_YACC	 +2 ) //
68cdf0e10cSrcweir #define ERR_NOVARIABLENAME		(ERR_YACC	 +3 ) //
69cdf0e10cSrcweir #define ERR_USHORTRANGE 		(ERR_YACC	 +4 ) //
70cdf0e10cSrcweir #define ERR_IDRANGE 			(ERR_YACC	 +5 ) //
71cdf0e10cSrcweir #define ERR_NOCOPYOBJ			(ERR_YACC	 +6 ) //
72cdf0e10cSrcweir #define ERR_REFNOTALLOWED		(ERR_YACC	 +7 ) // Return
73cdf0e10cSrcweir #define ERR_DOUBLEDEFINE		(ERR_YACC	 +8 ) //
74cdf0e10cSrcweir #define ERR_COPYNOTALLOWED		(ERR_YACC	 +9 ) //
75cdf0e10cSrcweir #define ERR_IDEXPECTED			(ERR_YACC	 +10) //
76cdf0e10cSrcweir #define ERR_ZERODIVISION		(ERR_YACC	 +11) //
77cdf0e10cSrcweir #define ERR_PRAGMA				(ERR_YACC	 +12) //
78cdf0e10cSrcweir #define ERR_DECLAREDEFINE		(ERR_YACC	 +13) //
79cdf0e10cSrcweir #define ERR_NOTUPELNAME 		(ERR_YACC	 +14) //
80cdf0e10cSrcweir #define ERR_NOTYPE				(ERR_YACC	 +15) //
81cdf0e10cSrcweir 
82cdf0e10cSrcweir #define ERR_RSCARRAY		 0x02A0  // Return
83cdf0e10cSrcweir #define ERR_ARRAY_INVALIDINDEX	(ERR_RSCARRAY +1 ) // Return
84cdf0e10cSrcweir 
85cdf0e10cSrcweir #define ERR_ERROREND				0x1000
86cdf0e10cSrcweir 
87cdf0e10cSrcweir #define ERR_WARNINGSTART		0x1001
88cdf0e10cSrcweir #define WRN_LOCALID 			(ERR_WARNINGSTART +1 )
89cdf0e10cSrcweir #define WRN_GLOBALID			(ERR_WARNINGSTART +2 )
90cdf0e10cSrcweir #define WRN_SUBINMEMBER 		(ERR_WARNINGSTART +3 )
91cdf0e10cSrcweir #define WRN_CONT_NOID			(ERR_WARNINGSTART +4 )
92cdf0e10cSrcweir #define WRN_STR_REFNOTFOUND 	(ERR_WARNINGSTART +5 )
93cdf0e10cSrcweir #define WRN_MGR_REFNOTFOUND 	(ERR_WARNINGSTART +6 )
94cdf0e10cSrcweir #define WRN_CONT_DOUBLEID		(ERR_WARNINGSTART +7 )
95cdf0e10cSrcweir 
96cdf0e10cSrcweir #define ERR_WARNINGEND		0x2000
97cdf0e10cSrcweir 
98cdf0e10cSrcweir class ERRTYPE {
99cdf0e10cSrcweir 	sal_uInt32	nError;
100cdf0e10cSrcweir public:
ERRTYPE()101cdf0e10cSrcweir 	ERRTYPE()				 { nError = ERR_OK; }
ERRTYPE(sal_uInt32 nErr)102cdf0e10cSrcweir 	ERRTYPE( sal_uInt32 nErr )	 { nError = nErr; }
ERRTYPE(const ERRTYPE & rErr)103cdf0e10cSrcweir 	ERRTYPE( const ERRTYPE & rErr ) { nError = rErr.nError; };
104cdf0e10cSrcweir 	ERRTYPE& operator = ( const ERRTYPE & rError );
operator sal_uInt32() const105cdf0e10cSrcweir 	operator  sal_uInt32() const { return( nError ); }
IsError() const106cdf0e10cSrcweir 	sal_Bool IsError() const	 { return( nError <= ERR_ERROREND ); }
IsOk() const107cdf0e10cSrcweir 	sal_Bool IsOk() const		 { return( !IsError() ); }
IsWarning() const108cdf0e10cSrcweir 	sal_Bool IsWarning() const	 {
109cdf0e10cSrcweir 		return( nError >= ERR_WARNINGSTART && nError <= ERR_WARNINGEND );
110cdf0e10cSrcweir 	};
Clear()111cdf0e10cSrcweir 	void	Clear(){ nError = ERR_OK; }
112cdf0e10cSrcweir };
113cdf0e10cSrcweir 
114cdf0e10cSrcweir /****************** R s c E r r o r **************************************/
115cdf0e10cSrcweir class RscId;
116cdf0e10cSrcweir class RscTop;
117cdf0e10cSrcweir 
118cdf0e10cSrcweir enum RscVerbosity
119cdf0e10cSrcweir {
120cdf0e10cSrcweir     RscVerbositySilent = 0,
121cdf0e10cSrcweir     RscVerbosityNormal = 1,
122cdf0e10cSrcweir     RscVerbosityVerbose = 2
123cdf0e10cSrcweir };
124cdf0e10cSrcweir 
125cdf0e10cSrcweir class RscError
126cdf0e10cSrcweir {
127cdf0e10cSrcweir 	FILE *	fListing;
128cdf0e10cSrcweir     RscVerbosity m_verbosity;
129cdf0e10cSrcweir 
130cdf0e10cSrcweir 	void WriteError( const ERRTYPE& rError, const char * pMessage );
131cdf0e10cSrcweir 	void StdLstOut( const char * pStr );
132cdf0e10cSrcweir 	void StdLstErr( const char * pStr );
133cdf0e10cSrcweir 	void ErrorFormat( const ERRTYPE& rError, RscTop * pClass,
134cdf0e10cSrcweir 					  const RscId & aId );
135cdf0e10cSrcweir public:
136cdf0e10cSrcweir 	sal_uInt32	nErrors;// Anzahl der Fehler
RscError(RscVerbosity _verbosity)137cdf0e10cSrcweir 					RscError( RscVerbosity _verbosity ) {
138cdf0e10cSrcweir 						fListing = NULL;
139cdf0e10cSrcweir 						nErrors = 0;
140cdf0e10cSrcweir                         m_verbosity = _verbosity;
141cdf0e10cSrcweir 					};
SetListFile(FILE * fList)142cdf0e10cSrcweir 	void			SetListFile( FILE * fList ){
143cdf0e10cSrcweir 						fListing = fList;
144cdf0e10cSrcweir 					};
GetListFile()145cdf0e10cSrcweir 	FILE *			GetListFile(){
146cdf0e10cSrcweir 						return fListing;
147cdf0e10cSrcweir 					};
GetVerbosity() const148cdf0e10cSrcweir     RscVerbosity    GetVerbosity() const { return m_verbosity; }
149cdf0e10cSrcweir 	virtual void	StdOut( const char *, const RscVerbosity _verbosityLevel = RscVerbosityNormal );
150cdf0e10cSrcweir 	virtual void	StdErr( const char * );
151cdf0e10cSrcweir 	virtual void	LstOut( const char * );
152cdf0e10cSrcweir 	virtual void	Error( const ERRTYPE& rError, RscTop* pClass, const RscId &aId,
153cdf0e10cSrcweir 						   const char * pMessage = NULL );
154cdf0e10cSrcweir 	// Dieser Fehler sollte nur im Compilermodus auftreten,
155cdf0e10cSrcweir 	// das Programm wird mit exit() verlassen
156cdf0e10cSrcweir 	virtual void	FatalError( const ERRTYPE& rError, const RscId &aId,
157cdf0e10cSrcweir 								const char * pMessage = NULL );
Error(const ERRTYPE & rError,RscTop * pClass,const RscId & rId,const rtl::OString & rStr)158*24c56ab9SHerbert Dürr 	void Error( const ERRTYPE& rError, RscTop* pClass, const RscId& rId, const rtl::OString& rStr ) { this->Error( rError, pClass, rId, rStr.getStr()); }
FatalError(const ERRTYPE & rError,const RscId & rId,const rtl::OString & rStr)159*24c56ab9SHerbert Dürr 	void FatalError( const ERRTYPE& rError, const RscId& rId, const rtl::OString& rStr ) { this->FatalError( rError,rId, rStr.getStr()); }
160cdf0e10cSrcweir };
161cdf0e10cSrcweir 
162cdf0e10cSrcweir #endif // _RSCERROR_H
163