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