Skip to content
Snippets Groups Projects
Commit 88fab669 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Macroprocessor: length() operator called on a string returns the number of characters

Closes DynareTeam/Dynare#1547
parent 5f1465f9
Branches
Tags
No related merge requests found
...@@ -329,6 +329,12 @@ StringMV::print() ...@@ -329,6 +329,12 @@ StringMV::print()
return "'" + value + "'"; return "'" + value + "'";
} }
shared_ptr<IntMV>
StringMV::length() noexcept(false)
{
return make_shared<IntMV>(value.length());
}
FuncMV::FuncMV(vector<string> args_arg, string body_arg) : FuncMV::FuncMV(vector<string> args_arg, string body_arg) :
args{move(args_arg)}, body{move(body_arg)} args{move(args_arg)}, body{move(body_arg)}
{ {
......
...@@ -161,6 +161,7 @@ public: ...@@ -161,6 +161,7 @@ public:
//! Returns underlying string value //! Returns underlying string value
string toString() override; string toString() override;
string print() override; string print() override;
shared_ptr<IntMV> length() noexcept(false) override;
}; };
class FuncMV : public MacroValue class FuncMV : public MacroValue
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment