ControlReference: hide parse_error behind GetParseStatus()

This commit is contained in:
Michael Maltese 2016-12-09 13:19:23 -08:00
parent 9a632ea7b9
commit 492d5b6ac7
3 changed files with 12 additions and 5 deletions

View File

@ -326,7 +326,7 @@ void ControlDialog::UpdateGUI()
m_bound_label->SetLabel(
wxString::Format(_("Bound Controls: %lu"), (unsigned long)control_reference->BoundCount()));
switch (control_reference->parse_error)
switch (control_reference->GetParseStatus())
{
case EXPRESSION_PARSE_SYNTAX_ERROR:
m_error_label->SetLabel(_("Syntax error"));
@ -391,8 +391,8 @@ bool ControlDialog::Validate()
UpdateGUI();
return (control_reference->parse_error == EXPRESSION_PARSE_SUCCESS ||
control_reference->parse_error == EXPRESSION_PARSE_NO_DEVICE);
return (control_reference->GetParseStatus() == EXPRESSION_PARSE_SUCCESS ||
control_reference->GetParseStatus() == EXPRESSION_PARSE_NO_DEVICE);
}
void InputConfigDialog::SetDevice(wxCommandEvent&)

View File

@ -33,13 +33,14 @@ void ControlReference::UpdateReference(ciface::Core::DeviceContainer& devices,
parsed_expression = nullptr;
ControlFinder finder(devices, default_device, IsInput());
parse_error = ParseExpression(expression, finder, &parsed_expression);
m_parse_status = ParseExpression(expression, finder, &parsed_expression);
}
ControlReference::~ControlReference()
{
delete parsed_expression;
}
int ControlReference::BoundCount() const
{
if (parsed_expression)
@ -48,6 +49,11 @@ int ControlReference::BoundCount() const
return 0;
}
ExpressionParseStatus ControlReference::GetParseStatus() const
{
return m_parse_status;
}
ControlReference::ControlReference() : range(1), parsed_expression(nullptr)
{
}

View File

@ -29,16 +29,17 @@ public:
virtual bool IsInput() const = 0;
int BoundCount() const;
ciface::ExpressionParser::ExpressionParseStatus GetParseStatus() const;
void UpdateReference(ciface::Core::DeviceContainer& devices,
const ciface::Core::DeviceQualifier& default_device);
ControlState range;
std::string expression;
ciface::ExpressionParser::ExpressionParseStatus parse_error;
protected:
ControlReference();
ciface::ExpressionParser::Expression* parsed_expression;
ciface::ExpressionParser::ExpressionParseStatus m_parse_status;
};
//