这篇教程C++ strPatternSubst函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中strPatternSubst函数的典型用法代码示例。如果您正苦于以下问题:C++ strPatternSubst函数的具体用法?C++ strPatternSubst怎么用?C++ strPatternSubst使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了strPatternSubst函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: strPatternSubstALERROR CSingleItem::LoadFromXML (SDesignLoadCtx &Ctx, CXMLElement *pDesc)// LoadFromXML//// Load from XML { ALERROR error; if (error = m_pItemType.LoadUNID(Ctx, pDesc->GetAttribute(ITEM_ATTRIB))) return error; m_iDamaged = pDesc->GetAttributeInteger(DAMAGED_ATTRIB); m_bDebugOnly = pDesc->GetAttributeBool(DEBUG_ONLY_ATTRIB); if (m_pItemType.GetUNID() == 0) { CString sUNID = pDesc->GetAttribute(ITEM_ATTRIB); if (sUNID.IsBlank()) Ctx.sError = strPatternSubst(CONSTLIT("<Item> element missing item attribute.")); else Ctx.sError = strPatternSubst(CONSTLIT("Invalid item UNID: %s"), sUNID); return ERR_FAIL; } if (error = m_Enhanced.InitFromXML(Ctx, pDesc)) return error; return NOERROR; }
开发者ID:alanhorizon,项目名称:Transcendence,代码行数:30,
示例2: GetPowerRatingCString CDeviceClass::GetReferencePower (CItemCtx &Ctx)// GetReferencePower//// Returns a string for the reference relating to the power required for// this device. { int iPower = GetPowerRating(Ctx); // Compute the power units CString sUnit; if (iPower == 0) return NULL_STR; else if (iPower >= 10000) { sUnit = CONSTLIT("GW"); iPower = iPower / 1000; } else sUnit = CONSTLIT("MW"); // Decimal int iMW = iPower / 10; int iMWDecimal = iPower % 10; if (iMW >= 100 || iMWDecimal == 0) return strPatternSubst(CONSTLIT("%d %s"), iMW, sUnit); else return strPatternSubst(CONSTLIT("%d.%d %s"), iMW, iMWDecimal, sUnit); }
开发者ID:bmer,项目名称:Mammoth,代码行数:33,
示例3: strPatternSubstvoid CUIHelper::CreateClassInfoCargo (CShipClass *pClass, const CDeviceDescList &Devices, int x, int y, int cxWidth, DWORD dwOptions, int *retcyHeight, IAnimatron **retpInfo) const// CreateClassInfoCargo//// Creates info about the ship class' cargo { const CVisualPalette &VI = m_HI.GetVisuals(); CDeviceClass *pCargoExtension = Devices.GetNamedDevice(devCargo); int iCargoSpace = pClass->GetCargoSpace(); if (pCargoExtension) iCargoSpace += pCargoExtension->GetCargoSpace(); // Icon CItemType *pItemIcon = (pCargoExtension ? pCargoExtension->GetItemType() : g_pUniverse->FindItemType(CARGO_HOLD_EXPANSION_UNID)); // Text CString sText = strPatternSubst(CONSTLIT("{/rtf {/f:LargeBold;/c:%d; %s} {/f:MediumBold;/c:%d; %s}/n{/f:Medium;/c:%d; %s}}"), CG16bitImage::RGBFromPixel(VI.GetColor(colorTextDialogLabel)), strFromInt(iCargoSpace, TRUE), CG16bitImage::RGBFromPixel(VI.GetColor(colorTextDialogInput)), (pCargoExtension ? strPatternSubst(CONSTLIT("ton %s"), CTextBlock::Escape(pCargoExtension->GetItemType()->GetNounPhrase(nounActual))) : CONSTLIT("ton cargo hold")), CG16bitImage::RGBFromPixel(VI.GetColor(colorTextDialogLabel)), (iCargoSpace < pClass->GetMaxCargoSpace() ? strPatternSubst(CONSTLIT("optional expansion up to %d tons"), pClass->GetMaxCargoSpace()) : CONSTLIT("cargo space cannot be expanded"))); CreateClassInfoSpecialItem(pItemIcon, sText, x, y, cxWidth, dwOptions, retcyHeight, retpInfo); }
开发者ID:Sdw195,项目名称:Transcendence,代码行数:30,
示例4: switchCString CCInteger::Print (CCodeChain *pCC, DWORD dwFlags)// Print//// Returns a text representation of this item { // If this is an error code, translate it if (IsError()) { switch (m_iValue) { case CCRESULT_NOTFOUND: return strPatternSubst(LITERAL("[%d] Item not found."), m_iValue); case CCRESULT_CANCEL: return strPatternSubst(LITERAL("[%d] Operation canceled."), m_iValue); case CCRESULT_DISKERROR: return strPatternSubst(LITERAL("[%d] Disk error."), m_iValue); default: return strPatternSubst(LITERAL("[%d] Unknown error."), m_iValue); } } // Otherwise, just print the integer value else return strFromInt(m_iValue, TRUE); }
开发者ID:Sdw195,项目名称:Transcendence,代码行数:32,
示例5: CONSTLITALERROR CDesignCollection::AddEntry (SDesignLoadCtx &Ctx, CDesignType *pEntry)// AddEntry//// Adds an entry to the collection { ALERROR error; DWORD dwUNID = pEntry->GetUNID(); // If this is an extension, then add to the appropriate extension CDesignTable *pTable = NULL; if (Ctx.pExtension) { pTable = &Ctx.pExtension->Table; // If the UNID of the entry does not belong to the extension, then make sure it // overrides a valid base entry if (!Ctx.pExtension->bRegistered && (dwUNID & UNID_DOMAIN_AND_MODULE_MASK) != (Ctx.pExtension->dwUNID & UNID_DOMAIN_AND_MODULE_MASK)) { // Cannot override AdventureDesc if (pEntry->GetType() == designAdventureDesc) { Ctx.sError = CONSTLIT("<AdventureDesc> UNID must be part of extension."); return ERR_FAIL; } // Make sure we override a base type else if (m_Base.FindByUNID(dwUNID) == NULL) { Ctx.sError = strPatternSubst(CONSTLIT("Invalid UNID: %x [does not match extension UNID or override base type]"), dwUNID); return ERR_FAIL; } } } // Otherwise, add to the base design types else pTable = &m_Base; // Add if (error = pTable->AddEntry(pEntry)) { if (pTable->FindByUNID(dwUNID)) Ctx.sError = strPatternSubst(CONSTLIT("Duplicate UNID: %x"), dwUNID); else Ctx.sError = strPatternSubst(CONSTLIT("Error adding design entry UNID: %x"), dwUNID); return error; } return NOERROR; }
开发者ID:Sdw195,项目名称:Transcendence,代码行数:60,
示例6: CONSTLITALERROR CMarkovWordGenerator::WriteAsXML (IWriteStream *pOutput)// WriteAsXML//// Writes out the Markov chain data to an XML element { ALERROR error; int i; // Open tag CString sData; sData = CONSTLIT("/t<WordGenerator>/r/n"); if (error = pOutput->Write(sData.GetPointer(), sData.GetLength(), NULL)) return error; // Fragments for (i = 0; i < m_Table.GetCount(); i++) { sData = CONSTLIT("/t/t<Syl>"); if (error = pOutput->Write(sData.GetPointer(), sData.GetLength(), NULL)) return error; sData = strPatternSubst(CONSTLIT("%s;%d;%d;"), strToXMLText(CString(m_Table[i]->sFrag)), m_Table[i]->dwCount, m_Table[i]->dwFlags); if (error = pOutput->Write(sData.GetPointer(), sData.GetLength(), NULL)) return error; SChainChar *pChain = GetChain(m_Table[i]); while ((*(DWORD *)pChain) != 0) { char chChar[2]; chChar[0] = pChain->chChar; chChar[1] = '/0'; CString sChar = strToXMLText(CString(chChar, 1, true)); sData = strPatternSubst(CONSTLIT("%s;%d;"), sChar, pChain->dwCount); if (error = pOutput->Write(sData.GetPointer(), sData.GetLength(), NULL)) return error; pChain++; } sData = CONSTLIT("</Syl>/r/n"); if (error = pOutput->Write(sData.GetPointer(), sData.GetLength(), NULL)) return error; } // Done // Close tag sData = CONSTLIT("/t</WordGenerator>/r/n"); if (error = pOutput->Write(sData.GetPointer(), sData.GetLength(), NULL)) return error; return NOERROR; }
开发者ID:Sdw195,项目名称:Transcendence,代码行数:59,
示例7: arcDecompressFilebool arcDecompressFile (const CString &sArchive, const CString &sFilename, IWriteStream &Output, CString *retsError)// arcDecompressFile//// Unzips to a stream. { unzFile theZipFile = unzOpen(sArchive.GetASCIIZPointer()); if (theZipFile == NULL) { *retsError = strPatternSubst(CONSTLIT("Unable to open file: %s."), sArchive); return false; } if (unzLocateFile(theZipFile, sFilename.GetASCIIZPointer(), 0) != UNZ_OK) { unzClose(theZipFile); *retsError = strPatternSubst(CONSTLIT("Unable to find file in archive: %s."), sFilename); return false; } if (unzOpenCurrentFile(theZipFile) != UNZ_OK) { unzClose(theZipFile); *retsError = strPatternSubst(CONSTLIT("Unable to open file in archive: %s."), sFilename); return false; } while (true) { char szBuffer[BUFFER_SIZE]; int iRead = unzReadCurrentFile(theZipFile, szBuffer, BUFFER_SIZE); if (iRead == 0) break; else if (iRead < 0) { unzCloseCurrentFile(theZipFile); unzClose(theZipFile); *retsError = CONSTLIT("Error reading archive."); return false; } Output.Write(szBuffer, iRead); } // Returns UNZ_CRCERROR if the file failed its CRC check. if (unzCloseCurrentFile(theZipFile) != UNZ_OK) { unzClose(theZipFile); *retsError = strPatternSubst(CONSTLIT("File in archive corrupted: %s."), sArchive); return false; } unzClose(theZipFile); return true; }
开发者ID:gmoromisato,项目名称:Dev,代码行数:59,
示例8: GetTypeDescCString GetTypeDesc (CDesignType *pType) { CString sName = pType->GetTypeName(); if (sName.IsBlank()) return strPatternSubst(CONSTLIT("%08x: [%s]"), pType->GetUNID(), pType->GetTypeClassName()); else return strPatternSubst(CONSTLIT("%08x: %s [%s]"), pType->GetUNID(), sName, pType->GetTypeClassName()); }
开发者ID:AvanWolf,项目名称:Transcendence,代码行数:8,
示例9: CalcMinMaxHPCString CShieldClass::GetReference (CItemCtx &Ctx, int iVariant, DWORD dwFlags)// GetReference//// Returns a string that describes the basic attributes// of this shield//// Example://// 20 hp (average regen); 100MW { int i; CString sReference; CString sRegeneration; const CItemEnhancement &Mods = Ctx.GetMods(); // Compute the strength string int iMin, iMax; CalcMinMaxHP(Ctx, m_iMaxCharges, 0, 0, &iMin, &iMax); // Compute the regeneration if (m_iRegenHP > 0) { int iRate = (int)((10.0 * g_TicksPerSecond * m_iRegenHP / m_iRegenRate) + 0.5); if (iRate == 0) sRegeneration = CONSTLIT("<0.1 hp/sec"); else if ((iRate % 10) == 0) sRegeneration = strPatternSubst(CONSTLIT("%d hp/sec"), iRate / 10); else sRegeneration = strPatternSubst(CONSTLIT("%d.%d hp/sec"), iRate / 10, iRate % 10); } else sRegeneration = CONSTLIT("none"); sReference = strPatternSubst("%s C++ strTemp函数代码示例 C++ strPath函数代码示例
|