diff options
author | Noel Grandin <noel@peralex.com> | 2016-02-24 14:02:06 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2016-02-25 13:50:24 +0200 |
commit | 6a9046d02e17a7dd0997aa3a041d468be9d8f80b (patch) | |
tree | 22caf4c1ed549be92eaffc8a88fd848ee9dc30db | |
parent | aef004cea8e7b93f84c13292a009e689f99383d8 (diff) |
convert ErrorCode to scoped enum
Change-Id: I37d2dd0b84fce229b548bbe941cfdd1169170af9
-rw-r--r-- | connectivity/source/parse/sqlbison.y | 38 | ||||
-rw-r--r-- | connectivity/source/parse/sqliterator.cxx | 16 | ||||
-rw-r--r-- | connectivity/source/parse/sqlnode.cxx | 18 | ||||
-rw-r--r-- | dbaccess/source/core/api/SingleSelectQueryComposer.cxx | 2 | ||||
-rw-r--r-- | include/connectivity/IParseContext.hxx | 28 | ||||
-rw-r--r-- | svx/source/form/ParseContext.cxx | 26 |
6 files changed, 64 insertions, 64 deletions
diff --git a/connectivity/source/parse/sqlbison.y b/connectivity/source/parse/sqlbison.y index 0b657fd74264..c9f8bbadc68c 100644 --- a/connectivity/source/parse/sqlbison.y +++ b/connectivity/source/parse/sqlbison.y @@ -4305,26 +4305,26 @@ OParseContext::~OParseContext() OUString OParseContext::getErrorMessage(ErrorCode _eCode) const { - OUString aMsg; - switch (_eCode) - { - case ERROR_GENERAL: aMsg = "Syntax error in SQL expression"; break; - case ERROR_VALUE_NO_LIKE: aMsg = "The value #1 can not be used with LIKE."; break; - case ERROR_FIELD_NO_LIKE: aMsg = "LIKE can not be used with this field."; break; - case ERROR_INVALID_COMPARE: aMsg = "The entered criterion can not be compared with this field."; break; - case ERROR_INVALID_INT_COMPARE: aMsg = "The field can not be compared with a number."; break; - case ERROR_INVALID_DATE_COMPARE: aMsg = "The field can not be compared with a date."; break; - case ERROR_INVALID_REAL_COMPARE: aMsg = "The field can not be compared with a floating point number."; break; - case ERROR_INVALID_TABLE_NOSUCH: aMsg = "The database does not contain a table named \"#\"."; break; - case ERROR_INVALID_TABLE_OR_QUERY: aMsg = "The database does contain neither a table nor a query named \"#\"."; break; - case ERROR_INVALID_COLUMN: aMsg = "The column \"#1\" is unknown in the table \"#2\"."; break; - case ERROR_INVALID_TABLE_EXIST: aMsg = "The database already contains a table or view with name \"#\"."; break; - case ERROR_INVALID_QUERY_EXIST: aMsg = "The database already contains a query with name \"#\"."; break; + OUString aMsg; + switch (_eCode) + { + case ErrorCode::General: aMsg = "Syntax error in SQL expression"; break; + case ErrorCode::ValueNoLike: aMsg = "The value #1 can not be used with LIKE."; break; + case ErrorCode::FieldNoLike: aMsg = "LIKE can not be used with this field."; break; + case ErrorCode::InvalidCompare: aMsg = "The entered criterion can not be compared with this field."; break; + case ErrorCode::InvalidIntCompare: aMsg = "The field can not be compared with a number."; break; + case ErrorCode::InvalidDateCompare: aMsg = "The field can not be compared with a date."; break; + case ErrorCode::InvalidRealCompare: aMsg = "The field can not be compared with a floating point number."; break; + case ErrorCode::InvalidTableNosuch: aMsg = "The database does not contain a table named \"#\"."; break; + case ErrorCode::InvalidTableOrQuery: aMsg = "The database does contain neither a table nor a query named \"#\"."; break; + case ErrorCode::InvalidColumn: aMsg = "The column \"#1\" is unknown in the table \"#2\"."; break; + case ErrorCode::InvalidTableExist: aMsg = "The database already contains a table or view with name \"#\"."; break; + case ErrorCode::InvalidQueryExist: aMsg = "The database already contains a query with name \"#\"."; break; default: OSL_FAIL( "OParseContext::getErrorMessage: unknown error code!" ); break; - } - return aMsg; + } + return aMsg; } @@ -4585,7 +4585,7 @@ OSQLParseNode* OSQLParser::parseTree(OUString& rErrorMessage, if (m_sErrorMessage.isEmpty()) m_sErrorMessage = s_pScanner->getErrorMessage(); if (m_sErrorMessage.isEmpty()) - m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ERROR_GENERAL); + m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ErrorCode::General); rErrorMessage = m_sErrorMessage; @@ -4747,7 +4747,7 @@ sal_Int16 OSQLParser::buildStringNodes(OSQLParseNode*& pLiteral) } if(SQL_ISRULE(pLiteral,term) || SQL_ISRULE(pLiteral,value_exp_primary)) { - m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ERROR_INVALID_COMPARE); + m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ErrorCode::InvalidCompare); return 0; } return 1; diff --git a/connectivity/source/parse/sqliterator.cxx b/connectivity/source/parse/sqliterator.cxx index a32e5e5ca9f7..309674ef271d 100644 --- a/connectivity/source/parse/sqliterator.cxx +++ b/connectivity/source/parse/sqliterator.cxx @@ -381,9 +381,9 @@ OSQLTable OSQLParseTreeIterator::impl_locateRecordSource( const OUString& _rComp if ( SQL_STATEMENT_CREATE_TABLE == m_eStatementType ) { if ( bQueryDoesExist ) - impl_appendError( IParseContext::ERROR_INVALID_QUERY_EXIST, &sName ); + impl_appendError( IParseContext::ErrorCode::InvalidQueryExist, &sName ); else if ( bTableDoesExist ) - impl_appendError( IParseContext::ERROR_INVALID_TABLE_EXIST, &sName ); + impl_appendError( IParseContext::ErrorCode::InvalidTableExist, &sName ); else aReturn = impl_createTableObject( sName, sCatalog, sSchema ); } @@ -412,15 +412,15 @@ OSQLTable OSQLParseTreeIterator::impl_locateRecordSource( const OUString& _rComp if ( m_pImpl->m_xQueryContainer.is() ) // the connection on which we're working supports sub queries in from (else // m_xQueryContainer would not have been set), so emit a better error message - impl_appendError( IParseContext::ERROR_INVALID_TABLE_OR_QUERY, &sName ); + impl_appendError( IParseContext::ErrorCode::InvalidTableOrQuery, &sName ); else - impl_appendError( IParseContext::ERROR_INVALID_TABLE_NOSUCH, &sName ); + impl_appendError( IParseContext::ErrorCode::InvalidTableNosuch, &sName ); } } } catch(Exception&) { - impl_appendError( IParseContext::ERROR_INVALID_TABLE_NOSUCH, &sComposedName ); + impl_appendError( IParseContext::ErrorCode::InvalidTableNosuch, &sComposedName ); } return aReturn; @@ -860,7 +860,7 @@ void OSQLParseTreeIterator::traverseCreateColumns(const OSQLParseNode* pSelectNo if (!pSelectNode || m_eStatementType != SQL_STATEMENT_CREATE_TABLE || m_pImpl->m_pTables->empty()) { - impl_appendError( IParseContext::ERROR_GENERAL ); + impl_appendError( IParseContext::ErrorCode::General ); return; } if (!SQL_ISRULE(pSelectNode,base_table_element_commalist)) @@ -921,7 +921,7 @@ bool OSQLParseTreeIterator::traverseSelectColumnNames(const OSQLParseNode* pSele if (!pSelectNode || m_eStatementType != SQL_STATEMENT_SELECT || m_pImpl->m_pTables->empty()) { - impl_appendError( IParseContext::ERROR_GENERAL ); + impl_appendError( IParseContext::ErrorCode::General ); return false; } @@ -1653,7 +1653,7 @@ void OSQLParseTreeIterator::appendColumns(::rtl::Reference<OSQLColumns>& _rColum _rColumns->get().push_back(xCol); } else - impl_appendError( IParseContext::ERROR_INVALID_COLUMN, pBegin, &_rTableAlias ); + impl_appendError( IParseContext::ErrorCode::InvalidColumn, pBegin, &_rTableAlias ); } } diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index 1d1638dd1a76..3cddde3044bd 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -849,7 +849,7 @@ OSQLParseNode* OSQLParser::convertNode(sal_Int32 nType, OSQLParseNode* pLiteral) pReturn = buildDate( nType, pReturn); break; default: - m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ERROR_INVALID_COMPARE); + m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ErrorCode::InvalidCompare); break; } break; @@ -862,10 +862,10 @@ OSQLParseNode* OSQLParser::convertNode(sal_Int32 nType, OSQLParseNode* pLiteral) if ( m_xFormatter.is() ) pReturn = buildDate( nType, pReturn); else - m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ERROR_INVALID_DATE_COMPARE); + m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ErrorCode::InvalidDateCompare); break; default: - m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ERROR_INVALID_COMPARE); + m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ErrorCode::InvalidCompare); break; } break; @@ -893,7 +893,7 @@ OSQLParseNode* OSQLParser::convertNode(sal_Int32 nType, OSQLParseNode* pLiteral) pReturn = buildNode_STR_NUM(pReturn); break; default: - m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ERROR_INVALID_INT_COMPARE); + m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ErrorCode::InvalidIntCompare); break; } break; @@ -916,7 +916,7 @@ OSQLParseNode* OSQLParser::convertNode(sal_Int32 nType, OSQLParseNode* pLiteral) break; case DataType::INTEGER: default: - m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ERROR_INVALID_REAL_COMPARE); + m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ErrorCode::InvalidRealCompare); break; } break; @@ -1018,14 +1018,14 @@ sal_Int16 OSQLParser::buildLikeRule(OSQLParseNode* pAppend, OSQLParseNode*& pLit nErg = 1; break; default: - m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ERROR_VALUE_NO_LIKE); + m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ErrorCode::ValueNoLike); m_sErrorMessage = m_sErrorMessage.replaceAt(m_sErrorMessage.indexOf("#1"),2,pLiteral->getTokenValue()); break; } } break; default: - m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ERROR_FIELD_NO_LIKE); + m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ErrorCode::FieldNoLike); break; } return nErg; @@ -1271,7 +1271,7 @@ OSQLParseNode* OSQLParser::predicateTree(OUString& rErrorMessage, const OUString if (m_sErrorMessage.isEmpty()) m_sErrorMessage = s_pScanner->getErrorMessage(); if (m_sErrorMessage.isEmpty()) - m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ERROR_GENERAL); + m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ErrorCode::General); rErrorMessage = m_sErrorMessage; @@ -1569,7 +1569,7 @@ OSQLParseNode* OSQLParser::buildDate(sal_Int32 _nType,OSQLParseNode*& pLiteral) pLiteral = nullptr; if ( !pFCTNode ) - m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ERROR_INVALID_DATE_COMPARE); + m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ErrorCode::InvalidDateCompare); return pFCTNode; } diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx index aaaf28f40a57..ec4ae3ece64c 100644 --- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx +++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx @@ -110,7 +110,7 @@ namespace OUString sSQLStateGeneralError( getStandardSQLState( SQL_GENERAL_ERROR ) ); SQLException aError2( aErrorMsg, _rxContext, sSQLStateGeneralError, 1000, Any() ); SQLException aError1( _rStatement, _rxContext, sSQLStateGeneralError, 1000, makeAny( aError2 ) ); - throw SQLException(_rParser.getContext().getErrorMessage(OParseContext::ERROR_GENERAL),_rxContext,sSQLStateGeneralError,1000,makeAny(aError1)); + throw SQLException(_rParser.getContext().getErrorMessage(OParseContext::ErrorCode::General),_rxContext,sSQLStateGeneralError,1000,makeAny(aError1)); } return pNewSqlParseNode; } diff --git a/include/connectivity/IParseContext.hxx b/include/connectivity/IParseContext.hxx index a7bb4648834a..132bae27b69d 100644 --- a/include/connectivity/IParseContext.hxx +++ b/include/connectivity/IParseContext.hxx @@ -33,22 +33,22 @@ namespace connectivity class IParseContext { public: - enum ErrorCode + enum class ErrorCode { - ERROR_NONE = 0, - ERROR_GENERAL, // "Syntax error in SQL expression" - ERROR_VALUE_NO_LIKE, // "The value #1 can not be used with LIKE." - ERROR_FIELD_NO_LIKE, // "LIKE can not be used with this field." - ERROR_INVALID_COMPARE, // "The entered criterion can not be compared with this field." - ERROR_INVALID_INT_COMPARE, // "The field can not be compared with a number." - ERROR_INVALID_DATE_COMPARE, // "The field can not be compared with a date." - ERROR_INVALID_REAL_COMPARE, // "The field can not be compared with a floating point number." - ERROR_INVALID_TABLE_NOSUCH, // "The database does not contain a table named \"#\"." + None = 0, + General, // "Syntax error in SQL expression" + ValueNoLike, // "The value #1 can not be used with LIKE." + FieldNoLike, // "LIKE can not be used with this field." + InvalidCompare, // "The entered criterion can not be compared with this field." + InvalidIntCompare, // "The field can not be compared with a number." + InvalidDateCompare, // "The field can not be compared with a date." + InvalidRealCompare, // "The field can not be compared with a floating point number." + InvalidTableNosuch, // "The database does not contain a table named \"#\"." // Named like this to avoid conflict with a #define in the Windows system ODBC headers. - ERROR_INVALID_TABLE_OR_QUERY, // "The database does contain neither a table nor a query named \"#\"." - ERROR_INVALID_COLUMN, // "The column \"#1\" is unknown in the table \"#2\"." - ERROR_INVALID_TABLE_EXIST, // "The database already contains a table or view with name \"#\"." - ERROR_INVALID_QUERY_EXIST // "The database already contains a query with name \"#\"."; + InvalidTableOrQuery, // "The database does contain neither a table nor a query named \"#\"." + InvalidColumn, // "The column \"#1\" is unknown in the table \"#2\"." + InvalidTableExist, // "The database already contains a table or view with name \"#\"." + InvalidQueryExist // "The database already contains a query with name \"#\"."; }; enum InternationalKeyCode diff --git a/svx/source/form/ParseContext.cxx b/svx/source/form/ParseContext.cxx index 3333f797771d..b052a8a30deb 100644 --- a/svx/source/form/ParseContext.cxx +++ b/svx/source/form/ParseContext.cxx @@ -58,19 +58,19 @@ OUString OSystemParseContext::getErrorMessage(ErrorCode _eCode) const SolarMutexGuard aGuard; switch (_eCode) { - case ERROR_GENERAL: aMsg = SVX_RESSTR(RID_STR_SVT_SQL_SYNTAX_ERROR); break; - case ERROR_VALUE_NO_LIKE: aMsg = SVX_RESSTR(RID_STR_SVT_SQL_SYNTAX_VALUE_NO_LIKE); break; - case ERROR_FIELD_NO_LIKE: aMsg = SVX_RESSTR(RID_STR_SVT_SQL_SYNTAX_FIELD_NO_LIKE); break; - case ERROR_INVALID_COMPARE: aMsg = SVX_RESSTR(RID_STR_SVT_SQL_SYNTAX_CRIT_NO_COMPARE); break; - case ERROR_INVALID_INT_COMPARE: aMsg = SVX_RESSTR(RID_STR_SVT_SQL_SYNTAX_INT_NO_VALID); break; - case ERROR_INVALID_DATE_COMPARE: aMsg = SVX_RESSTR(RID_STR_SVT_SQL_SYNTAX_ACCESS_DAT_NO_VALID); break; - case ERROR_INVALID_REAL_COMPARE: aMsg = SVX_RESSTR(RID_STR_SVT_SQL_SYNTAX_REAL_NO_VALID); break; - case ERROR_INVALID_TABLE_NOSUCH: aMsg = SVX_RESSTR(RID_STR_SVT_SQL_SYNTAX_TABLE); break; - case ERROR_INVALID_TABLE_OR_QUERY: aMsg = SVX_RESSTR(RID_STR_SVT_SQL_SYNTAX_TABLE_OR_QUERY); break; - case ERROR_INVALID_COLUMN: aMsg = SVX_RESSTR(RID_STR_SVT_SQL_SYNTAX_COLUMN); break; - case ERROR_INVALID_TABLE_EXIST: aMsg = SVX_RESSTR(RID_STR_SVT_SQL_SYNTAX_TABLE_EXISTS); break; - case ERROR_INVALID_QUERY_EXIST: aMsg = SVX_RESSTR(RID_STR_SVT_SQL_SYNTAX_QUERY_EXISTS); break; - case ERROR_NONE: break; + case ErrorCode::General: aMsg = SVX_RESSTR(RID_STR_SVT_SQL_SYNTAX_ERROR); break; + case ErrorCode::ValueNoLike: aMsg = SVX_RESSTR(RID_STR_SVT_SQL_SYNTAX_VALUE_NO_LIKE); break; + case ErrorCode::FieldNoLike: aMsg = SVX_RESSTR(RID_STR_SVT_SQL_SYNTAX_FIELD_NO_LIKE); break; + case ErrorCode::InvalidCompare: aMsg = SVX_RESSTR(RID_STR_SVT_SQL_SYNTAX_CRIT_NO_COMPARE); break; + case ErrorCode::InvalidIntCompare: aMsg = SVX_RESSTR(RID_STR_SVT_SQL_SYNTAX_INT_NO_VALID); break; + case ErrorCode::InvalidDateCompare: aMsg = SVX_RESSTR(RID_STR_SVT_SQL_SYNTAX_ACCESS_DAT_NO_VALID); break; + case ErrorCode::InvalidRealCompare: aMsg = SVX_RESSTR(RID_STR_SVT_SQL_SYNTAX_REAL_NO_VALID); break; + case ErrorCode::InvalidTableNosuch: aMsg = SVX_RESSTR(RID_STR_SVT_SQL_SYNTAX_TABLE); break; + case ErrorCode::InvalidTableOrQuery: aMsg = SVX_RESSTR(RID_STR_SVT_SQL_SYNTAX_TABLE_OR_QUERY); break; + case ErrorCode::InvalidColumn: aMsg = SVX_RESSTR(RID_STR_SVT_SQL_SYNTAX_COLUMN); break; + case ErrorCode::InvalidTableExist: aMsg = SVX_RESSTR(RID_STR_SVT_SQL_SYNTAX_TABLE_EXISTS); break; + case ErrorCode::InvalidQueryExist: aMsg = SVX_RESSTR(RID_STR_SVT_SQL_SYNTAX_QUERY_EXISTS); break; + case ErrorCode::None: break; } return aMsg; } |