]> git.tdb.fi Git - builder.git/blobdiff - source/booleanevaluator.cpp
Use format() when creating strings from more than two parts
[builder.git] / source / booleanevaluator.cpp
index 6891abceff9a8088db506c6ea1388664830fb4f1..58a6fcf1a682b53aa0c6ef54627a9f7729f7eecd 100644 (file)
@@ -1,7 +1,9 @@
 #include <stdexcept>
+#include <msp/strings/format.h>
 #include "booleanevaluator.h"
 
 using namespace std;
+using namespace Msp;
 
 BooleanEvaluator::BooleanEvaluator(const ValueFunction &f):
        func([&f](const string &value, const string *){ return f(value); }),
@@ -51,7 +53,7 @@ bool BooleanEvaluator::evaluate(const string &str)
                        else if(ops.find(*i)!=string::npos)
                                push_op(*i);
                        else
-                               throw runtime_error("syntax error at "+string(1, *i));
+                               throw runtime_error(format("syntax error at %c", *i));
                }
        }
 
@@ -67,7 +69,7 @@ bool BooleanEvaluator::evaluate(const string &str)
 void BooleanEvaluator::push_op(char op)
 {
        if(last_was_op!=is_unary(op))
-               throw runtime_error("syntax error at "+string(1, op));
+               throw runtime_error(format("syntax error at %c", op));
        // TODO Disallow mixing of ! and =/^
        if(is_logic(op) && !var_stack.empty())
                value_stack.push_back(pop_value());