void CStdUtilsTestDlg::OnTestStrings() 
{
	unsigned char iUChar = 1;
	unsigned short iUShort=5;
	int iInt = 10;
	long lLong = 15;
	float fltFloat = (float) 5.3;
	double dblDouble = 7.5;
	bool bBool = true;

try
{
//	LOG_TEMP(StdLogInfo, "Test Val %d, Float: %f", 5403, dblDouble);

	CStdString strVal;

	strVal = (int) iUChar;
	strVal = iUShort;
	strVal = iInt;
	strVal = lLong;
	strVal = fltFloat;
	strVal = dblDouble;

	CStdString strUShort(iUShort), strInt(iInt), strLong(lLong);
	CStdString strFloat(fltFloat), strDouble(dblDouble);
	CStdString strTest1("The Test value is : ");
	CStdString strTest2(" Is the test value.");

	strVal = strTest1 + STR(iInt);
	strVal = strTest1 + STR(lLong);
	strVal = strTest1 + STR(fltFloat);
	strVal = strTest1 + STR(dblDouble);

	strVal = STR(iInt) + strTest2;
	strVal = STR(lLong) + strTest2;
	strVal = STR(fltFloat) + strTest2;
	strVal = STR(dblDouble) + strTest2;

	strVal = "This is a test: " + STR(iInt);
	strVal = "This is a test: " + STR(lLong);
	strVal = "This is a test: " + STR(fltFloat);
	strVal = "This is a test: " + STR(bBool);
	strVal = "This is a test: " + STR("100");

	TRACE_INFO("This is a test. Test Value: " + STR(lLong));
	TRACE_DETAIL("Fitness: " + STR(fltFloat));

	strVal = "This is a test: " + FSTR("%5.2f", fltFloat);

	Test1();
}
catch(CStdErrorInfo oError)
{
	CStdString strError = oError.Log();
	CString strMSError = strError.c_str();
	AfxMessageBox(strMSError);
}
catch(...)
{AfxMessageBox("Unidentified Error");}
}
示例#2
0
GR_COLOR
GrGetColorByName(char *colorname, int *retr, int *retg, int *retb)
{
	FILE *fp;
	unsigned int r = 0, g = 0, b = 0;
	char buf[256];

	fp = fopen(X11_RGBTXT, "r");
	if (!fp)
		return 0;

	while (fgets(buf, 256, fp) != NULL) {
		if (buf[0] != '!') {
			char *p;
			char name[256];
	
			p = strInt(&r, buf);
			p = strInt(&g, p);
			p = strInt(&b, p);
			strEol(name, p);

			if (strcasecmp(name, colorname) == 0) {
				if (retr)
					*retr = r;
				if (retg)
					*retg = g;
				if (retb)
					*retb = b;
				return GR_RGB(r, g, b);
			}
		}
	}
	fclose(fp);

	return 0;
}