当前位置: 首页>>代码示例>>C++>>正文


C++ TVar::asInteger方法代码示例

本文整理汇总了C++中TVar::asInteger方法的典型用法代码示例。如果您正苦于以下问题:C++ TVar::asInteger方法的具体用法?C++ TVar::asInteger怎么用?C++ TVar::asInteger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TVar的用法示例。


在下文中一共展示了TVar::asInteger方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CompAB

bool CompAB(const TVar& a, const TVar& b, TVarFuncCmp fcmp)
{
	bool r = true;
	__int64 bi;
	double bd;

	switch (a.vType)
	{
		case vtUnknown:
		case vtInteger:

			switch (b.vType)
			{
				case vtUnknown:
				case vtInteger: r = fcmp(vtInteger,&a.inum,&b.inum); break;
				case vtDouble:  r = fcmp(vtDouble,&a.inum,&b.dnum);  break;
				case vtString:
				{
					switch (checkTypeString(b.asString()))
					{
						case tsStr:   r = fcmp(vtString,a.asString().data(),b.str.data()); break;
						case tsInt:   bi=b.asInteger(); r = fcmp(vtInteger,&a.inum,&bi);  break;
						case tsFloat: bd=b.asDouble(); r = fcmp(vtDouble,&a.inum,&bd);   break;
					}

					break;
				}
			}

			break;
		case vtDouble:

			switch (b.vType)
			{
				case vtUnknown:
				case vtInteger: r = fcmp(vtInteger,&a.dnum,&b.inum); break;
				case vtDouble:  r = fcmp(vtDouble,&a.dnum,&b.dnum);  break;
				case vtString:
				{
					switch (checkTypeString(b.str))
					{
						case tsStr:   r = fcmp(vtString,a.asString().data(),b.str.data()); break;
						case tsInt:
						case tsFloat: bd=b.asDouble(); r = fcmp(vtDouble,&a.inum,&bd);   break;
					}

					break;
				}
			}

			break;
		case vtString:
		{
			r = fcmp(vtString,a.asString().data(),b.asString().data());
			break;
		}
	}

	return r;
};
开发者ID:chapgaga,项目名称:farmanager,代码行数:60,代码来源:tvar.cpp

示例2: if

TVar operator%(const TVar& a, const TVar& b)
{
	TVar r;

	switch (a.vType)
	{
		case vtUnknown:
		case vtInteger:
		{
			switch (b.vType)
			{
				case vtUnknown:
				case vtInteger: r = b.inum ? (a.inum % b.inum) : 0; break;
				case vtDouble:  r = fabs(b.dnum) > DBL_EPSILON? fmod((double)a.inum, b.dnum) : 0.0; break;
				case vtString:
				{
					switch (checkTypeString(b.str))
					{
						case tsStr:   r = a;     break;
						case tsInt:
						{
							__int64 bi=b.asInteger();
							r = bi ? a.inum % bi : 0; break;
						}
						case tsFloat:
						{
							double bd=b.asDouble();
							r = fabs(bd) > DBL_EPSILON? fmod((double)a.inum, bd) : 0.0; break;
						}
					}

					break;
				}
			}

			break;
		}
		case vtDouble:
		{
			switch (b.vType)
			{
				case vtUnknown:
				case vtInteger: r = b.inum ? fmod(a.dnum,(double)b.inum) : 0.0; break;
				case vtDouble:  r = fabs(b.dnum) > DBL_EPSILON? fmod(a.dnum,b.dnum) : 0.0; break;
				case vtString:
				{
					switch (checkTypeString(b.str))
					{
						case tsStr:   r = a;     break;
						case tsInt:
						case tsFloat:
						{
							double bd=b.asDouble();
							r = fabs(bd) > DBL_EPSILON? fmod(a.dnum, bd) : 0.0; break;
						}
					}

					break;
				}
			}

			break;
		}
		case vtString:
		{
			TypeString tsA=checkTypeString(a.str),tsB;

			if (b.vType == vtInteger || b.vType == vtUnknown)
				tsB=tsInt;
			else if (b.vType == vtDouble)
				tsB=tsFloat;
			else
				tsA=tsB=tsStr;

			if ((tsA == tsStr && tsB == tsStr) || (tsA != tsStr && tsB == tsStr) || (tsA == tsStr && tsB != tsStr))
				r = a;
			else if (tsA == tsInt && tsB == tsInt)
			{
				__int64 bi=b.asInteger();
				r = bi ? (a.asInteger() % bi) : 0;
			}
			else
			{
				double bd=b.asDouble();
				r = fabs(bd) > DBL_EPSILON? fmod(a.asDouble() , bd) : 0.0;
			}

			break;
		}
	}

	return r;
};
开发者ID:chapgaga,项目名称:farmanager,代码行数:93,代码来源:tvar.cpp


注:本文中的TVar::asInteger方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。