Make UNKNOWN_RULE the default value of connectivity::OSQLParseNode::Rule
Change-Id: I4e56da8820d5c92d3b6e2ff2c749bdc0cef46d73
This commit is contained in:
@@ -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
|
||||
|
@@ -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 )
|
||||
{
|
||||
|
Reference in New Issue
Block a user