void Test() {
  std::string str('x', 4);
  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: constructor parameters are probably swapped [misc-string-constructor]
  std::wstring wstr(L'x', 4);
  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: constructor parameters are probably swapped
  std::string s0(0, 'x');
  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: constructor creating an empty string
  std::string s1(-4, 'x');
  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: negative value used as length parameter
  std::string s2(0x1000000, 'x');
  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: suspicious large length parameter
  
  std::string q0("test", 0);
  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: constructor creating an empty string
  std::string q1(kText, -4);
  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: negative value used as length parameter
  std::string q2("test", 200);
  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: length is bigger then string literal size
  std::string q3(kText, 200);
  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: length is bigger then string literal size
  std::string q4(kText2, 200);
  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: length is bigger then string literal size
  std::string q5(kText3,  0x1000000);
  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: suspicious large length parameter
}
Beispiel #2
0
int main(void)
{
	static const struct st3 a = {1, 2, 3, 4, 5, 6};

	l1(100);
	l2(100, 200);
	l3(100, 200, 300);
	l4(100, 200, 300, 400);
	l5(100, 200, 300, 400, 500);
	l6(100, 200, 300, 400, 500, 600);
	l7(100, 200, 300, 400, 500, 600, 700);
	l8(100, 200, 300, 400, 500, 600, 700, 800);

	d1();
	d2(43);
	d3(100, 200);
	d4(a);
	d5('a', 43, a);
	d6('a', 1);

	c1(44);
	c2(100, 'a', 3.4);
	c3(200, 2.777, 'q');
	c4(200, 1);
	c5(1.1, 2.2);
	c6(1.23, 45.6);
	c7('z', 0x200);

	a1('a');
	a2(10);
	a3(20);
	a4(102030405060LL);

	b1('a', 20);
	b2(30, 'b');
	b3(10, 20, 30, 40, 50, 60);

	s1(sx);
	s1p(&sx);
	s2(sy);
	s3(sz);
	s4(sq);
	s5(sa);
	s6(sb);

	r1();
	r3();
	r4();

	q1(200, sx);
	q2(300, 't', sx);
	q3(400, 410, sy);
	q4(500, 510, sq);
	q5(600, 610, 'z', 'q', sq);

	real1("fresh air");
	real2();

	return 0;
}
Beispiel #3
0
int main()
{
    int array[16] = {1,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0};
    q4(array);
    for (int i = 0; i < 16; i++)
    {
        printf("%d", array[i]);
    }
}
Beispiel #4
0
void q3(char *cad, int *p)
{
	fprintf(stdout, "Q3 cad[%d] - %s\n", *p, cad);
	(*p)--;
	if(cad[*p] == '0')
		q0(cad, p);
	else if(cad[*p] == 'X' || cad[*p] == 'Y' || cad[*p] == '1')
		q3(cad, p);
	else
		q4(cad, p);
}
Beispiel #5
0
void q1(char *cad, int *p)
{
	fprintf(stdout, "Q1 cad[%d] - %s\n", *p, cad);
	(*p)++;
	if(cad[*p] == '1')
		q2(cad, p);
	else if(cad[*p] == 'X' || cad[*p] == 'Y' || cad[*p] == '0')
		q1(cad, p);
	else
		q4(cad, p);
}
Beispiel #6
0
bool Database::createDatabase()
{
	QSqlQuery q0("create table Artist (ID integer primary key autoincrement, value varchar(200), refs integer, rating integer, art varchar(250), mbid varchar(50))", db);
	QSqlQuery q1("create table Album (ID integer primary key autoincrement, value varchar(200), refs integer, rating integer, art varchar(250), artist integer, mbid varchar(50))", db);
	QSqlQuery q2("create table Genre (ID integer primary key autoincrement, value varchar(200), refs integer, rating integer, art varchar(250))", db);
	QSqlQuery q4("create table Song (ID integer primary key autoincrement, File varchar(250), Track integer, Title varchar(200), Artist integer, Album integer, Genre integer, Year integer, Comment varchar(200), Length varchar(20), Rating integer, Type varchar(30), Date varchar(50))", db);
	QSqlQuery q5("create table Version (value integer)", db);
	QSqlQuery q6("insert into Version (value) values ("+QString::number(DB_VERSION)+")", db);
	QSqlQuery q8("create table Info(Mbid varchar(50) primary key, text varchar(10000))", db);
	QSqlQuery q9("create table SQLPlaylist (ID integer primary key autoincrement, value varchar(200), art varchar(250), data varchar(250))", db);
	CreateDefaultSqlPlaylists();
	return true;
}
   void QuatOpsTest::testQuatInvert()
   {
      // test out mult( result, quat, quat )
      const float eps = 0.0001f;
      gmtl::Quat<float> q( 0.2f, 0.33f, 0.44f, 0.101f ), expected_result( -0.567053f, -0.935637f, -1.24752f, 0.286362f );
      gmtl::Quat<float> q2( q );
      gmtl::Quat<float> q3( gmtl::invert( q2 ) );
      CPPUNIT_ASSERT( gmtl::isEqual( expected_result, q3, eps ) );
      CPPUNIT_ASSERT( gmtl::isEqual( expected_result, q2, eps ) );

      gmtl::Quat<float> q4( gmtl::makeInvert( q ) );
      CPPUNIT_ASSERT( gmtl::isEqual( expected_result, q4, eps ) );
   }
Beispiel #8
0
   void QuatGenTest::testQuatMakeInvert()
   {
      // test out mult( result, quat, quat )
      const float eps = 0.0001f;
      gmtl::Quat<float> q( 0.2f, 0.33f, 0.44f, 0.101f ), expected_result( -0.567053f, -0.935637f, -1.24752f, 0.286362f );
      gmtl::Quat<float> q4( gmtl::makeInvert( q ) );
      CPPUNIT_ASSERT( gmtl::isEqual( expected_result, q4, eps ) );

      // make sure set works the same
      /// @todo no impl
      // gmtl::Quat<float> q5;
      //gmtl::setInvert( q5, q );
      //CPPUNIT_ASSERT( gmtl::isEqual( expected_result, q5, eps ) );
   }
