• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ Pack函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Pack函数的典型用法代码示例。如果您正苦于以下问题:C++ Pack函数的具体用法?C++ Pack怎么用?C++ Pack使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: TEST_F

TEST_F(PacksTests, test_check_version) {
  auto fpack = Pack("foobar", getPackWithDiscovery());
  EXPECT_TRUE(fpack.checkVersion());

  auto zpack = Pack("foobaz", getPackWithFakeVersion());
  EXPECT_FALSE(zpack.checkVersion());
}
开发者ID:hungld,项目名称:osquery,代码行数:7,代码来源:packs_tests.cpp


示例2: Vector2f

void MpHostSetupUi::initWindow() {
    window->SetStyle(Style::Fullscreen);
    window->SetRequisition(Vector2f((float)ct::WindowWidth, (float)ct::WindowHeight));

    mainBox = Box::Create(Box::Orientation::VERTICAL, 5);
    auto closeButton = Button::Create("Close");
    closeButton->GetSignal(Widget::OnLeftClick).Connect(backAction);
    mainBox->Pack(createAlignment(closeButton, Vector2f(0.0f, 0.0f), Vector2f(1.0f, 0.0f)));

    auto nameBox = Box::Create(Box::Orientation::HORIZONTAL, 5);
    nameEntry = Entry::Create("Player 1");
    nameEntry->SetMaximumLength(10);
    nameEntry->SetRequisition(Vector2f(ct::WindowWidth * 0.1f, 0.0f));
    auto createButton = Button::Create("Create");
    createButton->GetSignal(Widget::OnLeftClick).Connect(bind(&MpHostSetupUi::triggerCreateServer, this));

    nameBox->Pack(nameEntry, true, true);
    nameBox->Pack(createButton, true, true);

    nameFrame = Frame::Create("Your name:");
    nameFrame->Add(nameBox);
    nameFrame->SetRequisition(Vector2f(0.0f, ct::WindowHeight * 0.1f));
    mainBox->Pack(createAlignment(nameFrame, Vector2f(0.5f, 0.01f), Vector2f(1.0f, 0.0f)));

    window->Add(createAlignment(mainBox, Vector2f(0.5f, 0.5f), Vector2f(0.9f, 0.9f)));
}
开发者ID:TED-996,项目名称:MinesweeperMp,代码行数:26,代码来源:MpHostSetupUi.cpp


示例3: Pack

void ExteriorNeighbor::Pack(
	const GridData4D & data
) {
	// Model grid
	const Grid & grid = m_pConnect->GetGridPatch().GetGrid();

	// 3D Grid Data
	GridData3D data3D;

	// For state data exclude non-collacted data points
	if (data.GetDataType() == DataType_State) {
		// List of variable indices to send
		// - exclude variables which are not-collocated with this data structure
		for (int c = 0; c < data.GetComponents(); c++) {
			if (grid.GetVarLocation(c) != data.GetDataLocation()) {
				continue;
			}
			data.GetAsGridData3D(c, data3D);
			Pack(data3D);
		}

	// Send everything
	} else {
		for (int c = 0; c < data.GetComponents(); c++) {
			data.GetAsGridData3D(c, data3D);
			Pack(data3D);
		}
	}
}
开发者ID:AntoninVerletBanide,项目名称:tempestmodel,代码行数:29,代码来源:Connectivity.cpp


示例4: render_window

