Skip to main content
Question

Evaluate an expression in a C++ plugin

  • March 9, 2016
  • 3 replies
  • 19 views

ahuarte47
Contributor
Forum|alt.badge.img+3

Hi all, I am developing a C++ plugin with a new IFMEDevFactory.

The "processClause" method of the factory gets an attribute (TEXT_OR_ATTR-type) as an encoded string:

@EvaluateExpression(FDIV,STRING,<at>Value<openparen>mypath<closeparen>,MyModule)

How do I evaluate this to resolve the real "mypath" value?

Thanks in advance!

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

3 replies

david_r
Celebrity
  • March 9, 2016

Hi

I do not have first-hand experience with the C++ API, but in Python it could perhaps look something like this:

import fmeobjects
encoded_text = '@EvaluateExpression(FDIV,STRING,<at>Value<openparen>mypath<closeparen>,MyModule)'
decoded_text = fmeobjects.FMESession().decodeFromFMEParsableText(encoded_text)
mypath = my_feature.performFunction(decoded_text)

It seems that the method decodeFromFMEParsableText() is located in IFMEString in the C++ libraries, however.

Hope this gives you some ideas.

David


ahuarte47
Contributor
Forum|alt.badge.img+3
  • Author
  • Contributor
  • March 9, 2016

Thanks a lot david!!!! It works for me.

My plugin is a mixed CLI/C++ DLL, the code ....

// Expand expressions of Keywords ?
for each (String^ key in gcnew List<String^>(static_cast<IDictionary<String^,String^>^>(_keywords)->Keys))
{
  String^ value = _keywords->default[key];

  if (value->Contains("@"))
  {
    std::string tempString = msclr::interop::marshal_as<std::string>( value );
    IFMEString* v = _fmeSession->createString();
    IFMEString* r = _fmeSession->createString();

    *v = tempString.c_str(); 
    v->decodeFromFMEParsableText();

    FME_MsgNum rs = feature->performFunction(*v, *r);
    if (rs==FME_SUCCESS)
    {
      _keywords->default[key] = gcnew String(r->data());
    }
    _fmeSession->destroyString(v);
    _fmeSession->destroyString(r);
  }
}

Alvaro


david_r
Celebrity
  • March 9, 2016

Thanks a lot david!!!! It works for me.

My plugin is a mixed CLI/C++ DLL, the code ....

// Expand expressions of Keywords ?
for each (String^ key in gcnew List<String^>(static_cast<IDictionary<String^,String^>^>(_keywords)->Keys))
{
  String^ value = _keywords->default[key];

  if (value->Contains("@"))
  {
    std::string tempString = msclr::interop::marshal_as<std::string>( value );
    IFMEString* v = _fmeSession->createString();
    IFMEString* r = _fmeSession->createString();

    *v = tempString.c_str(); 
    v->decodeFromFMEParsableText();

    FME_MsgNum rs = feature->performFunction(*v, *r);
    if (rs==FME_SUCCESS)
    {
      _keywords->default[key] = gcnew String(r->data());
    }
    _fmeSession->destroyString(v);
    _fmeSession->destroyString(r);
  }
}

Alvaro

Glad to hear you found a solution! Thanks for posting the working code as well.