Beispiel #9
0
void
QuaternionTest::testConstructor()
{
	xpcc::Vector<float,3> v(1,2,3);
	float mData[] = {1,2,3,4};
	xpcc::Matrix<float, 4, 1> m(mData);
	
	xpcc::Quaternion<float> q0;
	xpcc::Quaternion<float> q1(1,2,3,4);
	xpcc::Quaternion<float> q2(v, M_PI/4);
	xpcc::Quaternion<float> q3(m);
	xpcc::Quaternion<float> q4(q1);
	
	TEST_ASSERT_EQUALS(q0.w, 0);
	TEST_ASSERT_EQUALS(q0.x, 0);
	TEST_ASSERT_EQUALS(q0.y, 0);
	TEST_ASSERT_EQUALS(q0.z, 0);
	
	TEST_ASSERT_EQUALS(q1.w, 1);
	TEST_ASSERT_EQUALS(q1.x, 2);
	TEST_ASSERT_EQUALS(q1.y, 3);
	TEST_ASSERT_EQUALS(q1.z, 4);
	
	TEST_ASSERT_EQUALS_FLOAT(q2.w, cos(M_PI/8));
	TEST_ASSERT_EQUALS_FLOAT(q2.x, 1*sin(M_PI/8));
	TEST_ASSERT_EQUALS_FLOAT(q2.y, 2*sin(M_PI/8));
	TEST_ASSERT_EQUALS_FLOAT(q2.z, 3*sin(M_PI/8));
	
	TEST_ASSERT_EQUALS(q3.w, 1);
	TEST_ASSERT_EQUALS(q3.x, 2);
	TEST_ASSERT_EQUALS(q3.y, 3);
	TEST_ASSERT_EQUALS(q3.z, 4);
	
	TEST_ASSERT_EQUALS(q4.w, 1);
	TEST_ASSERT_EQUALS(q4.x, 2);
	TEST_ASSERT_EQUALS(q4.y, 3);
	TEST_ASSERT_EQUALS(q4.z, 4);
	
	q0.w = 1;
	q0.x = 2;
	q0.y = 3;
	q0.z = 4;
	TEST_ASSERT_EQUALS(q0.w, 1);
	TEST_ASSERT_EQUALS(q0.x, 2);
	TEST_ASSERT_EQUALS(q0.y, 3);
	TEST_ASSERT_EQUALS(q0.z, 4);
	
}
static int test_quat_precision()
{
	int Error(0);
	
	{
		glm::f32quat q1;
		glm::lowp_f32quat qA(q1);
		glm::mediump_f32quat qB(q1);
		glm::highp_f32quat qC(q1);
		glm::f32quat q2(qA);
		glm::f32quat q3(qB);
		glm::f32quat q4(qC);
		
		Error += glm::all(glm::equal(q1, q2)) ? 0 : 1;
		Error += glm::all(glm::equal(q1, q3)) ? 0 : 1;
		Error += glm::all(glm::equal(q1, q4)) ? 0 : 1;
	}

	return Error;
}
TransTable table()
{
	QString t = "t";
	QString n = "n";
	QString d = "d";
	QString c = "c";
	QString lett = QObject::tr("абвгдеёжзийклмнопрстуфхцчшщъыьэюяАБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ")
					+ "_0123456789abefghijklmopqrsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	QString colon = ":";
	QString space = " ";
	QString pipe  = "|";
	QString quote = "\"";
	QString symb = "!\\\"#$%&'()*+,-./;<=>?@[]^`{}~";
	QString eot = "\n\r";

	State q1("Empty");
	State q2("Token");
	State q3("Filter");
	State q4("EndOfFilterItem");
	State q5("FullFilter");
	State q6("WaitFilterSkipNonLetters");

	TransTable table;
	table << q1 << q2 << q3 << q4 << q5 << q6;
	table << Event(t)     << T(C, q2) << T(C, q3) << T(C, q3) << T(N, q4) << T(C, q5) << T(C, q3)
		  << Event(n)     << T(C, q2) << T(C, q3) << T(C, q3) << T(N, q4) << T(C, q5) << T(C, q3)
		  << Event(d)     << T(C, q2) << T(C, q3) << T(C, q3) << T(N, q4) << T(C, q5) << T(C, q3)
		  << Event(c)     << T(C, q2) << T(C, q3) << T(C, q3) << T(N, q4) << T(C, q5) << T(C, q3)
		  << Event(lett)  << T(C, q3) << T(C, q3) << T(C, q3) << T(N, q4) << T(C, q5) << T(C, q3)
		  << Event(colon) << T(N, q1) << T(S, q6) << T(F, q4) << T(N, q4) << T(C, q5) << T(N, q6)
		  << Event(space) << T(N, q1) << T(F, q4) << T(F, q4) << T(N, q4) << T(C, q5) << T(N, q6)
		  << Event(pipe)  << T(N, q1) << T(F, q1) << T(F, q1) << T(N, q1) << T(C, q5) << T(A, q1)
		  << Event(quote) << T(N, q5) << T(F, q4) << T(F, q4) << T(N, q4) << T(F, q4) << T(N, q5)
		  << Event(symb)  << T(N, q1) << T(F, q4) << T(F, q4) << T(N, q4) << T(C, q5) << T(N, q6)
		  << Event(eot)   << T(N, q1) << T(F, q1) << T(F, q1) << T(N, q1) << T(F, q1) << T(N, q1)
		;
	return table;
}
void CTestMessageComposer::SetHeaderL(TInt aNumberofHeaders)
	{
	switch (aNumberofHeaders)
		{
		case 1:	
			{
			// Open strings used in this test	
			//1.Accept header----  Accept: text/html; q=0.8, text/vnd.wap.wml; q=0.2; extended=value, text/*);
			RStringF textHtml = iStringPool.StringF(HTTP::ETextHtml,RHTTPSession::GetTable());
			RStringF textWml  = iStringPool.StringF(HTTP::ETextVndWapWml,RHTTPSession::GetTable());
			RStringF textAny  = iStringPool.StringF(HTTP::ETextAny,RHTTPSession::GetTable());
			RStringF extended  = iStringPool.OpenFStringL(_L8("extended"));
			CleanupClosePushL(extended);
			RStringF extendVal = iStringPool.OpenFStringL(_L8("value"));
			CleanupClosePushL(extendVal);
			iHTTPHeaders = iTransaction.Request().GetHeaderCollection();
			RStringF accept = iStringPool.StringF(HTTP::EAccept,RHTTPSession::GetTable());
			THTTPHdrVal accVal(textHtml);
			THTTPHdrVal q1(THTTPHdrVal::TQConv(0.8));
			iHTTPHeaders.SetFieldL(accept, accVal, iStringPool.StringF(HTTP::EQ,RHTTPSession::GetTable()), q1);
			accVal.SetStrF(textWml);
			q1.SetInt(THTTPHdrVal::TQConv(0.2));
			iHTTPHeaders.SetFieldL(accept, accVal, iStringPool.StringF(HTTP::EQ,RHTTPSession::GetTable()), q1);
			q1.SetStrF(extendVal);
			iHTTPHeaders.SetFieldL(accept, accVal, extended, q1);
			accVal.SetStrF(textAny);
			iHTTPHeaders.SetFieldL(accept, accVal);
			CleanupStack::PopAndDestroy(2, &extended);
		
			//2.Accept-Charset header-- Accept-Charset: iso-8859-5, unicode-1-1; q=0.8
			RStringF iso8859_5 = iStringPool.OpenFStringL(_L8("iso-8859-5"));
			CleanupClosePushL(iso8859_5);
			RStringF unicode1_1  = iStringPool.OpenFStringL(_L8("unicode-1-1"));
			CleanupClosePushL(unicode1_1);
			RStringF accChSet= iStringPool.StringF(HTTP::EAcceptCharset,RHTTPSession::GetTable());
			THTTPHdrVal accChSetVal(iso8859_5);
			iHTTPHeaders.SetFieldL(accChSet, accChSetVal);
			//
			accChSetVal.SetStrF(unicode1_1);
			THTTPHdrVal q2(THTTPHdrVal::TQConv(0.8));
			iHTTPHeaders.SetFieldL(accChSet, accChSetVal, iStringPool.StringF(HTTP::EQ,RHTTPSession::GetTable()), q2);
			CleanupStack::PopAndDestroy(2, &iso8859_5);
			
			//3.User-Agent headers-- User-Agent: CERN-LineMode/2.15 libwww/2.17b3
			// Open strings used in this test
			RStringF ua1Str = iStringPool.OpenFStringL(_L8("CERN-LineMode/2.15"));
			CleanupClosePushL(ua1Str);
			RStringF ua2Str = iStringPool.OpenFStringL(_L8("libwww/2.17b3"));
			CleanupClosePushL(ua2Str);
			//
			RStringF uaStr = iStringPool.StringF(HTTP::EUserAgent,RHTTPSession::GetTable());
			THTTPHdrVal uaVal(ua1Str);
			iHTTPHeaders.SetFieldL(uaStr, uaVal); // sets part 1
			uaVal.SetStrF(ua2Str);
			iHTTPHeaders.SetFieldL(uaStr, uaVal); // sets part 2
			CleanupStack::PopAndDestroy(2,&ua1Str);
			
			//4.Connection Header -- Connection: close, keep-alive
			RStringF otherToken = iStringPool.StringF(HTTP::EKeepAlive,RHTTPSession::GetTable());
			RStringF connStr = iStringPool.StringF(HTTP::EConnection,RHTTPSession::GetTable());
			THTTPHdrVal connVal(iStringPool.StringF(HTTP::EClose,RHTTPSession::GetTable()));
			iHTTPHeaders.SetFieldL(connStr, connVal); // sets part 1
			THTTPHdrVal keepAlive(otherToken);
			iHTTPHeaders.SetFieldL(connStr, keepAlive); // sets part 2
			
			//5.content type header-- Content-Type: text/vnd.wap.wml; charset=utf-8; transcode=yes
			RStringF textWml1   = iStringPool.StringF(HTTP::ETextVndWapWml,RHTTPSession::GetTable());
			RStringF utf8	  = iStringPool.OpenFStringL(_L8("utf-8"));
			CleanupClosePushL(utf8);
			RStringF extended1  = iStringPool.OpenFStringL(_L8("transcode"));
			CleanupClosePushL(extended1);
			RStringF extendVal1 = iStringPool.OpenFStringL(_L8("yes"));
			CleanupClosePushL(extendVal1);
			//
			RStringF contType = iStringPool.StringF(HTTP::EContentType,RHTTPSession::GetTable());
			THTTPHdrVal ctVal(textWml1);
			THTTPHdrVal chSet(utf8);
			iHTTPHeaders.SetFieldL(contType, ctVal, iStringPool.StringF(HTTP::ECharset,RHTTPSession::GetTable()), chSet);
			chSet.SetStrF(extendVal1);
			iHTTPHeaders.SetFieldL(contType, ctVal, extended1, chSet);
			CleanupStack::PopAndDestroy(3,&utf8);
			
			//6.host type header-- Host: nokia.com
			RStringF host1Str = iStringPool.OpenFStringL(_L8("www.nokia.com"));
			CleanupClosePushL(host1Str);
			RStringF host = iStringPool.StringF(HTTP::EHost,RHTTPSession::GetTable());
			THTTPHdrVal hostVal(host1Str);
			iHTTPHeaders.SetFieldL(host, hostVal);
			CleanupStack::PopAndDestroy(&host1Str);
			
			//7.upgrade type header-- Upgrade: HTTP/2.0, SHTTP/1.3
			RStringF http = iStringPool.OpenFStringL(_L8("HTTP/2.0"));
			CleanupClosePushL(http);
			RStringF shttp = iStringPool.OpenFStringL(_L8("SHTTP/1.3"));
			CleanupClosePushL(shttp);
			RStringF upgradeStr = iStringPool.StringF(HTTP::EUpgrade, RHTTPSession::GetTable());
			THTTPHdrVal val(http);
			THTTPHdrVal val2(shttp);
			
			iHTTPHeaders.SetFieldL(upgradeStr, val);
			iHTTPHeaders.SetFieldL(upgradeStr, val2);
			CleanupStack::PopAndDestroy(2);
			
			//8.Cache control -- Cache-Control: public, no-cache=\"wibble,wobble\"
			_LIT8(KPublic, "public");
			_LIT8(KNoCache, "no-cache=\"wibble,wobble\"");
			RStringF publicStr = iStringPool.OpenFStringL(KPublic);
			CleanupClosePushL(publicStr);
			RStringF noCacheStr = iStringPool.OpenFStringL(KNoCache);
			CleanupClosePushL(noCacheStr);
			RStringF cc = iStringPool.StringF(HTTP::ECacheControl,RHTTPSession::GetTable());
			iHTTPHeaders.SetFieldL(cc, THTTPHdrVal(publicStr));
			iHTTPHeaders.SetFieldL(cc, THTTPHdrVal(noCacheStr));
			CleanupStack::PopAndDestroy(2,&publicStr);
			
			//9.Authorization-- Authorization: Basic c3ltYmlhbjpmMXN5bmNtbA==
			RString basicCred = iStringPool.OpenStringL(_L8("c3ltYmlhbjpmMXN5bmNtbA=="));
			CleanupClosePushL(basicCred);
			RStringF authStr = iStringPool.StringF(HTTP::EAuthorization,RHTTPSession::GetTable());
			THTTPHdrVal authVal(iStringPool.StringF(HTTP::EBasic,RHTTPSession::GetTable()));
			iHTTPHeaders.SetFieldL(authStr, authVal); // sets part 1
			THTTPHdrVal credVal(basicCred);
			iHTTPHeaders.SetFieldL(authStr, credVal); // sets part 2
			CleanupStack::PopAndDestroy(&basicCred);
			break;
			}
		
		case 2:	
			{
			//1. Connection: Keep-Alive\r\n
			RStringF keep = iStringPool.StringF(HTTP::EKeepAlive,RHTTPSession::GetTable());
			iHTTPHeaders = iTransaction.Request().GetHeaderCollection();
			RStringF Connection= iStringPool.StringF(HTTP::EConnection,RHTTPSession::GetTable());
			THTTPHdrVal keepalive(keep);
			iHTTPHeaders.SetFieldL(Connection,keepalive);
			
			//2.Host: 192.168.100.100\r\n
			_LIT8(KHostIp, "192.168.100.100");
			RStringF host2Str = iStringPool.OpenFStringL(KHostIp);
			CleanupClosePushL(host2Str);
			RStringF host2= iStringPool.StringF(HTTP::EHost,RHTTPSession::GetTable());
			THTTPHdrVal hostip(host2Str);
			iHTTPHeaders.SetFieldL(host2,hostip);
			CleanupStack::PopAndDestroy(&host2Str);
			//3.Accept: */*\r\n
			_LIT8(KAccept2, "*/*");
			RStringF acceptall = iStringPool.OpenFStringL(KAccept2);
			CleanupClosePushL(acceptall);
			RStringF accept2= iStringPool.StringF(HTTP::EAccept,RHTTPSession::GetTable());
			THTTPHdrVal acceptvalue(acceptall);
			iHTTPHeaders.SetFieldL(accept2,acceptvalue);
			CleanupStack::PopAndDestroy(&acceptall);
			
			//4.Accept-Charset: iso-8859-1,utf-8;q=0.7,*;q=0.7\r\n
			RStringF iso8859 = iStringPool.OpenFStringL(_L8("iso-8859-1"));
			CleanupClosePushL(iso8859);
			RStringF utf8_1  = iStringPool.OpenFStringL(_L8("utf-8"));
			CleanupClosePushL(utf8_1);
			RStringF all  = iStringPool.OpenFStringL(_L8("*"));
			CleanupClosePushL(all);
			RStringF accChSet1= iStringPool.StringF(HTTP::EAcceptCharset,RHTTPSession::GetTable());
			THTTPHdrVal accChSetVal1(iso8859);
			iHTTPHeaders.SetFieldL(accChSet1, accChSetVal1);
			accChSetVal1.SetStrF(utf8_1);
			THTTPHdrVal q3(THTTPHdrVal::TQConv(0.7));
			iHTTPHeaders.SetFieldL(accChSet1, accChSetVal1, iStringPool.StringF(HTTP::EQ,RHTTPSession::GetTable()), q3);
			accChSetVal1.SetStrF(all);
			iHTTPHeaders.SetFieldL(accChSet1, accChSetVal1, iStringPool.StringF(HTTP::EQ,RHTTPSession::GetTable()), q3);	
			CleanupStack::PopAndDestroy(3,&iso8859);
			
			//5.Accept-Encoding: gzip, deflate, x-gzip, identity; q=0.9\r\n
			RStringF gzip = iStringPool.OpenFStringL(_L8("gzip"));
			CleanupClosePushL(gzip);
			RStringF deflate  = iStringPool.OpenFStringL(_L8("deflate"));
			CleanupClosePushL(deflate);
			RStringF xgzip  = iStringPool.OpenFStringL(_L8("x-gzip"));
			CleanupClosePushL(xgzip);
			RStringF identity  = iStringPool.OpenFStringL(_L8("identity"));
			CleanupClosePushL(identity);
			RStringF acceptencoding1= iStringPool.StringF(HTTP::EAcceptEncoding,RHTTPSession::GetTable());
			THTTPHdrVal aevalue(gzip);
			iHTTPHeaders.SetFieldL(acceptencoding1, aevalue);
			aevalue.SetStrF(deflate);
			iHTTPHeaders.SetFieldL(acceptencoding1, aevalue);
			aevalue.SetStrF(xgzip);
			iHTTPHeaders.SetFieldL(acceptencoding1, aevalue);
			aevalue.SetStrF(identity);
			THTTPHdrVal q4(THTTPHdrVal::TQConv(0.9));
			iHTTPHeaders.SetFieldL(acceptencoding1, aevalue, iStringPool.StringF(HTTP::EQ,RHTTPSession::GetTable()), q4);
			CleanupStack::PopAndDestroy(4,&gzip);
			
			//6.Accept-Language: en;q=1.0,bg;q=0.5,nl;q=0.5,fr;q=0.5\r\n
			RStringF en = iStringPool.OpenFStringL(_L8("en"));
			CleanupClosePushL(en);
			RStringF bg  = iStringPool.OpenFStringL(_L8("bg"));
			CleanupClosePushL(bg);
			RStringF nl  = iStringPool.OpenFStringL(_L8("nl"));
			CleanupClosePushL(nl);
			RStringF fr  = iStringPool.OpenFStringL(_L8("fr"));
			CleanupClosePushL(fr);
			RStringF acceptlanguage1= iStringPool.StringF(HTTP::EAcceptLanguage,RHTTPSession::GetTable());
			THTTPHdrVal alvalue(en);
			THTTPHdrVal q5(THTTPHdrVal::TQConv(1.0));
			iHTTPHeaders.SetFieldL(acceptlanguage1, alvalue, iStringPool.StringF(HTTP::EQ,RHTTPSession::GetTable()), q5);
			THTTPHdrVal q6(THTTPHdrVal::TQConv(0.5));
			alvalue.SetStrF(bg);
			iHTTPHeaders.SetFieldL(acceptlanguage1, alvalue, iStringPool.StringF(HTTP::EQ,RHTTPSession::GetTable()), q6);
			alvalue.SetStrF(nl);
			iHTTPHeaders.SetFieldL(acceptlanguage1, alvalue, iStringPool.StringF(HTTP::EQ,RHTTPSession::GetTable()), q6);
			alvalue.SetStrF(fr);
			iHTTPHeaders.SetFieldL(acceptlanguage1, alvalue, iStringPool.StringF(HTTP::EQ,RHTTPSession::GetTable()), q6);
			CleanupStack::PopAndDestroy(4,&en);
		
			//7.Referer: http://192.168.100.100/il/index.html\r\n
			RStringF referer = iStringPool.OpenFStringL(_L8("http://192.168.100.100/il/index.html"));
			CleanupClosePushL(referer);
			RStringF refer= iStringPool.StringF(HTTP::EReferer,RHTTPSession::GetTable());
			THTTPHdrVal referval(referer);
			iHTTPHeaders.SetFieldL(refer,referval);
			CleanupStack::PopAndDestroy(&referer);	
			
			//8.User-Agent: Mozilla/5.0 AppleWebKit/525
			RStringF ua1Str1 = iStringPool.OpenFStringL(_L8("Mozilla/5.0"));
			CleanupClosePushL(ua1Str1);
			RStringF ua2Str2 = iStringPool.OpenFStringL(_L8("AppleWebKit/525"));
			CleanupClosePushL(ua2Str2);
			RStringF uaString = iStringPool.StringF(HTTP::EUserAgent,RHTTPSession::GetTable());
			THTTPHdrVal uaVal1(ua1Str1);
			iHTTPHeaders.SetFieldL(uaString, uaVal1); // sets part 1
			uaVal1.SetStrF(ua2Str2);
			iHTTPHeaders.SetFieldL(uaString, uaVal1); // sets part 2
			CleanupStack::PopAndDestroy(2,&ua1Str1);
			break;
			}
			
		default:
			break;	
		}
	}
