GME  13
OCLException.cpp
Go to the documentation of this file.
00001 //###############################################################################################################################################
00002 //
00003 //      Object Constraint Language Generic Manager
00004 //      OCLException.cpp
00005 //
00006 //###############################################################################################################################################
00007 #include "Solve4786.h"
00008 #include "OCLException.h"
00009 
00010 //###############################################################################################################################################
00011 //
00012 //      M E S S A G E   C O N S T A N T S
00013 //
00014 //###############################################################################################################################################
00015 
00016 const char* ErrorMessages[] = {
00017 
00018         "Type [ ? ] does not exist.",
00019         "Type [ ? ] is ambiguous.",
00020         "BaseType of types [ ? , ? ] does not exist.",
00021         "Operator [ ? ] is ambiguous.",
00022         "Operator [ ? ] does not exist.",
00023         "Function [ ? ] is ambiguous.",
00024         "Function [ ? ] does not exist.",
00025         "Attribute [ ? ] is ambiguous.",
00026         "Attribute [ ? ] does not exist.",
00027         "Association [ ? ] is ambiguous. If you did not, then use qualifier.",
00028         "Association [ ? ] does not exist.",
00029         "Method [ ? ] is ambiguous.",
00030         "Method [ ? ] does not exist.",
00031         "Iterator [ ? ] is ambiguous.",
00032         "Iterator [ ? ] does not exist.",
00033         "TypeSequence [ ? ] is invalid.",
00034         "Type [ ? ] is not compound.",
00035         "Variable [ ? ] already exists.",
00036         "Root expression has to return type [ ocl::Boolean ].",
00037         "Then and Else braches of If statement returns different types [ ? , ? ].",
00038         "Invalid type cast. Object of type [ ? ] is not an instance of type [ ? ].",
00039         "Operator is not implemented.",
00040         "Member selection operator [ \"?\" ] is invalid.",
00041         "Iterator is not implemented.",
00042         "On literals of type [ ? ] member selection operator cannot be used.",
00043         "Method [ ? ] and Iterator [ ? ] are ambiguous. Use \"self\" or variable and member selection operator.",
00044         "Method is not implemented.",
00045         "Function is not implemented.",
00046         "Association is not implemented.",
00047         "Attribute is not implemented.",
00048         "Attribute [ ? ] and Association [ ? ] are ambiguous. Use \"self\", variable and member selection operator or qualifier.",
00049         "Variable [ ? ] does not exist.",
00050         "Literal of type [ ? ] with value [ ? ] cannot be created.",
00051         "Collection literal of compound type [ ? ] cannot be created.",
00052         "Attribute [ ? ] and Attribute [ ? ] are ambiguous. Use \"self\" or variable and member selection operator.",
00053         "Type [ ? ] is not compound and does not have Iterator.",
00054         "Type [ ? ] is compound and does not have Association.",
00055         "Iterators has exactly one argument.",
00056         "Constraint definition has to have a Type to return.",
00057         "Root expression has to return Type [ ? ]. Type [ ? ] is not appropriate.",
00058         "Constraint definition [ ? ] failed.",
00059         "Assignment is invalid. Type [ ? ] of right-value does not conform to Type [ ? ] of left-value.",
00060         "Type cast is invalid. Types [ ? , ? ] do not conform to each other.",
00061         "Implicit Iterator [ ? ] does not exist. ",
00062         "Neither Function, implicit Method nor implicit Iterator [ ? ] exists.",
00063         "Implicit Association [ ? ] does not exist.",
00064         "Neither Type, Variable, implicit Attribute nor implicit Association [ ? ] exists.",
00065         "Stop evaluation."
00066 };
00067 
00068 namespace OclCommon
00069 {
00070 
00071 //###############################################################################################################################################
00072 //
00073 //      C L A S S : Exception
00074 //
00075 //###############################################################################################################################################
00076 
00077         std::string Exception::GGetMessage()
00078         {
00079                 std::string strMessage = m_strMessage;
00080                 if ( m_iCode != - 1 ) {
00081                         switch ( m_eType ) {
00082                                 case ET_SYNTACTIC       :
00083                                 case ET_SEMANTIC        :
00084                                 case ET_RUNTIME         :
00085                                 case ET_WARNING         : strMessage = ErrorMessages[ m_iCode - 100 ]; break;
00086                         }
00087                 }
00088                 unsigned int iCnt = 0;
00089                 size_t iPos = strMessage.find( '?' );
00090                 while ( iPos != std::string::npos && iCnt < m_vecParameters.size() ) {
00091                         strMessage = strMessage.substr( 0, iPos ) + m_vecParameters[ iCnt++ ] + strMessage.substr( iPos + 1, strMessage.length() - iPos - 1 );
00092                         iPos = strMessage.find( '?' );
00093                 }
00094                 return strMessage;
00095         }
00096 
00097 }; // namespace OclCommon