当前位置: 首页>>代码示例>>C++>>正文


C++ CStr::Format方法代码示例

本文整理汇总了C++中CStr::Format方法的典型用法代码示例。如果您正苦于以下问题:C++ CStr::Format方法的具体用法?C++ CStr::Format怎么用?C++ CStr::Format使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CStr的用法示例。


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

示例1: Export

//------------------------------------------------------------------------------
/// \brief
//------------------------------------------------------------------------------
bool NativeExpDdf::Export ()
{
  if (GetPackage()->PackageName() != Packages::DDF)
  {
    return false;
  }

  MfPackage* a_p = GetPackage();
  const double *rhofresh(0), *rhostd(0), *cstd(0);
  if (a_p->GetField(Packages::Ddf::RHOFRESH, &rhofresh) && rhofresh &&
      a_p->GetField(Packages::Ddf::RHOSTD, &rhostd) && rhostd &&
      a_p->GetField(Packages::Ddf::CSTD, &cstd) && cstd)
  {

    CStr desc = "1. RHOFRESH, RHOSTD, CSTD";
    CStr var;
    CStr line;
    int width = util::RealWidth();

    var.Format("%s ", STR(*rhofresh, -1, width, STR_FULLWIDTH));
    line += var;
    var.Format("%s ", STR(*rhostd, -1, width, STR_FULLWIDTH));
    line += var;
    var.Format("%s", STR(*cstd, -1, width, STR_FULLWIDTH));
    line += var;
    AddToStoredLinesDesc(line, desc);
  }

  WriteComments();
  WriteStoredLines();
  return true;
} // MfNativeExpDdf::Export
开发者ID:Aquaveo,项目名称:MFLib,代码行数:35,代码来源:NativeExpDdf.cpp

示例2: ItemToButton

void LumosGame::ItemToButton( const GameItem* item, gamui::Button* button )
{
	CStr<64> text;

	// Set the text to the proper name, if we have it.
	// Then an icon for what it is, and a check
	// mark if the object is in use.
	int value = item->GetValue();
	const char* name = item->ProperName() ? item->ProperName() : item->Name();
	if ( value ) {
		text.Format( "%s\n%d", name, value );
	}
	else {
		text.Format( "%s\n ", name );
	}
	button->SetText( text.c_str() );

	IString decoName = item->keyValues.GetIString( "uiIcon" );
	RenderAtom atom  = LumosGame::CalcUIIconAtom( decoName.c_str(), true );
	atom.renderState = (const void*) UIRenderer::RENDERSTATE_UI_DECO_DISABLED;
	RenderAtom atomD = LumosGame::CalcUIIconAtom( decoName.c_str(), false );
	atomD.renderState = (const void*) UIRenderer::RENDERSTATE_UI_DECO_DISABLED;

	button->SetDeco( atom, atomD );
}
开发者ID:fordream,项目名称:alteraorbis,代码行数:25,代码来源:lumosgame.cpp

示例3: GetPackage

//------------------------------------------------------------------------------
/// \brief
//------------------------------------------------------------------------------
void NativeExpGag::Line2 ()
{
  using namespace MfData::Packages;
  const int *igglst(0), *numgage(0);
  if (GetPackage()->GetField(GAGpack::IGGLST, &igglst) && igglst &&
      GetPackage()->GetField(GAGpack::NUMGAGE, &numgage) && numgage)
  {
    CStr s;
    for (int i=0; i<*numgage; ++i)
    {
      int type = igglst[i*4 + 0];
      if (type >= 0)
      {
        // line 2b: GAGESEG GAGERCH UNIT OUTTYPE
        int gageseg = type;
        int gagerch = igglst[i*4 + 1];
        int unit    = igglst[i*4 + 2];
        int outtype = igglst[i*4 + 3];
        s.Format("%3d %4d %4d %3d", gageseg, gagerch, unit, outtype);
        AddToStoredLinesDesc(s, Desc(3));
      }
      else
      {
        // line 2a: LAKE UNIT {OUTTYPE}
        int lake    = type;
        int unit    = igglst[i*4 + 2];
        int outtype = igglst[i*4 + 3];
        s.Format("%3d %4d %4d", lake, unit, outtype);
        AddToStoredLinesDesc(s, Desc(2));
      }
    }
  }
} // NativeExpGag::Line2
开发者ID:Aquaveo,项目名称:MFLib,代码行数:36,代码来源:NativeExpGag.cpp