Beispiel #13
0
bool Database::updateDatabase(int fromver)
{
    switch (fromver) {
    case 0: {
        QSqlQuery q0("create table Version (value integer)", db);
        //QSqlQuery q1("insert into Version (value) values ("+QString::number(DB_VERSION)+")");
        QSqlQuery q3("alter table Artist add column art varchar(250)", db);
        QSqlQuery q4("alter table Album add column art varchar(250)", db);
        QSqlQuery q5("alter table Genre add column art varchar(250)", db);
        QSqlQuery q6("alter table Song drop column Mark", db);
        QSqlQuery q2("drop table Mark", db);
        qDebug("Update database from version 0");
    }
    case 1: {
        QSqlQuery q0("create table Playlist (ID integer primary key autoincrement, value varchar(200), refs integer, rating integer, art varchar(250), list varchar(250))", db);
        qDebug("Update database from version 1");
    }
    case 2: {
        QSqlQuery q0("alter table Album add column artist integer", db);
        qDebug("Update database from version 2");
        QSqlQuery q1("select distinct Artist, Album from Song", db);
        while(q1.next()) {
            int ar = q1.value(0).toString().toInt();
            QSqlQuery q2("select artist from Album where ID = "+q1.value(1).toString(), db);
            if(q2.next()) {
                int ar2 = q2.value(0).toString().toInt();
                if(!ar2) { // update
                    QSqlQuery q3("update Album set artist = "+q1.value(0).toString()+" where ID = "+q1.value(1).toString(), db);
                } else if(ar2 != ar) { // copy
                    QSqlQuery q4("select value, art, refs, rating from Album where ID = "+q1.value(1).toString()+" and artist = "+q2.value(0).toString(), db);
                    if(q4.next()) {
                        int old_ref = q4.value(2).toString().toInt();
                        int old_rat = q4.value(3).toString().toInt();
                        QSqlQuery q5("insert into Album (value,art,artist) values ('"+q4.value(0).toString()+"','"+q4.value(1).toString()+"',"+q1.value(0).toString(), db);
                        QSqlQuery q6("select ID from Album where value = '"+q4.value(0).toString()+"' and art = '"+q4.value(1).toString()+"' and artist = "+q1.value(0).toString(), db);
                        if(q6.next()) {
                            int id = q6.value(0).toString().toInt();
                            int ref=0, rat=0;
                            QSqlQuery q7("select ID, Rating from Song where Artist = "+q1.value(0).toString()+" and Album = "+q1.value(1).toString(), db);
                            while(q7.next()) {
                                ref ++;
                                rat += q7.value(1).toString().toInt();
                                QSqlQuery q8("update Song set Album = "+QString::number(id)+" where ID = "+q7.value(0).toString(), db);
                            }
                            QSqlQuery q8("update Album set refs = "+QString::number(ref)+", rating = "+QString::number(rat)+" where ID = "+QString::number(id), db);
                            QSqlQuery q9("update Album set refs = "+QString::number(old_ref-ref)+", rating = "+QString::number(old_rat-rat)+" where ID = "+q1.value(1).toString(), db);
                        }
                    }
                }
            }
        }
    }
	case 3: {
		QSqlQuery q0("alter table Artist add column mbid varchar(50)", db);
		QSqlQuery q1("alter table Album add column mbid varchar(50)", db);
		qDebug("Update database from version 3");
	}
	case 4: {
		QSqlQuery q0("create table Info(Mbid varchar(50) primary key, text varchar(10000))", db);
		qDebug("Update database from version 4");
	}
	case 5: {
		QSqlQuery q0("", db);
		q0.prepare("create table SQLPlaylist (ID integer primary key autoincrement, value varchar(200), art varchar(250), data varchar(250))");
		q0.exec();
		CreateDefaultSqlPlaylists();
		qDebug("Update database from version 5");
	}
	case 6: {
		QSqlQuery q0("alter table Song add column Type varchar(30)", db);
		qDebug("Update database from version 6");
	}
	case 7: {
		QSqlDatabase ldb;
		ldb = QSqlDatabase::addDatabase("QSQLITE", "tempLibraryDB");
		ldb.setDatabaseName(QDir::homePath()+"/.cuberok/library.db");
		if(!QFile::exists(ldb.databaseName())) {
			if(!QDir().mkpath(QDir::homePath()+"/.cuberok") || !ldb.open()) {
				qDebug("Can not create library database");
			} else {
				QSqlQuery q0("create table Version (value integer)", ldb);
				QSqlQuery q1("insert into Version (value) values (0)", ldb);
				QSqlQuery q2("create table Playlist (ID integer primary key autoincrement, value varchar(200), refs integer, rating integer, art varchar(250), list varchar(250))", ldb);
				QSqlQuery q("select value, art from Playlist order by value ASC", db);
				q.exec();
				int records = 0;
				while(q.next()) {
					QSqlQuery q3("", ldb);
					q3.prepare("insert into Playlist (value, art) values (:val, :art)");
					q3.bindValue(":val", q.value(0).toString());
					q3.bindValue(":art", q.value(1).toString());
					q3.exec();
					records ++;
				}
				ldb.close();
				qDebug("%d records has been moved", records);
			}
		}
        QSqlQuery q2("drop table Playlist", db);
		QSqlDatabase::removeDatabase("tempLibraryDB");
		qDebug("Update database from version 7");
	}
	case 8: {
		QSqlQuery q0("alter table Song add column Date varchar(50)", db);
		CreateDefaultSqlPlaylists2();
		qDebug("Update database from version 8");
	}
    }
    proxy->message("Database update from version "+QString::number(fromver));
    QSqlQuery q1("delete from Version", db);
    QSqlQuery q2("insert into Version (value) values ("+QString::number(DB_VERSION)+")", db);
    return true;
}
   void QuatOpsTest::testQuatDiv()
   {
      // test matrix div version against quat div version, 
      // make sure they all work the same.
      // note: this test depends on the xforms functions working
      {
         const float eps = 0.0001f;
         gmtl::Matrix44f q3( gmtl::makeRot<gmtl::Matrix44f>( gmtl::AxisAnglef( gmtl::Math::deg2Rad( 90.0f ), 0,1,0 ) ) ), 
                           q4( gmtl::makeRot<gmtl::Matrix44f>( gmtl::AxisAnglef( gmtl::Math::deg2Rad( 90.0f ), 0,0,1 ) ) ), q6;
         gmtl::Vec3f sx( 6,0,0 ), sy( 0,4,0 ), sz( 0,0,9 ), ex( 0,0,6 ), ey( -4,0,0 ), ez( 0,-9,0 ), tx, ty, tz;

         gmtl::invert( q3 ); // there is no matrix div, so do this to simulate it.

         // make sure the mult() func works
         gmtl::mult( q6, q4, q3 );
         tx = q6 * sx;
         ty = q6 * sy;
         tz = q6 * sz;
         CPPUNIT_ASSERT( gmtl::isEqual( ex, tx, eps ) );
         CPPUNIT_ASSERT( gmtl::isEqual( ey, ty, eps ) );
         CPPUNIT_ASSERT( gmtl::isEqual( ez, tz, eps ) );

         // make sure the operator* works too
         q6 = q4 * q3;
         tx = q6 * sx;
         ty = q6 * sy;
         tz = q6 * sz;
         CPPUNIT_ASSERT( gmtl::isEqual( ex, tx, eps ) );
         CPPUNIT_ASSERT( gmtl::isEqual( ey, ty, eps ) );
         CPPUNIT_ASSERT( gmtl::isEqual( ez, tz, eps ) );

         // make sure the operator*= works too
         q6 = q4;
         q6 *= q3;
         tx = q6 * sx;
         ty = q6 * sy;
         tz = q6 * sz;
         CPPUNIT_ASSERT( gmtl::isEqual( ex, tx, eps ) );
         CPPUNIT_ASSERT( gmtl::isEqual( ey, ty, eps ) );
         CPPUNIT_ASSERT( gmtl::isEqual( ez, tz, eps ) );
      }
      {
         const float eps = 0.0001f;
         gmtl::Quat<float> q3( gmtl::makeRot<gmtl::Quatf>( gmtl::AxisAnglef( gmtl::Math::deg2Rad( 90.0f ), 0,1,0 ) ) ), 
                           q4( gmtl::makeRot<gmtl::Quatf>( gmtl::AxisAnglef( gmtl::Math::deg2Rad( 90.0f ), 0,0,1 ) ) ), q5, q6;
         gmtl::Vec3f sx( 6,0,0 ), sy( 0,4,0 ), sz( 0,0,9 ), ex( 0,0,6 ), ey( -4,0,0 ), ez( 0,-9,0 ), tx, ty, tz;

         // make sure the mult() func works
         gmtl::div( q6, q4, q3 ); 
         tx = q6 * sx;
         ty = q6 * sy;
         tz = q6 * sz;
         CPPUNIT_ASSERT( gmtl::isEqual( ex, tx, eps ) );
         CPPUNIT_ASSERT( gmtl::isEqual( ey, ty, eps ) );
         CPPUNIT_ASSERT( gmtl::isEqual( ez, tz, eps ) );

         // make sure the operator* works too
         q6 = q4 / q3; 
         tx = q6 * sx;
         ty = q6 * sy;
         tz = q6 * sz;
         CPPUNIT_ASSERT( gmtl::isEqual( ex, tx, eps ) );
         CPPUNIT_ASSERT( gmtl::isEqual( ey, ty, eps ) );
         CPPUNIT_ASSERT( gmtl::isEqual( ez, tz, eps ) );

         // make sure the operator*= works too
         q6 = q4;
         q6 /= q3;
         tx = q6 * sx;
         ty = q6 * sy;
         tz = q6 * sz;
         CPPUNIT_ASSERT( gmtl::isEqual( ex, tx, eps ) );
         CPPUNIT_ASSERT( gmtl::isEqual( ey, ty, eps ) );
         CPPUNIT_ASSERT( gmtl::isEqual( ez, tz, eps ) );
      }
   }
