예제 #1
0
파일: test1.c 프로젝트: jkkm/latrace
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;
}
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
}
   void QuatOpsTest::testQuatConj()
   {
      const float eps = 0.0001f;
      gmtl::Quat<float> q3( 0,0,342334,0 ), q5( 342334,-342334,342334,-342334 );
      gmtl::conj( q3 );
      gmtl::conj( q5 );

      gmtl::Quat<float> expected_result1( 0, 0, -342334, 0 ), expected_result2( -342334,342334,-342334,-342334 );
      CPPUNIT_ASSERT( gmtl::isEqual( expected_result1, q3, eps ) );
      CPPUNIT_ASSERT( gmtl::isEqual( expected_result2, q5, eps ) );
   }
예제 #4
0
파일: pro.c 프로젝트: ashrithhc/blindfold
void n3(float x,float y,float h,float w)
{
 glBegin(GL_POINTS);
 mid(x,y+h,x+w,y+h);
 mid(x+w,y+h,x+w/3,y+2*h/3);
 sem14(x+w/3,y+h/3,h/3);
 q5(x+w/3,y+h/3,h/3);
 glVertex2f(x+w/3,y);
 glEnd();
 xnxt+=w;
 xnxt+=sp;
}
예제 #5
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;
}
예제 #6
0
파일: pro.c 프로젝트: ashrithhc/blindfold
void sss(float x,float y,float h,float w)
{
 glBegin(GL_POINTS);
 q1(x+3*w/4,y+7*h/8,h/8);
 mid(x+w/2,y+h,x+3*w/4,y+h);
 sem23(x+w/2,y+3*h/4,h/4);
 sem14(x+w/2,y+h/4,h/4);
 mid(x+w/4,y,x+w/2,y);
 q5(x+w/4,y+h/8,h/8);
 glVertex2f(x,y+h/16);
 glEnd();
 xnxt+=w;
 xnxt+=sp;
}
   void QuatOpsTest::testQuatNormalize()
   {
      const float eps = 0.0001f;
      gmtl::Quat<float> q3( 0,0,342334,0 ), q5( 342334,-342334,342334,-342334 );
      gmtl::normalize( q3 );
      gmtl::normalize( q5 );

      gmtl::Quat<float> expected_result1( 0, 0, 1, 0 ), expected_result2( 0.5, -0.5, 0.5, -0.5 );
      CPPUNIT_ASSERT( gmtl::isEqual( expected_result1, q3, eps ) );
      CPPUNIT_ASSERT( gmtl::isEqual( expected_result2, q5, eps ) );

      CPPUNIT_ASSERT( gmtl::isNormalized( expected_result1 ) );
      CPPUNIT_ASSERT( gmtl::isNormalized( expected_result2 ) );
   }
   void QuatOpsTest::testQuatNegate()
   {
      const float eps = 0.0001f;
      gmtl::Quat<float> q3( 0,0,342334,0 ), q5( 342334,-342334,342334,-342334 );
      gmtl::Quat<float> expected_result1( 0, 0, -342334, 0 ), expected_result2( -342334,342334,-342334,342334 );

      // test operator-
      CPPUNIT_ASSERT( gmtl::isEqual( expected_result1, -q3, eps ) );
      CPPUNIT_ASSERT( gmtl::isEqual( expected_result2, -q5, eps ) );

      // test negate(quat)
      gmtl::negate( q3 );
      gmtl::negate( q5 );
      CPPUNIT_ASSERT( gmtl::isEqual( expected_result1, q3, eps ) );
      CPPUNIT_ASSERT( gmtl::isEqual( expected_result2, q5, eps ) );
   }
예제 #9
0
int main()
{
  Quaternion<> q0(1, 2, 3, 4);
  Quaternion<> q1(2, 3, 4, 5);
  Quaternion<> q2(3, 4, 5, 6);
  double r = 7;

  cout << "q0:      " << q0 << endl;
  cout << "q1:      " << q1 << endl;
  cout << "q2:      " << q2 << endl;
  cout << "r:       " << r << endl;
  cout << endl;
  cout << "-q0:     " << -q0 << endl;
  cout << "~q0:     " << ~q0 << endl;
  cout << endl;
  cout << "r * q0:  " << r*q0 << endl;
  cout << "r + q0:  " << r+q0 << endl;
  cout << "q0 / r:  " << q0/r << endl;
  cout << "q0 - r:  " << q0-r << endl;
  cout << endl;
  cout << "q0 + q1: " << q0+q1 << endl;
  cout << "q0 - q1: " << q0-q1 << endl;
  cout << "q0 * q1: " << q0*q1 << endl;
  cout << "q0 / q1: " << q0/q1 << endl;
  cout << endl;
  cout << "q0 * ~q0:     " << q0*~q0 << endl;
  cout << "q0 + q1*q2:   " << q0+q1*q2 << endl;
  cout << "(q0 + q1)*q2: " << (q0+q1)*q2 << endl;
  cout << "q0*q1*q2:     " << q0*q1*q2 << endl;
  cout << "(q0*q1)*q2:   " << (q0*q1)*q2 << endl;
  cout << "q0*(q1*q2):   " << q0*(q1*q2) << endl;
  cout << endl;
  cout << "||q0||:  " << sqrt(q0.normSquared()) << endl;
  cout << endl;
  cout << "q0*q1 - q1*q0: " << (q0*q1 - q1*q0) << endl;

  // Other base types
  Quaternion<int> q5(2), q6(3);
  cout << endl << q5*q6 << endl;
}
예제 #10
0
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;	
		}
	}
예제 #12
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;
}
예제 #13
0
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);
}
예제 #14
0
파일: GameShapes.cpp 프로젝트: knied/LD29
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);
}