示例4: SaveUnitListHdr

void CUnitPane::SaveUnitListHdr()
{
    CListLayoutItem * pLI;
    int               i;
    CStr              Key;
    CStr              Val;

    if (m_pLayout)
    {
        // we are naming items dynamically, so remove them first!
        gpApp->RemoveSection(m_sConfigSectionHdr.GetData());

        for (i=0; i<m_pLayout->Count(); i++)
        {
            pLI = (CListLayoutItem*)m_pLayout->At(i);


            Key.Format("%03d", i);
            Val.Format("%d, %lu, %s, %s", GetColumnWidth(i), pLI->m_Flags, pLI->m_Name, pLI->m_Caption);
            gpApp->SetConfig(m_sConfigSectionHdr.GetData(), Key.GetData(), Val.GetData());
        }

        gpApp->SetConfig(m_sConfigSection.GetData(), SZ_KEY_SORT1, GetSortName(0 ) );
        gpApp->SetConfig(m_sConfigSection.GetData(), SZ_KEY_SORT2, GetSortName(1 ) );
        gpApp->SetConfig(m_sConfigSection.GetData(), SZ_KEY_SORT3, GetSortName(2 ) );
    }
}
开发者ID:ennorehling,项目名称:alh,代码行数:27,代码来源:unitpane.cpp

示例5: EnableButtons

void MapScene::EnableButtons()
{
	Vector2I v = data->destSector;
	CoreScript* cs = CoreScript::GetCore(v);
	CoreScript* homeCore = lumosChitBag->GetHomeCore();

	if (!homeCore) {
		warButton.SetEnabled(false);
		peaceButton.SetEnabled(false);
		peaceButton.SetText("Peace Treaty");
		return;
	}

	warButton.SetEnabled(Team::Instance()->War(cs, homeCore, false, &lumosChitBag->GetSim()->GetCachedWeb()));
	int peace = Team::Instance()->Peace(cs, homeCore, false, &lumosChitBag->GetSim()->GetCachedWeb());
	const Wallet* wallet = homeCore->ParentChit()->GetWallet();

	if (peace > 0 && wallet->HasGold(peace)) {
		CStr<64> str;
		str.Format("Peace Treaty %d Au", peace);
		peaceButton.SetEnabled(true);
		peaceButton.SetText(str.c_str());
	}
	else {
		peaceButton.SetEnabled(false);
		peaceButton.SetText("Peace Treaty");
	}
}
开发者ID:fordream,项目名称:alteraorbis,代码行数:28,代码来源:mapscene.cpp

示例6: STR

