Exemplo n.º 1
0
static void test_container_apis(skiatest::Reporter* reporter) {
    REPORTER_ASSERT(reporter, !TContainer((TCount)0).get());
    REPORTER_ASSERT(reporter, TContainer((TCount)1).get());
    REPORTER_ASSERT(reporter, TContainer((TCount)kStackPreallocCount).get());
    REPORTER_ASSERT(reporter, TContainer((TCount)kStackPreallocCount + 1).get());

    TContainer container;
    // The default constructor may or may not init to empty, depending on the type of container.

    container.reset((TCount)1);
    REPORTER_ASSERT(reporter, container.get());

    container.reset((TCount)kStackPreallocCount);
    REPORTER_ASSERT(reporter, container.get());

    container.reset((TCount)kStackPreallocCount + 1);
    REPORTER_ASSERT(reporter, container.get());

    container.reset((TCount)0);
    REPORTER_ASSERT(reporter, !container.get());
}
Exemplo n.º 2
0
hash_t Pearson_Compare(const TContainer& data)
{
  hash_t hash;
  hash.fill(0);

  for (size_t j = 0; j < HASH_SIZE; ++j)
  {
    uint8_t subhash = etl::PEARSON_LOOKUP[(data[0] + j) % 256];

    for (size_t i = 1; i < data.size(); ++i)
    {
      subhash = etl::PEARSON_LOOKUP[subhash ^ data[i]];
    }

    hash[j] = subhash;
  }

  return hash;
}
Exemplo n.º 3
0
//-------------------------------------------------------------------------
bool TBaseServer::IsSessionSecurity(unsigned int id_session, void* crypt, int size_crypt, 
                                    void* pLogin, int sizeLogin, void* pPassword, int sizePassword)
{
  TContainer cRSA;
  // получить по сессии RSA от транспорта
  if(mManagerSession->GetRSAPublicKey(id_session, cRSA)==false)
    return false;

  TCryptMITM cryptMITM;
  TContainer cMITM;
  if(cryptMITM.Calc(cRSA.GetPtr(), cRSA.GetSize(),
    pLogin, sizeLogin, pPassword, sizePassword, cMITM)==false)
    return false;
  // сравнить по размеру
  if(size_crypt!=cMITM.GetSize())
    return false;
  // сравнить по содержимому
  if(memcmp(crypt, cMITM.GetPtr(), size_crypt)!=0)
    return false;

  return true;
}
Exemplo n.º 4
0
	void fill(TContainer& container) {
		rrange_insert<TContainer, typename TContainer::iterator> insert_range(container, container.begin());
		while (range_.ok() && range_.take2(insert_range));
	}
Exemplo n.º 5
0
	rrange_insert(TContainer& container, TIt it)
		: container_(container) , it_(it), previous_(container.end())
	{ }
Exemplo n.º 6
0
	void sort(TContainer & source, const TCmp & cmp)
	{
		std::sort(source.begin(), source.end(), cmp);
	}
