Example #1
0
void CMVPeriod::read_body(wistream& s)
{
	CMString str,token,token2;
	str = GetAssociation(L"yearend");
	int yearend = str.length() ? CMTime::Month(str.c_str()) : 12;
	if (IsType(L"trace"))
		traceno = 1;
	else {
		str = GetAssociation(L"trace");
		traceno = str.length() ? _wtoi(str.c_str()) : 0;
	}
	if (IsType(L"alwaysdraw") || IsType(L"monthly")) // LEGACY
		periodstate |= forceEvaluation;
	periodformat = -1;
	array.ResetAndDestroy(1);
	while(!s.eof()) {
		str.read_line(s);
		if (str.is_null() || str[0] == L'*')
			continue;
		if (str(0,wcslen(vardef_end)) == vardef_end)
			break;
		CMTokenizer next(str);
		token = next();
		token2 = next(L"\r\n");
		switch (token.length()) {
			case 1:
			case 2:
				SetExpression(CMTime(2000,_wtoi(token.c_str())),token2.c_str());
				if (periodformat<0) periodformat = CMTime::MM;
				break;
			case 4:
				{
				int yr = _wtoi(token.c_str());
				CMTime t((yearend<12)?(yr-1):yr,yearend%12+1);
				SetExpression(t,token2.c_str());
				if (periodformat<0) periodformat = CMTime::YYYY;
				}
				break;
			case 6:
				if (periodformat<0) periodformat = CMTime::YYYYMM;
			case 8:
				if (periodformat<0) periodformat = CMTime::YYYYMMDD;
			case 10:
				if (periodformat<0) periodformat = CMTime::YYYYMMDDHH;
			case 12:
				if (periodformat<0) periodformat = CMTime::YYYYMMDDHHMM;
			default:
				if (periodformat<0) periodformat = CMTime::YYYYMMDDHHMMSS;
				SetExpression(CMTime(token),token2.c_str());
				break;
		}
	}
	array.Resize(array.Count());
}
Example #2
0
void ParserMgr::InitParsers()
{
#ifdef DEBUG_PM_FUNC
    ScopeTracker st("ParserMgr::InitParsers", std::this_thread::get_id());
#endif
    try
    {
        VecStr expressions;
        for (size_t i=0; i<ds::NUM_MODELS; ++i)
        {
            const ParamModelBase* model = _modelMgr->Model((ds::PMODEL)i);
            if (model->DoEvaluate())
            {
                VecStr model_exprns = model->Expressions();
                expressions.insert(expressions.end(),
                                       model_exprns.begin(),
                                       model_exprns.end());
            }
        }
        SetExpression(expressions);
            //Note that the expressions are not actually evaluated at this point
    }
    catch (mu::ParserError& e)
    {
        _log->AddExcept("ParserMgr::InitParsers: " + std::string(e.GetMsg()));
    }
}
Example #3
0
int MathFunction::SetElementData(MBS* mbs, ElementDataContainer& edc) //set element data according to ElementDataContainer
{
    int rv = 1;

    int udf = 0; //user defined function
    GetElemDataBool(mbs, edc, "user_defined_function", udf, 0); //do not warn, if not exists
    if (udf) return rv; //this case is not treated!

    int piecewise_mode;
    Vector t, u, v;
    GetElemDataInt(mbs, edc, "piecewise_mode", piecewise_mode, 1);
    GetElemDataVector(mbs, edc, "piecewise_points", t, 1);
    GetElemDataVector(mbs, edc, "piecewise_values", u, 1);
    GetElemDataVector(mbs, edc, "piecewise_diff_values", v, 1);

    mystr pf, pfp;
    GetElemDataText(mbs, edc, "parsed_function", pf, 1);
    GetElemDataText(mbs, edc, "parsed_function_parameter", pfp, 1);

    if (piecewise_mode == 0) {
        SetPiecewise(t, u, 0);
    }
    else if (piecewise_mode == 1) {
        SetPiecewise(t, u, 1);
    }
    else if (piecewise_mode == 2) {
        SetPiecewiseQuadratic(t, u, v);
    }
    else
    {
        SetExpression(pf, pfp,mbs);
    }

    return rv;
}
Example #4
0
void CMVSingleExpression::read_body(wistream& s)
{
	CMString str;
	CMString expr;

	while(!s.eof()) {
		str.read_line(s);
		if (str.is_null() || str[0] == L'*')
			continue;
		if (str(0,wcslen(vardef_end)) == vardef_end)
			break;
		expr += str.strip(CMString::stripType::Trailing, L'\r');
	}
	SetExpression(expr.c_str());
	if (expression.Fail()) {
		SetState(vsFailed,1);
     	ReportError(XBadVardef,expression.GetString());
	}
}
Example #5
0
 unsigned int SetExpression(const std::string& s, bool icase = false){ return SetExpression(s.c_str(), icase); }
Example #6
0
RegEx& RegEx::operator=(const char* p)
{
   JM_GUARD_STACK
   SetExpression(p, false);
   return *this;
}
Example #7
0
RegEx::RegEx(const JM_STD::string& s, bool icase)
{
   JM_GUARD_STACK
   pdata = new RegExData();
   SetExpression(s.c_str(), icase);
}
Example #8
0
RegEx::RegEx(const char* c, bool icase)
{
   JM_GUARD_STACK
   pdata = new RegExData();
   SetExpression(c, icase);
}