本文整理汇总了C++中StdStrBuf::Append方法的典型用法代码示例。如果您正苦于以下问题:C++ StdStrBuf::Append方法的具体用法?C++ StdStrBuf::Append怎么用?C++ StdStrBuf::Append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StdStrBuf
的用法示例。
在下文中一共展示了StdStrBuf::Append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Enumerate
BOOL C4GameObjects::Save(const char *szFilename, BOOL fSaveGame,
bool fSaveInactive) {
// Enumerate
Enumerate();
InactiveObjects.Enumerate();
Game.ScriptEngine.Strings.EnumStrings();
// Decompile objects to buffer
StdStrBuf Buffer;
bool fSuccess = DecompileToBuf_Log<StdCompilerINIWrite>(
mkParAdapt(*this, false, !fSaveGame), &Buffer, szFilename);
// Decompile inactives
if (fSaveInactive) {
StdStrBuf InactiveBuffer;
fSuccess &= DecompileToBuf_Log<StdCompilerINIWrite>(
mkParAdapt(InactiveObjects, false, !fSaveGame), &InactiveBuffer,
szFilename);
Buffer.Append("\r\n");
Buffer.Append(InactiveBuffer);
}
// Denumerate
InactiveObjects.Denumerate();
Denumerate();
// Error?
if (!fSuccess) return FALSE;
// Write
return Buffer.SaveToFile(szFilename);
}
示例2:
bool C4TextureMap::SaveMap(C4Group &hGroup, const char *szEntryName)
{
#ifdef C4ENGINE
// build file in memory
StdStrBuf sTexMapFile;
// add desc
sTexMapFile.Append("# Automatically generated texture map" LineFeed);
sTexMapFile.Append("# Contains material-texture-combinations added at runtime" LineFeed);
// add overload-entries
if (fOverloadMaterials) sTexMapFile.Append("# Import materials from global file as well" LineFeed "OverloadMaterials" LineFeed);
if (fOverloadTextures) sTexMapFile.Append("# Import textures from global file as well" LineFeed "OverloadTextures" LineFeed);
sTexMapFile.Append(LineFeed);
// add entries
for (int32_t i = 0; i < C4M_MaxTexIndex; i++)
if (!Entry[i].isNull())
{
// compose line
sTexMapFile.AppendFormat("%d=%s-%s" LineFeed, i, Entry[i].GetMaterialName(), Entry[i].GetTextureName());
}
// create new buffer allocated with new [], because C4Group cannot handle StdStrBuf-buffers
size_t iBufSize = sTexMapFile.getLength();
BYTE *pBuf = new BYTE[iBufSize];
memcpy(pBuf, sTexMapFile.getData(), iBufSize);
// add to group
bool fSuccess = !!hGroup.Add(szEntryName, pBuf, iBufSize, false, true);
if (!fSuccess) delete [] pBuf;
// done
return fSuccess;
#else
return FALSE;
#endif
}
示例3: GetFilename
bool C4DownloadDlg::DownloadFile(const char *szDLType, C4GUI::Screen *pScreen, const char *szURL, const char *szSaveAsFilename, const char *szNotFoundMessage)
{
// log it
LogF(LoadResStr("IDS_PRC_DOWNLOADINGFILE"), szURL);
// show download dialog
C4DownloadDlg *pDlg = new C4DownloadDlg(szDLType);
if (!pDlg->ShowModal(pScreen, szURL, szSaveAsFilename))
{
// show an appropriate error
const char *szError = pDlg->GetError();
if (!szError || !*szError) szError = LoadResStr("IDS_PRC_UNKOWNERROR");
StdStrBuf sError;
sError.Format(LoadResStr("IDS_PRC_DOWNLOADERROR"), GetFilename(szURL), szError);
// it's a 404: display extended message
if (SSearch(szError, "404") && szNotFoundMessage)
{ sError.Append("|"); sError.Append(szNotFoundMessage); }
// display message
pScreen->ShowMessageModal(sError.getData(), FormatString(LoadResStr("IDS_CTL_DL_TITLE"), szDLType).getData(), C4GUI::MessageDialog::btnOK, C4GUI::Ico_Error, NULL);
delete pDlg;
return false;
}
LogF(LoadResStr("IDS_PRC_DOWNLOADCOMPLETE"), szURL);
delete pDlg;
return true;
}
示例4: if
void C4GameSave::WriteDescPlayers(StdStrBuf &sBuf, bool fByTeam, int32_t idTeam)
{
// write out all players; only if they match the given team if specified
C4PlayerInfo *pPlr; bool fAnyPlrWritten = false;
for (int i = 0; (pPlr = Game.PlayerInfos.GetPlayerInfoByIndex(i)); i++)
if (pPlr->HasJoined() && !pPlr->IsRemoved() && !pPlr->IsInvisible())
{
if (fByTeam)
{
if (idTeam)
{
// match team
if (pPlr->GetTeam() != idTeam) continue;
}
else
{
// must be in no known team
if (Game.Teams.GetTeamByID(pPlr->GetTeam())) continue;
}
}
if (fAnyPlrWritten)
sBuf.Append(", ");
else if (fByTeam && idTeam)
{
C4Team *pTeam = Game.Teams.GetTeamByID(idTeam);
if (pTeam) sBuf.AppendFormat("%s: ", pTeam->GetName());
}
sBuf.Append(pPlr->GetName());
fAnyPlrWritten = true;
}
if (fAnyPlrWritten) WriteDescLineFeed(sBuf);
}
示例5:
void C4GameSave::WriteDescDefinitions(StdStrBuf &sBuf)
{
// Definition specs
if (Game.DefinitionFilenames[0])
{
char szDef[_MAX_PATH+1];
// Desc
sBuf.Append(LoadResStr("IDS_DESC_DEFSPECS"));
// Get definition modules
for (int cnt=0; SGetModule(Game.DefinitionFilenames,cnt,szDef); cnt++)
{
// Get exe relative path
StdStrBuf sDefFilename;
sDefFilename.Copy(Config.AtRelativePath(szDef));
// Convert rtf backslashes
sDefFilename.Replace("\\", "\\\\");
// Append comma
if (cnt>0) sBuf.Append(", ");
// Apend to desc
sBuf.Append(sDefFilename);
}
// End of line
WriteDescLineFeed(sBuf);
}
}
示例6: GetFilename
StdStrBuf C4FileSelDlg::GetSelection(const char *szFixedSelection,
bool fFilenameOnly) const {
StdStrBuf sResult;
if (!IsMultiSelection()) {
// get single selected file for single selection dlg
if (pSelection)
sResult.Copy(fFilenameOnly ? GetFilename(pSelection->GetFilename())
: pSelection->GetFilename());
} else {
// force fixed selection first
if (szFixedSelection) sResult.Append(szFixedSelection);
// get ';'-seperated list for multi selection dlg
for (ListItem *pFileItem =
static_cast<ListItem *>(pFileListBox->GetFirst());
pFileItem; pFileItem = static_cast<ListItem *>(pFileItem->GetNext()))
if (pFileItem->IsChecked()) {
const char *szAppendFilename = pFileItem->GetFilename();
if (fFilenameOnly) szAppendFilename = GetFilename(szAppendFilename);
// prevent adding entries twice (especially those from the fixed
// selection list)
if (!SIsModule(sResult.getData(), szAppendFilename)) {
if (sResult.getLength()) sResult.AppendChar(';');
sResult.Append(szAppendFilename);
}
}
}
return sResult;
}
示例7: loader
void C4Def::LoadMeshMaterials(C4Group &hGroup, C4DefGraphicsPtrBackup *gfx_backup)
{
// Load all mesh materials from this folder
C4DefAdditionalResourcesLoader loader(hGroup);
hGroup.ResetSearch();
char MaterialFilename[_MAX_PATH + 1]; *MaterialFilename = 0;
for (const auto &mat : mesh_materials)
{
::MeshMaterialManager.Remove(mat, &gfx_backup->GetUpdater());
}
mesh_materials.clear();
while (hGroup.FindNextEntry(C4CFN_DefMaterials, MaterialFilename, NULL, !!*MaterialFilename))
{
StdStrBuf material;
if (hGroup.LoadEntryString(MaterialFilename, &material))
{
try
{
StdStrBuf buf;
buf.Copy(hGroup.GetName());
buf.Append("/"); buf.Append(MaterialFilename);
auto new_materials = ::MeshMaterialManager.Parse(material.getData(), buf.getData(), loader);
mesh_materials.insert(new_materials.begin(), new_materials.end());
}
catch (const StdMeshMaterialError& ex)
{
DebugLogF("Failed to read material script: %s", ex.what());
}
}
}
}
示例8: pMeshUpdate
C4DefGraphicsPtrBackup::C4DefGraphicsPtrBackup(C4DefGraphics *pSourceGraphics):
MeshMaterialUpdate(::MeshMaterialManager), pMeshUpdate(NULL)
{
// assign graphics + def
pGraphicsPtr = pSourceGraphics;
pDef = pSourceGraphics->pDef;
// assign name
const char *szName = pGraphicsPtr->GetName();
if (szName) SCopy(szName, Name, C4MaxName); else *Name=0;
// Remove all mesh materials that were loaded from this definition
for(StdMeshMatManager::Iterator iter = ::MeshMaterialManager.Begin(); iter != MeshMaterialManager.End(); )
{
StdStrBuf Filename;
Filename.Copy(pDef->Filename);
Filename.Append("/"); Filename.Append(GetFilename(iter->FileName.getData()));
if(Filename == iter->FileName)
iter = ::MeshMaterialManager.Remove(iter, &MeshMaterialUpdate);
else
++iter;
}
// assign mesh update
if(pSourceGraphics->Type == C4DefGraphics::TYPE_Mesh)
pMeshUpdate = new StdMeshUpdate(*pSourceGraphics->Mesh);
// create next graphics recursively
C4DefGraphics *pNextGfx = pGraphicsPtr->pNext;
if (pNextGfx)
pNext = new C4DefGraphicsPtrBackup(pNextGfx);
else
pNext = NULL;
}
示例9: Min
StdStrBuf C4Shader::Build(const ShaderSliceList &Slices, bool fDebug)
{
// At the start of the shader set the #version and number of
// available uniforms
StdStrBuf Buf;
#ifndef USE_CONSOLE
GLint iMaxFrags = 0, iMaxVerts = 0;
glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB, &iMaxFrags);
glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, &iMaxVerts);
#else
int iMaxFrags = INT_MAX, iMaxVerts = INT_MAX;
#endif
Buf.Format("#version %d\n"
"#define MAX_FRAGMENT_UNIFORM_COMPONENTS %d\n"
"#define MAX_VERTEX_UNIFORM_COMPONENTS %d\n",
C4Shader_Version, iMaxFrags, iMaxVerts);
// Put slices
int iPos = -1, iNextPos = -1;
do
{
iPos = iNextPos; iNextPos = C4Shader_LastPosition+1;
// Add all slices at the current level
if (fDebug && iPos > 0)
Buf.AppendFormat("\t// Position %d:\n", iPos);
for (ShaderSliceList::const_iterator pSlice = Slices.begin(); pSlice != Slices.end(); pSlice++)
{
if (pSlice->Position < iPos) continue;
if (pSlice->Position > iPos)
{
iNextPos = Min(iNextPos, pSlice->Position);
continue;
}
// Same position - add slice!
if (fDebug)
{
if (pSlice->Source.getLength())
Buf.AppendFormat("\t// Slice from %s:\n", pSlice->Source.getData());
else
Buf.Append("\t// Built-in slice:\n");
}
Buf.Append(pSlice->Text);
if (Buf[Buf.getLength()-1] != '\n')
Buf.AppendChar('\n');
}
// Add seperator - only priority (-1) is top-level
if (iPos == -1) {
Buf.Append("void main() {\n");
}
}
while (iNextPos <= C4Shader_LastPosition);
// Terminate
Buf.Append("}\n");
return Buf;
}
示例10:
void C4GameSave::WriteDescNetworkClients(StdStrBuf &sBuf)
{
// Desc
sBuf.Append(LoadResStr("IDS_DESC_CLIENTS"));
// Client names
for (C4Network2Client *pClient=::Network.Clients.GetNextClient(nullptr); pClient; pClient=::Network.Clients.GetNextClient(pClient))
{ sBuf.Append(", "); sBuf.Append(pClient->getName()); }
// End of line
WriteDescLineFeed(sBuf);
}
示例11: mkNamingAdapt
StdStrBuf C4Playback::ReWriteText() {
// Would work, too, but is currently too slow due to bad buffering inside
// StdCompilerINIWrite:
// return
// DecompileToBuf<StdCompilerINIWrite>(mkNamingAdapt(mkSTLContainerAdapt(chunks),
// "Rec"));
StdStrBuf Output;
for (chunks_t::const_iterator i = chunks.begin(); i != chunks.end(); i++) {
Output.Append(
static_cast<const StdStrBuf &>(DecompileToBuf<StdCompilerINIWrite>(
mkNamingAdapt(mkDecompileAdapt(*i), "Rec"))));
Output.Append("\n\n");
}
return Output;
}
示例12:
StdStrBuf C4MusicFileOgg::GetDebugInfo() const
{
StdStrBuf result;
result.Append(FileName);
result.AppendFormat("[%.0lf]", last_playback_pos_sec);
result.AppendChar('[');
bool sec = false;
for (auto i = categories.cbegin(); i != categories.cend(); ++i)
{
if (sec) result.AppendChar(',');
result.Append(i->getData());
sec = true;
}
result.AppendChar(']');
return result;
}
示例13: GetPrefColorValue
bool C4PlayerInfoCore::Load(C4Group &hGroup)
{
// New version
StdStrBuf Source;
if (hGroup.LoadEntryString(C4CFN_PlayerInfoCore,&Source))
{
// Compile
StdStrBuf GrpName = hGroup.GetFullName(); GrpName.Append(DirSep C4CFN_PlayerInfoCore);
if (!CompileFromBuf_LogWarn<StdCompilerINIRead>(*this, Source, GrpName.getData()))
return false;
// Pref for AutoContextMenus is still undecided: default by player's control style
if (OldPrefAutoContextMenu == -1)
OldPrefAutoContextMenu = OldPrefControlStyle;
// Determine true color from indexed pref color
if (!PrefColorDw)
PrefColorDw = GetPrefColorValue(PrefColor);
// Validate colors
PrefColorDw &= 0xffffff;
PrefColor2Dw &= 0xffffff;
// Validate name
C4Markup::StripMarkup(PrefName);
// Success
return true;
}
// Old version no longer supported - sorry
return false;
}
示例14: SLen
void C4Console::PlayerJoin()
{
// Get player file name(s)
StdCopyStrBuf c4pfile("");
if (!FileSelect(&c4pfile,
"OpenClonk Player\0*.ocp\0\0",
OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT | OFN_EXPLORER
)) return;
// Multiple players
if (DirectoryExists(c4pfile.getData()))
{
const char *cptr = c4pfile.getData() + SLen(c4pfile.getData()) + 1;
while (*cptr)
{
StdStrBuf f;
f.Copy(c4pfile.getData());
f.AppendBackslash(); f.Append(cptr);
cptr += SLen(cptr)+1;
::Players.JoinNew(f.getData());
}
}
// Single player
else
{
::Players.JoinNew(c4pfile.getData());
}
}
示例15:
void C4DefGraphicsPtrBackup::Add(C4DefGraphics* pGfx)
{
for(C4DefGraphics* pCur = pGfx; pCur != NULL; pCur = pCur->pNext)
Entries.push_back(new C4DefGraphicsPtrBackupEntry(pCur));
// Remove all mesh materials that were loaded from this definition
C4Def* pDef = pGfx->pDef;
for(StdMeshMatManager::Iterator iter = ::MeshMaterialManager.Begin(); iter != MeshMaterialManager.End(); )
{
StdStrBuf Filename;
Filename.Copy(pDef->Filename);
Filename.Append("/"); Filename.Append(GetFilename(iter->FileName.getData()));
if(Filename == iter->FileName)
iter = ::MeshMaterialManager.Remove(iter, &MeshMaterialUpdate);
else
++iter;
}
}