summaryrefslogtreecommitdiffstats
path: root/connectivity
diff options
context:
space:
mode:
authorLionel Elie Mamane <lionel@mamane.lu>2013-01-23 15:19:07 +0100
committerLionel Elie Mamane <lionel@mamane.lu>2013-01-23 16:32:52 +0100
commit22fef9910ecfcbbd7bd4c4c8268be2c4b4a5a96a (patch)
tree0defd227a7fcf270ed9d2fc3e05e5c8b2eb257ca /connectivity
parentConverted Table-> Autofit-> Row Height widget (diff)
downloadcore-22fef9910ecfcbbd7bd4c4c8268be2c4b4a5a96a.tar.gz
core-22fef9910ecfcbbd7bd4c4c8268be2c4b4a5a96a.zip
Make UNKNOWN_RULE the default value of connectivity::OSQLParseNode::Rule
Change-Id: I4e56da8820d5c92d3b6e2ff2c749bdc0cef46d73
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/inc/connectivity/sqlnode.hxx8
-rw-r--r--connectivity/source/parse/sqlnode.cxx12
2 files changed, 13 insertions, 7 deletions
diff --git a/connectivity/inc/connectivity/sqlnode.hxx b/connectivity/inc/connectivity/sqlnode.hxx
index e21e06e31515..4082375051fb 100644
--- a/connectivity/inc/connectivity/sqlnode.hxx
+++ b/connectivity/inc/connectivity/sqlnode.hxx
@@ -130,7 +130,10 @@ namespace connectivity
public:
enum Rule
{
- select_statement = 0,
+ UNKNOWN_RULE = 0, // ID indicating that a node is no rule with a matching Rule-enum value (see getKnownRuleID)
+ // we make sure it is 0 so that it is the default-constructor value of this enum
+ // and std::map<foo,Rule>::operator[](bar) default-inserts UNKNOWN_RULE rather than select_statement (!)
+ select_statement,
table_exp,
table_ref_commalist,
table_ref,
@@ -229,8 +232,7 @@ namespace connectivity
other_like_predicate_part_2,
between_predicate_part_2,
cast_spec,
- rule_count, // last value
- UNKNOWN_RULE = -1 // ID indicating that a node is no rule with a matching Rule-enum value (see getKnownRuleID)
+ rule_count // last value
};
// must be ascii encoding for the value
diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx
index ae9f3f1fe72a..ca2281a0708a 100644
--- a/connectivity/source/parse/sqlnode.cxx
+++ b/connectivity/source/parse/sqlnode.cxx
@@ -59,6 +59,7 @@
#include <tools/diagnose_ex.h>
#include <string.h>
#include <boost/bind.hpp>
+#include <boost/static_assert.hpp>
#include <algorithm>
#include <functional>
#include <rtl/logfile.hxx>
@@ -1289,8 +1290,9 @@ OSQLParser::OSQLParser(const ::com::sun::star::uno::Reference< ::com::sun::star:
if(!s_xLocaleData.is())
s_xLocaleData = LocaleData::create(m_xContext);
- // reset to 0
- memset(OSQLParser::s_nRuleIDs,0,sizeof(OSQLParser::s_nRuleIDs[0]) * (OSQLParseNode::rule_count+1));
+ // reset to UNKNOWN_RULE
+ BOOST_STATIC_ASSERT(OSQLParseNode::UNKNOWN_RULE==0);
+ memset(OSQLParser::s_nRuleIDs,0,sizeof(OSQLParser::s_nRuleIDs));
struct
{
@@ -1398,8 +1400,10 @@ OSQLParser::OSQLParser(const ::com::sun::star::uno::Reference< ::com::sun::star:
{ OSQLParseNode::between_predicate_part_2, "between_predicate_part_2" },
{ OSQLParseNode::cast_spec, "cast_spec" }
};
- size_t nRuleMapCount = sizeof( aRuleDescriptions ) / sizeof( aRuleDescriptions[0] );
- OSL_ENSURE( nRuleMapCount == size_t( OSQLParseNode::rule_count ), "OSQLParser::OSQLParser: added a new rule? Adjust this map!" );
+ const size_t nRuleMapCount = sizeof( aRuleDescriptions ) / sizeof( aRuleDescriptions[0] );
+ // added a new rule? Adjust this map!
+ // +1 for UNKNOWN_RULE
+ BOOST_STATIC_ASSERT( nRuleMapCount + 1 == static_cast<size_t>(OSQLParseNode::rule_count) );
for ( size_t mapEntry = 0; mapEntry < nRuleMapCount; ++mapEntry )
{