Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

skParseException.h

00001 /*
00002   Copyright 1996-2003
00003   Simon Whiteside
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Lesser General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Lesser General Public License for more details.
00014 
00015     You should have received a copy of the GNU Lesser General Public
00016     License along with this library; if not, write to the Free Software
00017     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00019   $Id: skParseException_8h-source.html,v 1.7 2004/12/17 21:31:15 sdw Exp $
00020 */
00021 #ifndef SKPARSEEXCEPTION_H
00022 #define SKPARSEEXCEPTION_H
00023 
00024 #include "skException.h"
00025 #include "skString.h"
00026 #include "skValist.h"
00027 #include "skStringBuffer.h"
00028 xskNAMED_LITERAL(QuoteStart,skSTR(" near \""));
00029 xskNAMED_LITERAL(QuoteEnd,skSTR("\""));
00033 class CLASSEXPORT skCompileError
00034 {
00035  public:
00039   skCompileError() 
00040     : m_LineNum(0){
00041   }
00045   skCompileError(const skCompileError& e) 
00046     : m_LineNum(e.m_LineNum),m_LexBuffer(e.m_LexBuffer),m_Msg(e.m_Msg){
00047   }
00051   skCompileError(skString location,int line_num,const skString& msg,const skString& lex_buffer)
00052     : m_LineNum(line_num),m_Location(location),m_LexBuffer(lex_buffer),m_Msg(msg){
00053   }
00057   skCompileError& operator=(const skCompileError& e){
00058     m_LineNum=e.m_LineNum;
00059     m_Msg=e.m_Msg;
00060     m_LexBuffer=e.m_LexBuffer;
00061     return *this;
00062   }
00066   skString location() const{
00067     return m_Location;
00068   }
00072   int lineNum() const{
00073     return m_LineNum;
00074   }
00078   skString msg() const{
00079     return m_Msg;
00080   }
00084   skString lexBuffer() const{
00085     return m_LexBuffer;
00086   }
00090   skString toString() const {
00091     return skString::addStrings(m_Location.ptr(),s_colon,skString::from(m_LineNum).ptr(),s_colon,m_Msg.ptr(),s_QuoteStart,m_LexBuffer.ptr(),s_QuoteEnd);
00092   }
00096   bool operator==(const skCompileError& err) const {
00097     return m_Msg==err.m_Msg;
00098   }
00099  private:
00100   int m_LineNum;
00101   skString m_Location;
00102   skString m_LexBuffer;
00103   skString m_Msg;
00104 };
00105 #ifdef INSTANTIATE_TEMPLATES
00106 EXTERN_TEMPLATE template class CLASSEXPORT skTVAList<skCompileError>;
00107 #endif
00108 
00111 class CLASSEXPORT skCompileErrorList : public skTVAList<skCompileError> 
00112 {
00113 };
00117 class CLASSEXPORT skParseException : public skException
00118 {
00119  public:
00123   skParseException(){
00124   }
00128   void setErrors(const skCompileErrorList& errors){
00129     m_Errors=errors;
00130   }
00134   const skCompileErrorList& getErrors() const{
00135     return m_Errors;
00136   }
00140   skString getMessage() const {
00141     skString ret;
00142     if (m_Errors.entries())
00143       ret=m_Errors[0].msg();
00144     return ret;
00145   }
00150   skString toString() const {
00151     skStringBuffer ret(50);
00152     for (unsigned int i=0;i<m_Errors.entries();i++){
00153       ret.append(m_Errors[i].toString());
00154       ret.append(skSTR("\n"));
00155     }
00156     return ret.toString();
00157   }
00158  private:
00159   skCompileErrorList m_Errors;
00160 };
00161 
00162 #endif

Generated on Fri Dec 17 20:28:26 2004 for Simkin C++ for Symbian by doxygen1.3