Github user phrocker commented on a diff in the pull request:

    https://github.com/apache/nifi-minifi-cpp/pull/188#discussion_r153900948
  
    --- Diff: extensions/expression-language/Expression.cpp ---
    @@ -0,0 +1,164 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +#include <utility>
    +#include <iostream>
    +
    +#include <expression/Expression.h>
    +#include "Driver.h"
    +
    +namespace org {
    +namespace apache {
    +namespace nifi {
    +namespace minifi {
    +namespace expression {
    +
    +Expression compile(const std::string &expr_str) {
    +  std::stringstream expr_str_stream(expr_str);
    +  Driver driver(&expr_str_stream);
    +  Parser parser(&driver);
    +  parser.parse();
    +  return driver.result;
    +}
    +
    +Expression make_static(std::string val) {
    +  return Expression(std::move(val));
    +}
    +
    +Expression make_dynamic(std::function<std::string(const Parameters 
&params)> val_fn) {
    +  return Expression("", std::move(val_fn));
    +}
    +
    +Expression make_dynamic_attr(const std::string &attribute_id) {
    +  return make_dynamic([attribute_id](const Parameters &params) -> 
std::string {
    +    std::string result;
    +    params.flow_file.lock()->getAttribute(attribute_id, result);
    +    return std::move(result);
    --- End diff --
    
    This will not allow for RVO


---

Reply via email to