//------------------------------------------------------------------------------
/// \brief
//------------------------------------------------------------------------------
void NativeExpMf6Lak::impl::WriteStressPeriodData ()
{
  int w = util::RealWidth();
  MfPackage* p = m_pack->GetPackage();
  const int *nlakes(0), *itmp1(0);
  const Real *rnf(0), *wthdrw(0);
  const double *prcplk(0), *evaplk(0);
  MfPackage* pLak = m_pack->GetGlobal()->GetPackage(Packages::LAK);
  if (pLak->GetField(Packages::LAKpack::NLAKES, &nlakes) && nlakes &&
      p->GetField(Packages::LAKSPpack::ITMP1, &itmp1) && itmp1 &&
      p->GetField(Packages::LAKSPpack::PRCPLK, &prcplk) && prcplk &&
      p->GetField(Packages::LAKSPpack::EVAPLK, &evaplk) && evaplk &&
      p->GetField(Packages::LAKSPpack::RNF, &rnf) && rnf &&
      p->GetField(Packages::LAKSPpack::WTHDRW, &wthdrw) && wthdrw )
  {
    std::stringstream ss;
    ss << "BEGIN PERIOD " << m_pack->GetGlobal()->GetCurrentPeriod();
    m_lines.push_back(ss.str());
    for (int i=0; i<*nlakes; ++i)
    {
      CStr lakId;
      lakId.Format("  %5d ", i+1);
      std::stringstream ss1;
      ss1 << lakId << "rainfall    " << STR(prcplk[i],-1,w,STR_FULLWIDTH) << "\n"
          << lakId << "evaporation " << STR(evaplk[i],-1,w,STR_FULLWIDTH) << "\n"
          << lakId << "runoff      " << STR(rnf[i],-1,w,STR_FULLWIDTH) << "\n"
          << lakId << "withdrawal  " << STR(wthdrw[i],-1,w,STR_FULLWIDTH);
      m_lines.push_back(ss1.str());
    }
    m_lines.push_back("END PERIOD");
    m_lines.push_back("");
  }

} // NativeExpMf6Lak::impl::WriteStressPeriodData
开发者ID:Aquaveo,项目名称:MFLib,代码行数:37,代码来源:NativeExpMf6Lak.cpp

示例7: SetBodyText

void StartGameWidget::SetBodyText()
{
	if (sectors.Empty()) return;

	const SectorData* sd = sectors[currentSector];
	Weather* weather = Weather::Instance();
	Vector2I pos = sd->CoreLoc();
	Vector2F pos2 = ToWorld2F(pos);
	GLASSERT(weather);
	const float AREA = float(SECTOR_SIZE*SECTOR_SIZE);
	int nPorts = 0;
	for (int i = 0; i < 4; ++i) {
		if ((1 << i) & sd->ports) {
			nPorts++;
		}
	}

	int bioFlora = 0;
	int flowers = 0;
	Rectangle2I bi = sd->InnerBounds();
	for (Rectangle2IIterator it(bi); !it.Done(); it.Next()) {
		const WorldGrid& wg = worldMap->GetWorldGrid(it.Pos().x, it.Pos().y);
		if (wg.Plant() >= 7) {
			flowers++;
		}
		else if (wg.Plant()) {
			bioFlora++;
		}
	}

	CStr<400> str;
	str.Format("%s\nTemperature=%d%%  Rain=%d%%  Land=%d%%  Water=%d%%  nPorts=%d\n"
		"bioFlora=%d%%  flowers=%d%%",
		sd->name.c_str(),
		LRint(weather->Temperature(pos2.x, pos2.y) * 100.0f),
		LRint(weather->RainFraction(pos2.x, pos2.y) * 100.0f),
		LRint(100.0f*float(sd->area) / AREA),
		LRint(100.0f*float(AREA - sd->area) / AREA),
		nPorts,
		LRint(100.0f*float(bioFlora) / AREA),
		LRint(100.0f*float(flowers) / AREA));

	bodyLabel.SetText(str.c_str());

	str.Format("%d/%d", currentSector+1, sectors.Size());
	countLabel.SetText(str.c_str());
}
开发者ID:csioza,项目名称:alteraorbis,代码行数:47,代码来源:startwidget.cpp

示例8: GetPackage

