Example #1
0
double TEnv::GetIfArgPrefixFlt(const TStr& PrefixStr,
                               const double& DfVal,
                               const TStr& DNm) const {
    if (Env.GetArgs() <= MnArgs) {
        // 'usage' argument message
        if (!SilentP) {
            printf("   %s%s (default:%g)\n", PrefixStr.CStr(),
                   DNm.CStr(), DfVal);
        }
        return DfVal;
    } else {
        // argument & value message
        double Val;
        if (Env.IsArgPrefix(PrefixStr)) {
            TStr ValStr = Env.GetArgPostfix(PrefixStr);
            Val = ValStr.GetFlt(DfVal);
        } else {
            Val = DfVal;
        }
        TStr MsgStr =
            DNm + " (" + PrefixStr + ")=" + TFlt::GetStr(Val);
        if (!SilentP) {
            TNotify::OnStatus(Notify, MsgStr);
        }
        return Val;
    }
}
Example #2
0
int ParseArgument(const TStr& arg, const TStr& argType, PyObject** argPy)
{
	if (argType == "int")
	{
		*argPy = PyLong_FromLong(arg.GetInt());
	}
	else if (argType == "double")
	{
		*argPy = PyFloat_FromDouble(arg.GetFlt());
	}
	else if (argType == "string")
	{
		*argPy = PyUnicode_FromString(arg.CStr());
	}
	if (!*argPy) {
        fprintf(stderr, "Cannot convert argument\n");
        return 0;
    }
	return 1;
}
Example #3
0
double TSAppSrvFun::GetFldFlt(const TStrKdV& FldNmValPrV, const TStr& FldNm, const double& DefFlt) {
	if (!IsFldNm(FldNmValPrV, FldNm)) { return DefFlt; }
	TStr IntStr = GetFldVal(FldNmValPrV, FldNm, "");
	EAssertR(IntStr.IsFlt(), "Parameter '" + FldNm + "' not a number");
	return IntStr.GetFlt();
}