Skip to content
Permalink
Browse files

Better Updates to nodes, and passing live output of regexp's. Still i…

…ncomplete. Some other bugfixes.
  • Loading branch information
nfomon committed Oct 30, 2015
1 parent c698019 commit 25e09be6eeb20ab037627dcedbc648e54fe02e22
Showing with 29 additions and 11 deletions.
  1. +20 −2 istatik/ParserWindow.cpp
  2. +1 −0 statik/IncParser.cpp
  3. +2 −3 statik/OutputFunc.cpp
  4. +6 −6 statik/Regexp.cpp
@@ -38,7 +38,12 @@ ParserWindow::~ParserWindow() {
WindowResponse ParserWindow::Input(const Batch& ibatch) {
g_log.info() << "Updating incParser " << m_incParser.Name() << " with batch: " << ibatch.Print();
m_incParser.ApplyBatch(ibatch);
const statik::STree& root = m_incParser.GetRoot();
WindowResponse response;
if (root.GetState().IsBad()) {
g_log.debug() << " - Not extracting output, because root is bad!";
return response;
}
// Find first item in incParser's output list, and draw everything
response.actions.push_back(WindowAction(WindowAction::MOVE, 0, 0, 0));
Batch batch;
@@ -138,8 +143,18 @@ WindowResponse ParserWindow::Input(const Batch& ibatch) {
}
break;

case Batch::OP_UPDATE:
g_log.debug() << "Update node: " << i->node->name << ":" << i->node->value;
case Batch::OP_UPDATE: {
g_log.debug() << "Update node: " << i->node->name << ":" << i->node->value;
/*
node_mod_iter node_i = m_nodeMap.find(i->node);
if (m_nodeMap.end() == node_i) {
throw ISError("Received invalid node for Update");
}
List* node = node_i->second;
g_log.debug() << "Update node: " << node->name << ":" << node->value << " -> " << i->node->name << ":" << i->node->value;
node->value = i->node->value;
*/
}
break;
default:
throw ISError("Unknown batch operation " + Batch::UnMapBatchOp(i->op));
@@ -157,6 +172,9 @@ WindowResponse ParserWindow::Input(const Batch& ibatch) {
m_str += " ";
}
m_str += node->name;
/*if (!node->value.empty()) {
m_str += "[" + node->value + "]";
}*/
node = node->right;
}
g_log.info() << "Printing str: '" << m_str << "'";
@@ -346,6 +346,7 @@ void IncParser::UpdateNode(List& inode) {
for (listener_iter i = listeners.begin(); i != listeners.end(); ++i) {
Enqueue(ParseAction(ParseAction::INodeUpdate, **i, inode));
}
ProcessActions();
}

void IncParser::ProcessActions() {
@@ -141,7 +141,6 @@ void OutputFunc_IValues::operator() () {
if (m_output.empty()) {
m_output.push_back(OutputItem(m_onode));
}
/*
string value;
const List* ilast = NULL;
if (m_node->GetState().IsComplete()) {
@@ -150,8 +149,8 @@ void OutputFunc_IValues::operator() () {
for (const List* i = &m_node->IStart(); i != ilast; i = i->right) {
value += i->value;
}
m_state.value = value;
*/
m_onode.value = value;
//g_log.debug() << "VALUE: " << m_onode.value;
}

auto_ptr<OutputFunc> OutputFunc_IValues::Clone() {
@@ -47,13 +47,13 @@ void ParseFunc_Regexp::operator() (ParseAction::Action action, const List& inode
if (boost::regex_match(str, m_regex)) {
state.GoDone();
// keep going if possible, in case we can get complete
} else if (str.size() > 1 && boost::regex_match(str.begin(), str.end()-1, m_regex)) {
state.GoComplete();
break;
} else if (boost::regex_match(str, m_regex, boost::match_partial)) {
state.GoDone();
// keep going if possible, in case we can get done or complete
} else {
if (str.size() > 1) {
if (boost::regex_match(str.begin(), str.end()-1, m_regex)) {
state.GoComplete();
break;
}
}
state.GoBad();
break;
}

0 comments on commit 25e09be

Please sign in to comment.
You can’t perform that action at this time.