//------------------------------------------------------------------------------
/// \brief
//------------------------------------------------------------------------------
void NativeExpLak::Line7to8 ()
{
  const int *nlakes(0), *itmp(0), *nslms(0), *ic(0), *isub(0);
  const Real *sillvt(0);
  MfPackage* a_p = GetPackage();
  MfPackage* a_pLak = GetGlobal()->GetPackage(Packages::LAK);
  if (a_pLak->GetField(Packages::LAKpack::NLAKES, &nlakes) && nlakes &&
      a_p->GetField(Packages::LAKSPpack::ITMP, &itmp) && itmp &&
      a_p->GetField(Packages::LAKSPpack::NSLMS, &nslms) && nslms &&
      a_p->GetField(Packages::LAKSPpack::IC, &ic) && ic &&
      a_p->GetField(Packages::LAKSPpack::ISUB, &isub) && isub &&
      a_p->GetField(Packages::LAKSPpack::SILLVT, &sillvt) && sillvt)
  {
    if (*itmp < 1) return;

    CStr desc = " 7. NSLMS";
    CStr ln;
    ln.Format("%5d", *nslms);
    AddToStoredLinesDesc(ln, desc);

    if (*nslms < 1) return;

    for (int s=0; s<*nslms && ic[s] > 0; ++s)
    {
      desc = "8a. IC ISUB(1) ISUB(2) ............ ISUB(IC)";
      ln.Format("%5d ", ic[s]);
      for (int i=0; i<ic[s]; ++i)
      {
        CStr tmp;
        tmp.Format("%5d ", isub[i*(*nlakes)+s]);
        ln += tmp;
      }
      AddToStoredLinesDesc(ln, desc);

      int width = util::RealWidth();
      ln = "";
      desc = "8b. SILLVT(2) ............. SILLVT(IC)";
      for (int i=0; i<ic[s]-1; ++i)
      {
        CStr tmp;
        tmp.Format("%s ", STR(sillvt[i*(*nlakes)+s], -1, width, STR_FULLWIDTH));
        ln += tmp;
      }
      AddToStoredLinesDesc(ln, desc);
    }
  }
} // NativeExpLak::Line7to8
开发者ID:Aquaveo,项目名称:MFLib,代码行数:50,代码来源:NativeExpLak.cpp

示例9:

//------------------------------------------------------------------------------
/// \brief
//------------------------------------------------------------------------------
CStr NativeExpGag::Line1 ()
{
  using namespace MfData::Packages;
  CStr rval;
  const int *numgage(0);
  if (GetPackage()->GetField(GAGpack::NUMGAGE, &numgage) && numgage)
  {
    rval.Format("%d", *numgage);
  }
  return rval;
} // NativeExpGag::Line1
开发者ID:Aquaveo,项目名称:MFLib,代码行数:14,代码来源:NativeExpGag.cpp

示例10: DoTick

int CoreScript::DoTick(U32 delta)
{
	int nScoreTicks = scoreTicker.Delta(delta);
	int nAITicks = aiTicker.Delta(delta);

	Citizens(0);	// if someone was deleted, the spawn tick will reset.
	int nSpawnTicks = spawnTick.Delta(delta);

	// Clean rock off the core.
	Vector2I pos2i = ToWorld2I(parentChit->Position());
	const WorldGrid& wg = Context()->worldMap->GetWorldGrid(pos2i);
	if (wg.RockHeight()) {
		Context()->worldMap->SetRock(pos2i.x, pos2i.y, 0, false, 0);
	}

	if (InUse()) {
		DoTickInUse(delta, nSpawnTicks);
		UpdateScore(nScoreTicks);
	}
	else {
		DoTickNeutral(delta, nSpawnTicks);
	}
	workQueue->DoTick();

	if (nAITicks) {
		UpdateAI();
	}

	for (int i = 0; i < MAX_SQUADS; ++i) {
		if (squads[i].Empty()) {
			waypoints[i].Clear();
		}
	}

	if (strategicTicker.Delta(delta)) {
		if (this->InUse() && Context()->chitBag->GetHomeCore() != this) {
			DoStrategicTick();
		}
	}

	RenderComponent* rc = parentChit->GetRenderComponent();
	if (rc) {
		int team = parentChit->Team();
		CStr<40> str = "";
		if (this->InUse() && Team::IsDenizen(team)) {
			IString teamName = Team::Instance()->TeamName(team);
			str.Format("%s", teamName.safe_str());
		}
		rc->SetDecoText(str.safe_str());
	}

	return Min(spawnTick.Next(), aiTicker.Next(), scoreTicker.Next());
}
开发者ID:csioza,项目名称:alteraorbis,代码行数:53,代码来源:corescript.cpp

示例11: PlantDef