void CustomWidget::Run() {
	// Create SFML's window.
	sf::RenderWindow render_window( sf::VideoMode( SCREEN_WIDTH, SCREEN_HEIGHT ), "Custom Widget" );

	// Create our custom widget.
	m_custom_widget = MyCustomWidget::Create( "Custom Text" );

	// Create a simple button and connect the click signal.
	auto button = sfg::Button::Create( "Button" );
	button->GetSignal( sfg::Widget::OnLeftClick ).Connect( std::bind( &CustomWidget::OnButtonClick, this ) );

	// Create a vertical box layouter with 5 pixels spacing and add our custom widget and button
	// and button to it.
	auto box = sfg::Box::Create( sfg::Box::Orientation::VERTICAL, 5.0f );
	box->Pack( m_custom_widget );
	box->Pack( button, false );

	// Create a window and add the box layouter to it. Also set the window's title.
	auto window = sfg::Window::Create();
	window->SetTitle( "Custom Widget" );
	window->Add( box );

	// Create a desktop and add the window to it.
	sfg::Desktop desktop;
	desktop.Add( window );

	// We're not using SFML to render anything in this program, so reset OpenGL
	// states. Otherwise we wouldn't see anything.
	render_window.resetGLStates();

	// Main loop!
	sf::Event event;
	sf::Clock clock;

	while( render_window.isOpen() ) {
		// Event processing.
		while( render_window.pollEvent( event ) ) {
			desktop.HandleEvent( event );

			// If window is about to be closed, leave program.
			if( event.type == sf::Event::Closed ) {
				render_window.close();
			}
		}

		// Update SFGUI with elapsed seconds since last call.
		desktop.Update( clock.restart().asSeconds() );

		// Rendering.
		render_window.clear();
		m_sfgui.Display( render_window );
		render_window.display();
	}
}
开发者ID:TankOs,项目名称:SFGUI,代码行数:54,代码来源:CustomWidget.cpp


示例5: packFile