void Hud::Draw (Zeni::Time::Second_Type elapsedTime)
{
	HeroComponent & hero = HeroComponent::GetInstance();

	double heroHealth = hero.GetHealth();
	double heroShields = hero.GetShields();
	double healthWidth = 200.0f;
	double healthHeight = 30.0f;

	Zeni::Point2f bgPosition1 (590.0f, 40.0f);
	Zeni::Point2f bgPosition2 (bgPosition1.x, bgPosition1.y + healthHeight);
	Zeni::Point2f bgPosition3 (bgPosition1.x + healthWidth, bgPosition1.y + healthHeight);
	Zeni::Point2f bgPosition4 (bgPosition1.x + healthWidth, bgPosition1.y);

	Zeni::Point2f healthPosition1 = bgPosition1;
	Zeni::Point2f healthPosition2 = bgPosition2;
	Zeni::Point2f healthPosition3 (bgPosition1.x + healthWidth * heroHealth / 1000.0f, bgPosition1.y + healthHeight);
	Zeni::Point2f healthPosition4 (bgPosition1.x + healthWidth * heroHealth / 1000.0f, bgPosition1.y);

	Zeni::Point2f shieldPosition1 = bgPosition1;
	Zeni::Point2f shieldPosition2 = bgPosition2;
	Zeni::Point2f shieldPosition3 (bgPosition1.x + healthWidth * heroShields / 100.0f, bgPosition1.y + healthHeight);
	Zeni::Point2f shieldPosition4 (bgPosition1.x + healthWidth * heroShields / 100.0f, bgPosition1.y);

	int score = hero.GetScore();

	std::stringstream ss4;
	ss4 << score;
	Zeni::get_Fonts()["score"].render_text (ss4.str(), Zeni::Point2f (20.0f, 550.0f), Zeni::get_Colors()["score"]);

	++frameCount;

	std::stringstream ss ("FPS: ");
	ss << fps;

	//Zeni::get_Fonts()["fps"].render_text (ss.str(), Zeni::Point2f(), Zeni::get_Colors()["fps"]);

	const std::vector<ProjectileFactory*>& heroWeapons = hero.GetWeapons();

	size_t numWeapons = heroWeapons.size();
	int selectedWeapon = hero.GetSelectedWeaponIndex();

	double corner = 800.0f - 30.0f * numWeapons;

	Zeni::Color enabled = Zeni::get_Colors()["weapon_enabled"];
	Zeni::Color disabled = Zeni::get_Colors()["weapon_disabled"];

	for (int i = 0; i < numWeapons; ++i)
	{
		Zeni::Vertex2f_Texture vertex1 (Zeni::Point2f(corner + 30.0f * i, 0.0f), Zeni::Point2f(0.0f, 0.0f));
		Zeni::Vertex2f_Texture vertex2 (Zeni::Point2f(corner + 30.0f * i, 30.0f), Zeni::Point2f(0.0f, 1.0f));
		Zeni::Vertex2f_Texture vertex3 (Zeni::Point2f(corner + 30.0f * (i + 1), 30.0f), Zeni::Point2f(1.0f, 1.0f));
		Zeni::Vertex2f_Texture vertex4 (Zeni::Point2f(corner + 30.0f * (i + 1), 0.0f), Zeni::Point2f(1.0f, 0.0f));
		Zeni::Quadrilateral<Zeni::Vertex2f_Texture> q (vertex1, vertex2, vertex3, vertex4);

		Zeni::Material backing(i == selectedWeapon ? "selected_weapon" : "weapon");

		q.lend_Material (&backing);

		Zeni::get_Video().render (q);
		
		double r = selectedWeapon == i ? weaponRotation : 0.0f;
		Zeni::render_image (
			heroWeapons[i]->GetTexture(),
			Zeni::Point2f(corner + 30 * i + 5.0f, 5.0f),
			Zeni::Point2f(corner + 30 * (i + 1.0f) - 5.0f, 25.0),
			r,
			1.0f,
			Zeni::Point2f(corner + 30 * i + 15.0f, 15.0f),
			false,
			heroWeapons[i]->IsReady() ? enabled : disabled);
	}

	int heroAmmo = heroWeapons[selectedWeapon]->GetAmmo();

	std::stringstream ss3;
	ss3 << heroAmmo;
	Zeni::get_Fonts()["ammo"].render_text (ss3.str(), Zeni::Point2f(corner - 5.0f, 0.0f), Zeni::get_Colors()["ammo"], Zeni::ZENI_RIGHT);

	Zeni::Vertex2f_Texture v9 (bgPosition1, Zeni::Point2f (0.0f, 0.0f));
	Zeni::Vertex2f_Texture v10 (bgPosition2, Zeni::Point2f (0.0f, 1.0f));
	Zeni::Vertex2f_Texture v11 (bgPosition3, Zeni::Point2f (1.0f, 1.0f));
	Zeni::Vertex2f_Texture v12 (bgPosition4, Zeni::Point2f (1.0f, 0.0f));

	Zeni::Quadrilateral<Zeni::Vertex2f_Texture> q3 (v9, v10, v11, v12);

	Zeni::Material healthbar1("healthbar1");

	q3.lend_Material (&healthbar1);

	Zeni::get_Video().render (q3);

	Zeni::Vertex2f_Texture v13 (healthPosition1, Zeni::Point2f (0.0f, 0.0f));
	Zeni::Vertex2f_Texture v14 (healthPosition2, Zeni::Point2f (0.0f, 1.0f));
	Zeni::Vertex2f_Texture v15 (healthPosition3, Zeni::Point2f (heroHealth / 1000.0f, 1.0f));
	Zeni::Vertex2f_Texture v16 (healthPosition4, Zeni::Point2f (heroHealth / 1000.0f, 0.0f));

	Zeni::Quadrilateral<Zeni::Vertex2f_Texture> q4 (v13, v14, v15, v16);

	Zeni::Material healthbar2("healthbar2");

	q4.lend_Material (&healthbar2);

	Zeni::get_Video().render (q4);

	Zeni::Vertex2f_Texture v17 (shieldPosition1, Zeni::Point2f (0.0f, 0.0f));
	Zeni::Vertex2f_Texture v18 (shieldPosition2, Zeni::Point2f (0.0f, 1.0f));
	Zeni::Vertex2f_Texture v19 (shieldPosition3, Zeni::Point2f (heroShields / 100.0f, 1.0f));
	Zeni::Vertex2f_Texture v20 (shieldPosition4, Zeni::Point2f (heroShields / 100.0f, 0.0f));

	Zeni::Quadrilateral<Zeni::Vertex2f_Texture> q5 (v17, v18, v19, v20);

	Zeni::Material healthbar3("healthbar3");

	q5.lend_Material (&healthbar3);

	Zeni::get_Video().render (q5);

	double timeRemaining = GameTimer::GetInstance().GetRemainingTime();

	Zeni::Color timerTextColor = timeRemaining < 10.0f ? Zeni::get_Colors()["low_time"] : Zeni::get_Colors()["time"];

	Zeni::render_image (
		"Timer",
		Zeni::Point2f (620.0f, 540.0f),
		Zeni::Point2f (670.0f, 590.0f),
		false,
		timerTextColor);

	std::stringstream ss2;
	int minutes = (int)timeRemaining / 60;
	ss2 << minutes << ":" << std::fixed << std::setprecision(2) << timeRemaining - minutes * 60;
	Zeni::get_Fonts()["time"].render_text (ss2.str(), Zeni::Point2f(680.0f, 550.0f), timerTextColor);
}
Beispiel #16
0
void init_mine_mesh(GLShape& base_mesh, GLShape& wheel_mesh) {
    float d = 0.025f;
    float x0 = 1.5f * d;
    float x1 = 2.0f * d;
    float y0 = 3.0f * d;
    float y1 = 4.0f * d;
    float z0 = d * 0.25f;
    float z1 = d;
    
    Vector3 p0(-x1, 0.0f, z1);
    Vector3 p1(-x0, 0.0f, z1);
    Vector3 p2(-x0, y0, z0);
    Vector3 p3(x0, y0, z0);
    Vector3 p4(x0, 0.0f, z1);
    Vector3 p5(x1, 0.0f, z1);
    Vector3 p6(x1, y1, 0.0f);
    Vector3 p7(-x1, y1, 0.0f);
    
    Vector3 q0(-x1, 0.0f, -z1);
    Vector3 q1(-x0, 0.0f, -z1);
    Vector3 q2(-x0, y0, -z0);
    Vector3 q3(x0, y0, -z0);
    Vector3 q4(x0, 0.0f, -z1);
    Vector3 q5(x1, 0.0f, -z1);
    Vector3 q6(x1, y1, 0.0f);
    Vector3 q7(-x1, y1, 0.0f);
    
    base_mesh = {
        p0, p1, p2, p0, p2, p7, p2, p3, p6, p2, p6, p7, p3, p4, p5, p3, p5, p6,
        q0, q1, q2, q0, q2, q7, q2, q3, q6, q2, q6, q7, q3, q4, q5, q3, q5, q6
    };
    
    std::vector<Vector2> wheel = circle(Vector2(), 3.0f * d, 16);
    wheel = cut(wheel, circle(Vector2(), 2.5f * d, 16));
    
    wheel_mesh = to_xy(triangulate(wheel));
    
    Vector3 w0(-d * 0.25f, -2.75f * d, 0.0f);
    Vector3 w1(d * 0.25f, -2.75f * d, 0.0f);
    Vector3 w2(d * 0.25f, 2.75f * d, 0.0f);
    Vector3 w3(-d * 0.25f, 2.75f * d, 0.0f);
    
    Vector3 w4(-d * 2.75f, -0.25f * d, 0.0f);
    Vector3 w5(d * 2.75f, -0.25f * d, 0.0f);
    Vector3 w6(d * 2.75f, 0.25f * d, 0.0f);
    Vector3 w7(-d * 2.75f, 0.25f * d, 0.0f);
    
    wheel_mesh.push_back(w0);
    wheel_mesh.push_back(w1);
    wheel_mesh.push_back(w2);
    wheel_mesh.push_back(w0);
    wheel_mesh.push_back(w2);
    wheel_mesh.push_back(w3);
    
    wheel_mesh.push_back(w4);
    wheel_mesh.push_back(w5);
    wheel_mesh.push_back(w6);
    wheel_mesh.push_back(w4);
    wheel_mesh.push_back(w6);
    wheel_mesh.push_back(w7);
}