const GameItem* PlantScript::PlantDef(int plant0Based)
{
	GLASSERT(plant0Based >= 0 && plant0Based < NUM_EXTENDED_PLANT_TYPES);
	if (plantDef[0] == 0) {
		for (int i = 0; i < NUM_EXTENDED_PLANT_TYPES; ++i) {
			CStr<32> str;
			str.Format("plant%d", i);
			plantDef[i] = &ItemDefDB::Instance()->Get(str.c_str());
		}
	}
	GLASSERT(plantDef[plant0Based]);
	return plantDef[plant0Based];
}
开发者ID:fordream,项目名称:alteraorbis,代码行数:13,代码来源:plantscript.cpp

示例12: INoticeWithIcon

WNoticeContactInvite::WNoticeContactInvite(TContact * pContact) : INoticeWithIcon("Invite Peer?", eMenuIcon_Question)
	{
	Assert(pContact != NULL);
	mu_sponsor.pContact = pContact;	// This line is necessary for the notice to delete itself if the contact is deleted
	TAccountXmpp * pAccount = pContact->m_pAccount;
	PSZUC pszNickNameContact = pContact->ChatLog_PszGetNickname();
	setMaximumHeight(300);

	CStr strInvitationXml;
	strInvitationXml.Format("<i u='{[email protected]}' f='^S' p='$i' h='{B/}'/>", &pContact->m_strJidBare, &pAccount->m_strJID, pAccount->m_uServerPort, pAccount->Certificate_PGetBinaryFingerprint());
//	pContact->Invitation_InitFromXml(strInvitationXml);

	NoticeMessage_SetText_VE("Until now, you never received any message from <b>^S</b>.  The text below is a <i>canned invitation</i> you may wish to send <b>^s</b> by email or via other messaging system.", &pContact->m_strJidBare, pszNickNameContact);
	Notice_AddButton(PA_CHILD new WButtonTextWithIcon("Copy|Copy the invitation text below into the clipboard", eMenuIcon_Copy), SL_WNoticeContactInvite(SL_ButtonCopy_clicked));

	CStr strInvitation;
	strInvitation.Format("Hi $s,\nThis is an invitation to create a chat account to communicate with $S.\n\n"
	"If you do not have SocietyPro installed, please click on this download link:\n"
	d_szUrlBaseDowloadInvitation "?Invitation={S/}\n\n"
	"Otherwise, just copy & paste the invitation below into SocietyPro:\n\n" d_szInvitationPrefix "{S/}" d_szInvitationPostfix "\n", pszNickNameContact, &pAccount->m_strJID, &strInvitationXml, &strInvitationXml);
	m_pwEditInvitation = new WEditTextArea(strInvitation);

	PSZAC pszaLabelAndToolTip = (PSZAC)strInvitation.Format("Suggested Invitation to Send:|"
		"<html>Copy and paste this invitation and send it to the person you wish to invite.<br/></br/>"
		"You may use email or other messaging system to send your invitation.<br/><br/>"
		"The content of<br/><br/>{S/}<br/><br/>is<br/><br/>^S<br/><br/>encoded in Base64.  Likewise h='{B/}' is the certificate fingerprint encoded in Base64.</html>", &strInvitationXml, &strInvitationXml, pAccount->Certificate_PGetBinaryFingerprint());
	//m_pwEditInvitationBase64->setMaximumHeight(100);
	m_poLayoutNotice->Layout_PoAddRowLabelsAndWidgets_VEZA(pszaLabelAndToolTip, m_pwEditInvitation, NULL);
	/*
	WEdit * pwEditEmail = new WEdit;
	m_poLayoutBody->Layout_AddLabelAndWidgetH_PA("Email Address:|Enter the email address of the peer you wish to send the invitation.", pwEditEmail);
	WButtonTextWithIcon * m_pButtonConnectNow = new WButtonTextWithIcon("Send Email", eMenuAction_ContactInvite);
	m_poLayoutBody->Layout_PoAddLayoutVerticalWithWidgets_VEZA(m_pButtonConnectNow, NULL);
	Notice_LayoutBodyMoveToBottom(); // Move the fields: Edit Email and the Send button at the bottom.  This is done by removing the layout, and adding it at the bottom
	*/
	}