void IHM::packFile(File f_)
{
    auto box = sfg::Box::Create( sfg::Box::Orientation::HORIZONTAL, 50.f);
    box->Pack( sfg::Label::Create( f_.getFilename() ), true, true );
    box->Pack( sfg::Label::Create( f_.getFilepath() ), true, true );
    auto button = sfg::Button::Create( L"Load" );
    //auto funct = std::bind( &IHM::OnLoadMusicBtnClick, f_.getFilename());
    auto funct = std::bind(&IHM::OnLoadMusicBtnClick,this, f_.getFilename());//need to try this
    button->GetSignal( sfg::Widget::OnLeftClick ).Connect( funct );
    box->Pack( button, false );
    _listFiles->Pack( box, false);
开发者ID:teroratsu,项目名称:OggMaster,代码行数:11,代码来源:IHM.cpp


示例6:

WindowCreateCharacter::WindowCreateCharacter()
{
	this->window = sfg::Window::Create();
	this->window->SetTitle("Create Character");
	this->window->SetStyle(sfg::Window::Style::TITLEBAR | sfg::Window::Style::SHADOW | sfg::Window::Style::BACKGROUND);

	auto vbox = sfg::Box::Create(sfg::Box::Orientation::VERTICAL, 5.f);
	auto lblCharacterName = sfg::Label::Create(L"Character Name:");
	lblCharacterName->SetAlignment(sf::Vector2f(0.f, 0.5f));
	vbox->Pack(lblCharacterName);
	this->tbCharacterName = sfg::Entry::Create();
	this->tbCharacterName->SetMaximumLength(32);
	this->tbCharacterName->SetRequisition(sf::Vector2f(200.f, 0.f));
	this->tbCharacterName->SetText(L"Player");
	vbox->Pack(this->tbCharacterName);
	auto lblClass = sfg::Label::Create(L"Class:");
	lblClass->SetAlignment(sf::Vector2f(0.f, 0.5f));
	vbox->Pack(lblClass);
	this->cbxCharacterClass = sfg::ComboBox::Create();
	this->cbxCharacterClass->AppendItem(L"General");
	this->cbxCharacterClass->SelectItem(0);
	vbox->Pack(this->cbxCharacterClass);
	vbox->Pack(sfg::Separator::Create());
	auto hbox = sfg::Box::Create(sfg::Box::Orientation::HORIZONTAL);
	this->btnCancel = sfg::Button::Create(L"Cancel");
	hbox->Pack(this->btnCancel);
	this->btnPlay = sfg::Button::Create(L"Start!");
	hbox->Pack(btnPlay);

	vbox->Pack(hbox);
	this->window->Add(vbox);
}
开发者ID:LunaticEdit,项目名称:RancerZero,代码行数:32,代码来源:WindowCreateCharacter.cpp


示例7: assert

netBool UnreliableListener::Push(SerializerLess &_ser, const Peer& _peer)
{
	assert(m_stream != nullptr);

	Channel& channel = GetChannel(m_sendChannels, _peer);

	SerializerLess *back = channel.Back();

	// bundling
	if(channel.IsEmpty() || back->GetSize() + _ser.GetSize() > back->GetBufferSize())
	{
		SerializerLess ser(m_pool.GetSerializer());
		// prepare serializer
		ser.Write(m_stream->GetType());

		SerializerLess stream_ser(ser, m_stream->GetHeaderSize(), ser.GetBufferSize());
		stream_ser.Write(GetType());
		stream_ser.Close();

		ser.SetCursor(ser.GetCursor() + stream_ser.GetSize());
		ser.Close();
		channel.Push(ser);
	}

	return Pack(_ser, _peer);
}
开发者ID:ricklesauceur,项目名称:netduke,代码行数:26,代码来源:unreliablelistener.cpp


示例8: Pack

	bool Pack(msg_buffer_t & msgbuf) const {
		int sz = msgbuf.max_size;
		bool ret = Pack(msgbuf.buffer, sz);
		if (!ret) return ret;
		msgbuf.valid_size = sz;
		return true;
	}
开发者ID:jj4jj,项目名称:dcpots,代码行数:7,代码来源:msg_proto.hpp


示例9: Pack

uint WBEvent::GetSerializationSize() const
{
	WBPackedEvent PackedEvent;
	Pack( PackedEvent );

	return PackedEvent.GetSize() + 4;
}
开发者ID:MinorKeyGames,项目名称:Eldritch,代码行数:7,代码来源:wbevent.cpp


示例10: nullNodeKey

GlobalIDDataBase::NodeKey_t
GlobalIDDataBase::push(LayoutID_t layoutID, int context, GlobalID_t globalID)
{
  int ret = data_m.size();
  data_m.push_back(Pack(layoutID, context, globalID, nullNodeKey()));
  return ret;
}
开发者ID:pathscale,项目名称:freepooma-testsuite,代码行数:7,代码来源:GlobalIDDataBase.cmpl.C


示例11: Pack

void CDownloadFileCompletePacket::InitData(string strUrl, int64 nFileLength, string strHashValue)
{
    this->strUrl = strUrl;
    this->nFileLength = nFileLength;
    this->strHashValue = strHashValue;
    Pack();
};
开发者ID:zyouhua,项目名称:ligle,代码行数:7,代码来源:cfinderpacket.cpp


示例12: PackStay

bool Pointer::PackStay(Environment &env, const char *format, const ValueList &valListArg)
{
	size_t offset = _offset;
	if (!Pack(env, format, valListArg)) return false;
	_offset = offset;
	return true;
}
开发者ID:gura-lang,项目名称:gura,代码行数:7,代码来源:Pointer.cpp


示例13: switch

bool ScrollBox::SendKey(const SDL_keysym & key)
{
  if (!WidgetList::SendKey(key)) {
    int new_offset = offset;
    switch(key.sym)
    {
    case SDLK_PAGEUP:
      new_offset -= size.y;
      break;
    case SDLK_PAGEDOWN:
      new_offset += size.y;
      break;
    default:
      return false;
    }

    if (new_offset < 0)
      new_offset = 0;
    if (new_offset > GetMaxOffset())
      new_offset = GetMaxOffset();

    if (new_offset != offset) {
      offset = new_offset;
      Pack();
      NeedRedrawing();
    }
  }
  return true;
}
开发者ID:Arnaud474,项目名称:Warmux,代码行数:29,代码来源:scroll_box.cpp


示例14: GetMaxOffset

void ScrollBox::__Update(const Point2i & mousePosition,
                         const Point2i & /*lastMousePosition*/)
{
  // update position of items because of dragging
  if (HasScrollBar() && scroll_mode!=SCROLL_MODE_NONE) {
    int max_offset = GetMaxOffset();
    int new_offset = offset;

    if (scroll_mode == SCROLL_MODE_THUMB) {
      Point2i track_pos  = GetScrollTrackPos();
      int     height     = GetTrackHeight();

      new_offset = start_drag_offset +
                   ((mousePosition.y - start_drag_y) * (size.y+max_offset))/height;
    } else if (scroll_mode == SCROLL_MODE_DRAG) {
      // Act as if the scroll corresponds to bringing the starting point to the
      // current point
      new_offset = start_drag_offset + start_drag_y - mousePosition.y;
    }

    if (new_offset < 0)
      new_offset = 0;
    if (new_offset > max_offset)
      new_offset = max_offset;

    if (new_offset != offset) {
      offset = new_offset;
      Pack();
    }
  }
}
开发者ID:Arnaud474,项目名称:Warmux,代码行数:31,代码来源:scroll_box.cpp


示例15: Pack

bool PokerMsgBase::ToStream(StreamWriter* pWriter)
{
	if (!pWriter->Write(&m_Size, sizeof(m_Size))) return false;
	if (!pWriter->Write(&m_Type, sizeof(m_Type))) return false;

	return Pack(pWriter);
}
开发者ID:mshandle,项目名称:spank,代码行数:7,代码来源:PokerMsgBase.cpp


示例16: AdjustLength

 static SIZE_TYPE Pack
 (const SrcCont& src,
  TCoding src_coding,
  DstCont& dst,
  TCoding& dst_coding,
  TSeqPos length)
 {
     if ( src.empty()  ||  (length == 0) ) {
         return 0;
     }
     
     AdjustLength(src, src_coding, 0, length);
     // we allocate enough memory for ncbi4na coding
     // if the result will be ncbi2na coding we'll resize (see below)
     ResizeDst(dst, CSeqUtil::e_Ncbi4na, length);
     
     SIZE_TYPE res = Pack(&*src.begin(), length, src_coding, 
                          &*dst.begin(), dst_coding);
     if ( dst_coding == CSeqUtil::e_Ncbi2na ) {
         size_t new_size = res / 4;
         if ( (res % 4) != 0 ) {
             ++new_size;
         }
         dst.resize(new_size);
     }
     return res;
 }
开发者ID:swuecho,项目名称:igblast,代码行数:27,代码来源:sequtil_convert_imp.hpp


示例17: main

int main (int argc, char * * argv)
{
	if (argc != 3)
	{
		printf("\nInvalid number of arguments\n");
		return EXIT_FAILURE;
	}

	char * in_file = argv[1];
	char * out_file = argv[2];
	
	int num_b; // number of boxes
	int num_n; // nubmer of nodes

	// arr is an array implementation of a binary tree
	// the root node is the node of index num_n
	Node * arr = Load_File(in_file, &num_b, &num_n);

	double x_tot = 0;
	double y_tot = 0;

	clock_t pack_t = clock();
	Coord * crd = Pack(arr, num_n, num_b, &x_tot, &y_tot);
	pack_t = clock() - pack_t;

	printf("\n\nElapsed Time:  %le\n\n", ((double) pack_t) / CLOCKS_PER_SEC);

	Save_File(out_file, arr, crd, num_b);

	free(arr);
	free(crd);

	return EXIT_SUCCESS;
}
开发者ID:Zawicki,项目名称:ECE368,代码行数:34,代码来源:packing.c


示例18: Smooth

void Smooth()
{
	int imember; 		/* current member 	*/
	int i, j, igene;	/* counters		*/
	int begin, end;		/* limit the operator 	*/
	static double *Vector_Aux;
	static int first=1;

	if (first)
	{
	        Vector_Aux = 
			(double *) calloc((unsigned) Genes, sizeof(double));
                if (Vector_Aux == NULL) 
				Error("Allocation failed for Vector_Aux");
		first = 0;
	}

/*
    For all the members of the current population 
*/
	if (verbose) 
		fprintf(stderr,"\nSubpopulation %d smoothing trial solutions\n", instance);

	for (imember = 0; imember < Popsize; imember++)
	{
        	Unpack(New[imember].Gene, Bitstring, Length);
                FloatRep(Bitstring, Vector, Genes);

		for (igene = 0, Vector_Aux[igene] = 0.; 
		     igene < NSOURCES + NRECEIVERS; 
		     igene++, Vector_Aux[igene] = 0.)
		{
			if (igene < NSOURCES)
			{
				/* no smooth of source statics */
				Vector_Aux[igene] = Vector[igene];
			}	
			else
			{
				i = to_filter[igene - NSOURCES][0];
				j = to_filter[igene - NSOURCES][1];

				if (to_filter[igene - NSOURCES][2] == 2)
					Vector_Aux[igene] = 
						(Vector[i] + Vector[j]) / 2.;
				else
					Vector_Aux[igene] =
						(Vector[i] + Vector[igene] + 
						 Vector[j]) / 3.;
			}
		}
/*
    Packing
*/
                StringRep(Vector_Aux, Bitstring, Genes);
                Pack(Bitstring, New[imember].Gene, Length);
		New[imember].Needs_evaluation = 1;
	}
}
开发者ID:gwowen,项目名称:seismicunix,代码行数:59,代码来源:ngen_smooth.c


示例19: MSG_DEBUG

void FileListBox::PopulateFileList(const std::string& path)
{
  new_path = path;
  if (path.compare(path.size()-1, sizeof(PATH_SEPARATOR), PATH_SEPARATOR))
    new_path += PATH_SEPARATOR;
  MSG_DEBUG("file", "Searching in %s\n", new_path.c_str());

  FolderSearch *f = OpenFolder(new_path);

  // Now that we have made use of new_path, it can be freed:
  // clearing the list is now possible
  Clear();

  if (f) {
    bool is_file = list_files;
    const char *name;

    while ((name = FolderSearchNext(f, is_file)) != NULL) {
      if (is_file) {
        // We have a file, check that it validates the list
        if (MatchFilter(name)) {
          std::string* filename = new std::string(new_path);
          *filename += name;
          MSG_DEBUG("file", "Adding file %s\n", name);
          AddLabelItem(false, ANSIToUTF8(new_path, name), filename, Font::FONT_MEDIUM);
        } else {
          MSG_DEBUG("file", "NOT adding file %s, invalid extension\n", name);
        }
      } else if (strcmp(name, ".")) {
        std::string* filename;
        if (!strcmp(name, "..")) {
          // Are we at the root?
          if (!strcmp(name, PATH_SEPARATOR))
            break;
          size_t pos = new_path.find_last_of(PATH_SEPARATOR, new_path.size()-2, sizeof(PATH_SEPARATOR));
          filename = new std::string(new_path.substr(0, pos+1));
        } else
          filename = new std::string(new_path);
        *filename += name;
        MSG_DEBUG("file", "Adding directory %s\n", name);
        AddLabelItem(false, std::string("[") + ANSIToUTF8(new_path, name) + "]", filename,
                     Font::FONT_MEDIUM, Font::FONT_NORMAL, c_yellow);
      } else
        MSG_DEBUG("file", "Rejecting %s\n", name);

      // Prepare again for searching files
      is_file = list_files;
    }

    CloseFolder(f);
    Pack();
    NeedRedrawing();
  } else {
    MSG_DEBUG("file", "Search failed?\n");
  }

  // Store last time to drop fast clicks
  last_time = SDL_GetTicks();
}
开发者ID:fluxer,项目名称:warmux,代码行数:59,代码来源:file_list_box.cpp


示例20: assert

netBool UDPStream::Push(SerializerLess &_ser, const Peer& _peer)
{
	assert(m_isValid);

	Pack(_ser, _peer);

	return true;
}
开发者ID:ricklesauceur,项目名称:netduke,代码行数:8,代码来源:udpstream.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Packet函数代码示例发布时间:2022-05-30
下一篇:
C++ Pa_StopStream函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap