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

Closes DynareTeam/Dynare#1547
issue#70
Sébastien Villemot 2018-07-25 18:42:23 +02:00
parent 5f1465f9d1
commit 88fab669c6
2 changed files with 7 additions and 0 deletions

View File

@ -329,6 +329,12 @@ StringMV::print()
return "'" + value + "'";
}
shared_ptr<IntMV>
StringMV::length() noexcept(false)
{
return make_shared<IntMV>(value.length());
}
FuncMV::FuncMV(vector<string> args_arg, string body_arg) :
args{move(args_arg)}, body{move(body_arg)}
{

View File

@ -161,6 +161,7 @@ public:
//! Returns underlying string value
string toString() override;
string print() override;
shared_ptr<IntMV> length() noexcept(false) override;
};
class FuncMV : public MacroValue