开发者ID:tcolussi,项目名称:Cambrian-src,代码行数:36,代码来源:WLayoutChatLog.cpp

示例13: if

void
ITreeItem::TreeItemW_SetTextToDisplayMessagesUnread(int cMessagesUnread)
	{
	if (cMessagesUnread <= 0)
		{
		TreeItemW_UpdateText();
		return;
		}
	else if (m_paTreeItemW_YZ != NULL)
		{
		CStr str;
		str.Format("$s ($i)", TreeItem_PszGetNameDisplay(), cMessagesUnread);
		m_paTreeItemW_YZ->setText(0, str);
		}
	}
开发者ID:voodoo-chile,项目名称:Cambrian-src,代码行数:15,代码来源:ITreeItem.cpp

示例14: MAXBOUND

//------------------------------------------------------------------------------
/// \brief
//------------------------------------------------------------------------------
void NativeExpMf6Nam::WriteChdFile ()
{
  MfGlobal *g = m_pack->GetGlobal();
  if (!g) return;
  Mf2kNative* n = m_pack->GetNative();
  if (!n) return;
  CStr baseName = n->FileName();
  util::StripExtensionFromFilename(baseName, baseName);
  baseName += ".chd";

  std::vector<CStr> fieldStrings;
  int MAXBOUND(0);
  CStr chdStr = MfExportUtil::Mf6IboundToChd(g, MAXBOUND, fieldStrings);

  std::vector<CStr> lines;

  lines.push_back(MfExportUtil::GetMf6CommentHeader());
  lines.push_back("BEGIN OPTIONS");
  int saveFlows(0);
  if (g->GetIntVar("MF6_SAVE_FLOWS", saveFlows) && saveFlows)
  {
    lines.push_back("  SAVE_FLOWS");
  }
  lines.push_back("END OPTIONS");
  lines.push_back("");

  lines.push_back("BEGIN DIMENSIONS");
  CStr dimStr;
  dimStr.Format("  MAXBOUND %d", MAXBOUND);
  lines.push_back(dimStr);
  lines.push_back("END DIMENSIONS");
  lines.push_back("");

  lines.push_back("BEGIN PERIOD 1");
  lines.push_back(chdStr);
  lines.push_back("END PERIOD 1");

  FILE *fp = fopen(baseName.c_str(), "w");
  if (fp)
  {
    for (size_t i=0; i<lines.size(); ++i)
    {
      fprintf(fp, "%s\n", lines[i].c_str());
    }
    fclose(fp);
  }
} // NativeExpMf6Nam::WriteChdFile
开发者ID:Aquaveo,项目名称:MFLib,代码行数:50,代码来源:NativeExpMf6Nam.cpp

示例15: setTypes

//------------------------------------------------------------------------------
/// \brief
//------------------------------------------------------------------------------
bool NativeExpMf6Nam::ValidPackage (const CStr& a_ftype)
{
  const int NUMTYPES = 21;
  std::string types[NUMTYPES] =
    { "DIS", "DISV", "DISU", "IC", "OC", "NPF", "HFB", "STO", "CHD", "WEL",
      "DRN", "RIV", "GHB", "RCH", "EVT", "MAW", "SFR", "LAK", "UZF", "MVR",
      "GNC" };
  std::set<std::string> setTypes(&types[0], &types[NUMTYPES]);
  if (setTypes.find(a_ftype) != setTypes.end())
  {
    return true;
  }
  CStr msg;
  msg.Format("WARNING: Package %s is not supported for conversion to MF6.", a_ftype);
  printf("%s\n", msg.c_str());
  return false;
} // NativeExpMf6Nam::ValidPackage
开发者ID:Aquaveo,项目名称:MFLib,代码行数:20,代码来源:NativeExpMf6Nam.cpp


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