Exemplo n.º 7
0
jobjectArray ToJavaArray(JNIEnv * env, jclass clazz, TContainer const & src, TToJavaFn && toJavaFn)
{
  return ToJavaArray(env, clazz, begin(src), end(src), src.size(), forward<TToJavaFn>(toJavaFn));
}
Exemplo n.º 8
0
////////////////////////////////////////////////////////////////////
// Public functions
//
void CDrawGrid::Draw( int page, CDC* dc )
/* ============================================================
	Function :		CDrawGrid::Draw
	Description :	Draws this object.
	Access :		Public
					
	Return :		void
	Parameters :	int page	-	Current page
					CDC* dc		-	CDC to draw to

	Usage :			Called by the generator to draw the object.

   ============================================================*/
{

	/////////////////////////////////
	// Get and convert grid position
	//

	int drawpage = page - GetPageOffset();
	CDoubleRect rect = GetPosition();
	CUnitConversion::InchesToPixels( rect );

	CRect r( static_cast< int >( rect.left ), static_cast< int >( rect.top ), static_cast< int >( rect.right ), static_cast< int >( rect.bottom ) );
	CUnitConversion::AdjustPixelsToPaper( dc, r );

	/////////////////////////////////
	// Create column widths and 
	// fonts 
	//

	int restWidth = 0;
	int sumWidth = 0;
	TContainer< CFont* > fonts;

	double lpi = static_cast< double >( GetLPI() );
	double inch = static_cast< double >( dc->GetDeviceCaps( LOGPIXELSY ) );
	int lineHeight = static_cast< int >( inch / lpi + .5 );

	int max = m_columns.GetSize();
	for( int t = 0 ; t < max ; t++ )
	{

		CColumn* column = m_columns.GetAt( t );
		if( column )
		{
			sumWidth += CUnitConversion::InchesToPixels( column->GetWidth() );
			fonts.Add( column->GetColumnFont() );
		}

	}

	// restWidth will be used for 
	// any 0-length field
	restWidth = r.Width() - sumWidth;

	/////////////////////////////////
	// Find start and end of data
	// 

	int start = m_pages.GetAt( drawpage )->m_startLine;
	int end = m_pages.GetAt( drawpage )->m_endLine;

	int mode = dc->SetBkMode( TRANSPARENT );
	COLORREF color = dc->GetTextColor();

	/////////////////////////////////
	// Border
	//

	const CBorderLine* borderline = GetBorder();
	CPen pen;
	CPen boldPen;

	if( borderline->GetVisible() )
	{
		// Draw a border around the grid
		int thickness = CUnitConversion::InchesToPixels( borderline->GetThickness() );
		pen.CreatePen( borderline->GetStyle(),
					   thickness,
					   borderline->GetColor() );

		dc->SelectObject( &pen );
		dc->SelectStockObject( NULL_BRUSH );
		dc->Rectangle( r );
		dc->SelectStockObject( NULL_PEN );
	}


	/////////////////////////////////
	// Line pens
	//

	const CBorderLine* columnline = GetColumnLine();
	const CBorderLine* rowline = GetRowLine();
	CPen* columnpen = NULL;
	CPen* rowpen = NULL;
	if( columnline->GetVisible() )
	{
		columnpen = new CPen;
		int thickness = CUnitConversion::InchesToPixels( columnline->GetThickness() );
		columnpen->CreatePen( columnline->GetStyle(),
					   thickness,
					   columnline->GetColor() );
	}

	if( rowline->GetVisible() )
	{
		rowpen = new CPen;
		int thickness = CUnitConversion::InchesToPixels( rowline->GetThickness() );
		rowpen->CreatePen( rowline->GetStyle(),
					   thickness,
					   rowline->GetColor() );
	}


	/////////////////////////////////
	// Column lines
	//

	if( columnpen )
	{

		dc->SelectObject( columnpen );
		int left = r.left;

		// Loop columns
		for( int i = 0 ; i < max - 1; i++ )
		{

			CColumn* column = m_columns.GetAt( i );
			if( column )
			{

				int pixelWidth = CUnitConversion::InchesToPixels( column->GetWidth() );
				if( pixelWidth == 0 )
					pixelWidth = restWidth;

				left += pixelWidth;

				dc->MoveTo( left, r.top );
				dc->LineTo( left, r.bottom );

			}

		}

		dc->SelectStockObject( NULL_PEN );

	}

	/////////////////////////////////
	// Loop and print column strings
	//

	int top = r.top;
	for(int t = start ; t < end ; t++ )
	{
		// Tokenize a line of data
		CString line( m_data[ t ] );
		int quarterHeight = lineHeight / 4;

		// Check if this is a separator 
		if( IsSeparator( line ) )
		{
			// Draw a line across the grid
			dc->SelectStockObject( BLACK_PEN );
			dc->MoveTo( r.left, top + quarterHeight );
			dc->LineTo( r.right, top + quarterHeight );
		}
		else if( IsDoubleSeparator( line ) )
		{
			// Draw a double line across the grid
			dc->SelectStockObject( BLACK_PEN );
			dc->MoveTo( r.left, top + quarterHeight );
			dc->LineTo( r.right, top + quarterHeight );
			dc->MoveTo( r.left, top + quarterHeight * 2 );
			dc->LineTo( r.right, top + quarterHeight * 2 );
		}
		else if( IsBoldSeparator( line ) )
		{
			// Draw a bold line across the grid
			boldPen.CreatePen( PS_SOLID, quarterHeight / 2, RGB( 0, 0, 0 ) );
			dc->SelectObject( boldPen );
			dc->MoveTo( r.left, top + quarterHeight );
			dc->LineTo( r.right, top + quarterHeight );
			dc->SelectStockObject( BLACK_PEN );
		}
		else
		{
			CTokenizer tok( line, _T( "|" ) );

			int left = r.left;
			// Loop columns
			for( int i = 0 ; i < max ; i++ )
			{
				CColumn* column = m_columns.GetAt( i );
				CRect drawRect( left, top, r.right, top + lineHeight );
				if( column )
				{
					// Get the data for this column
					CString data;
					tok.GetAt( i, data );

					// Get the width of the column
					int pixelWidth = CUnitConversion::InchesToPixels( column->GetWidth() );
					if( pixelWidth == 0 )
						pixelWidth = restWidth;

					// Set font
					CFont* font = fonts.GetAt( i );
					CFont* specialFont = NULL;

					if( font )
					{
						if( IsBold( data ) )
						{

							// Select a bold font 
							// here instead

							specialFont = new CFont;
							LOGFONT lf;

							font->GetLogFont( &lf );

							lf.lfWeight = FW_BOLD;
							specialFont->CreateFontIndirect( &lf );

						}

						if( IsItalic( data ))
						{

							// Select an italic font 
							// here instead

							specialFont = new CFont;
							LOGFONT lf;

							font->GetLogFont( &lf );

							lf.lfItalic = TRUE;
							specialFont->CreateFontIndirect( &lf );

						}
					}

					if( specialFont )
						dc->SelectObject( specialFont );
					else if( font )
						dc->SelectObject( font );

					// Create draw rect
					drawRect.SetRect( left, top, left + pixelWidth, top + lineHeight );

					// Add offsets for columns
					int offset = CUnitConversion::PointsToPixels( column->GetFontSize() / 40.0 );
					if( borderline->GetVisible() && i == 0 )
						offset += max( 1, CUnitConversion::InchesToPixels( borderline->GetThickness() ) );
					if( columnline->GetVisible() && i > 0 )
						offset += max( 1, CUnitConversion::InchesToPixels( columnline->GetThickness() ) );

					drawRect.left += offset;
					drawRect.right -= offset;

					// Draw data
					int justification = column->GetJustification();
					dc->DrawText( data, drawRect, DT_VCENTER | DT_NOPREFIX | DT_WORDBREAK | justification );

					if( specialFont )
						delete specialFont;

					// Increase x-coord
					left += pixelWidth;
				}


				/////////////////////////////////
				// Row dividers
				//

				if( rowpen && t < end )
				{

					dc->SelectObject( rowpen );
					dc->MoveTo( r.left, drawRect.bottom );
					dc->LineTo( r.right, drawRect.bottom );

				}

			}
		}

		// Increase y-coord
		top += lineHeight;

	}

	/////////////////////////////////
	// Restore everything
	//

	dc->SetBkMode( mode );
	dc->SetTextColor( color );
	dc->SelectStockObject( ANSI_VAR_FONT );
	dc->SelectStockObject( NULL_PEN );

	if( columnpen )
		delete columnpen;

	if( rowpen )
		delete rowpen;
	
}
Exemplo n.º 9
0
//-------------------------------------------------------------------
int main(int argc, char** argv)
{
#if 0
  // внутри MMOEngine
  nsMMOEngine::TEventTryLogin erfd;
  erfd.id_session = 1;
  erfd.sizeData   = 100;
  TContainer* pC  = new TContainer;
  pC->SetData(NULL, sizeof(nsMMOEngine::TEventTryLogin) + erfd.sizeData);
  memcpy(pC->GetPtr(), &erfd, sizeof(nsMMOEngine::TEventTryLogin));
  // внутри DeveloperDLL
  nsMMOEngine::TBaseEvent* pBE = (nsMMOEngine::TBaseEvent*)pC->GetPtr();
  switch(pBE->mType)
  {
    case nsMMOEngine::TBase::eTryLogin:
    {
      nsMMOEngine::TEventTryLogin* pERFD = (nsMMOEngine::TEventTryLogin*)pBE;
      break;
    }
    default:;
  }
  delete pC;
#endif
    g_ShareTest->Init("Client");

	TArgData d;
	GetByArg(argc,argv,d);
	printf("port=%u,TimeSleep=%d,cnt=%d\n",d.port_client, d.time_sleep, d.cnt);

  INetTransport* pNetTransport = g_ShareTest->GetTransport();

  bool res = pNetTransport->Open(d.port_client);
  g_ShareTest->Register();

	pNetTransport->Start();

  TBreakPacket packetForSend;
	if(pNetTransport->Connect(d.ip, TShareTest::ePortServer))
	{
		unsigned int start = ht_GetMSCount();
		for(int i = 0 ; i < TShareTest::eCntRecvPacket ;)
		{
			for(int j = 0 ; j < d.cnt ; j++ )
			{
        packetForSend.UnlinkPart();
        packetForSend.PushFront(g_ShareTest->GetPacket(), TShareTest::eSizePacket);
        pNetTransport->Send(d.ip, TShareTest::ePortServer, packetForSend, true);
				i++;
				if(i==TShareTest::eCntRecvPacket)
					break;
			}
			ht_msleep(d.time_sleep);
      if(g_ShareTest->IsDisconnect())
        break;
		}
		start = ht_GetMSCount() - start;
    printf("time=%d ms, v=%f \n",
      start,float(TShareTest::eSizePacket*TShareTest::eCntRecvPacket)/(start*1000));
	}
  pNetTransport->Close(d.ip,TShareTest::ePortServer);
	pNetTransport->Stop();
  BL_ASSERT(pNetTransport->IsActive()==false);
  g_ShareTest->Unregister();

  //_getch();
  return 0;
}
Exemplo n.º 10
0
typename TContainer::iterator erase_if_impl(TContainer& cont, TPred pred, listlike_tag)
{
  return cont.remove_if(pred);
}
Exemplo n.º 11
0
typename TContainer::iterator erase_if_impl(TContainer& cont, TPred pred, vectorlike_tag)
{
  return cont.erase(std::remove_if(begin(cont), end(cont), pred), end(cont));
}
Exemplo n.º 12
0
typename TContainer::iterator erase_impl(TContainer& cont, const TValue& val, associative_tag)
{
  return cont.erase(val);
}
Exemplo n.º 13
0
typename TContainer::iterator erase_impl(TContainer& cont, const TValue& val, listlike_tag)
{
  return cont.remove(val);
}
Exemplo n.º 14
0
typename TContainer::iterator erase_impl(TContainer& cont, const TValue& val, vectorlike_tag)
{
  return cont.erase(std::remove(begin(cont), end(cont), val), end(cont));
}
Exemplo n.º 15
0
//----------------------------------------------------------------------------------
void TBasePacket_PCS::Unpack(TContainer c)
{
  char* p  = c.GetPtr()  + sizeof(mType);
  int size = c.GetSize() - sizeof(mType);
  UnpackInherit(p, size);
}
Exemplo n.º 16
0
typename TContainer::value_type JoinStrings(TContainer const & container,
                                            TDelimiter const & delimiter)
{
  return JoinStrings(container.begin(), container.end(), delimiter);
}
Exemplo n.º 17
0
 bool hasSpell(const std::string& spell) { return mSpells.find(Misc::StringUtils::lowerCase(spell)) != mSpells.end(); }