summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qlparser/querytree.cc17
-rw-r--r--qlparser/querytree.hh10
-rw-r--r--raslib/error.cc4
-rw-r--r--raslib/error.hh4
4 files changed, 34 insertions, 1 deletions
diff --git a/qlparser/querytree.cc b/qlparser/querytree.cc
index 4a14ed6..412a2a5 100644
--- a/qlparser/querytree.cc
+++ b/qlparser/querytree.cc
@@ -160,6 +160,9 @@ QueryTree::optimize( unsigned int currentOptimizationLevel )
}
}
+ if (isValidOptimizationLevel(currentOptimizationLevel) == false)
+ throw r_Error(r_Error::r_Error_InvalidOptimizationLevel);
+
optimizationFnc(currentOptimizationLevel, rootNode);
RMDBGIF( 1, RMDebug::module_qlparser, "QueryTree", \
@@ -487,3 +490,17 @@ void QueryTree::rewriteDomainObjects(r_Minterval *greatDomain, string *greatIter
void QueryTree::addCString( char *str ) {
lexedCStringList.push_back( str );
}
+
+bool QueryTree::isValidOptimizationLevel( int level )
+{
+ switch (level)
+ {
+ case STANDARDIZATION:
+ case SIMPLIFICATION:
+ case SUBEXPRESSIONS:
+ return true;
+
+ default:
+ return false;
+ }
+}
diff --git a/qlparser/querytree.hh b/qlparser/querytree.hh
index d6f28cc..cfeafb7 100644
--- a/qlparser/querytree.hh
+++ b/qlparser/querytree.hh
@@ -84,6 +84,13 @@ class QueryTree
public:
+ enum OptimizationLevel
+ {
+ STANDARDIZATION = 1,
+ SIMPLIFICATION = 2,
+ SUBEXPRESSIONS = 3
+ };
+
/// default constructor
QueryTree();
@@ -198,6 +205,9 @@ class QueryTree
static void (*optimizationFnc)(unsigned int, QtNode*);
+ // Validity checks for the level of optimization
+ bool isValidOptimizationLevel( int level );
+
/// used by public seeSubexpression()
vector<QtNode::QtNodeList>* seeSubexpression( QtNode::QtNodeList* leafList );
diff --git a/raslib/error.cc b/raslib/error.cc
index 1ccc3cc..6647847 100644
--- a/raslib/error.cc
+++ b/raslib/error.cc
@@ -438,6 +438,10 @@ r_Error::setErrorTextOnKind()
strcpy(buffer, "Memory allocation failed");
break;
+ case r_Error_InvalidOptimizationLevel:
+ strcpy(buffer, "Illegal value for optimization level");
+ break;
+
default:
strcpy(buffer, "not specified");
break;
diff --git a/raslib/error.hh b/raslib/error.hh
index 074c37d..0042596 100644
--- a/raslib/error.hh
+++ b/raslib/error.hh
@@ -145,7 +145,9 @@ class r_Error : public std::exception
r_Error_AccesDenied,
r_Error_SystemOverloaded,
- r_Error_MemoryAllocation
+ r_Error_MemoryAllocation,
+
+ r_Error_InvalidOptimizationLevel
};