本文整理汇总了C++中StdStrBuf::AppendChar方法的典型用法代码示例。如果您正苦于以下问题:C++ StdStrBuf::AppendChar方法的具体用法?C++ StdStrBuf::AppendChar怎么用?C++ StdStrBuf::AppendChar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StdStrBuf
的用法示例。
在下文中一共展示了StdStrBuf::AppendChar方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2:
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;
}
示例3: 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;
}
示例4: LogFatal
bool LogFatal(const char *szMessage)
{
if (!szMessage) szMessage = "(null)";
// add to fatal error message stack - if not already in there (avoid duplication)
if (!SSearch(sFatalError.getData(), szMessage))
{
if (!sFatalError.isNull()) sFatalError.AppendChar('|');
sFatalError.Append(szMessage);
}
// write to log - note that Log might overwrite a static buffer also used in szMessage
return !!Log(FormatString(LoadResStr("IDS_ERR_FATAL"), szMessage).getData());
}
示例5: defined
bool C4VectorFont::Init(C4Group &hGrp, const char *szFilename, C4Config &rCfg)
{
// name by file
Name.Copy(GetFilenameOnly(szFilename));
#if defined(_WIN32) && !defined(HAVE_FREETYPE)
// check whether group is directory or packed
if (!hGrp.IsPacked())
{
// it's open: use the file directly
SCopy(hGrp.GetFullName().getData(), FileName, _MAX_PATH);
AppendBackslash(FileName);
SAppend(szFilename, FileName);
if (!FileExists(FileName)) { *FileName=0; return false; }
fIsTempFile = false;
}
else
{
// it's packed: extract to temp path
SCopy(rCfg.AtTempPath(szFilename), FileName, _MAX_PATH);
// make sure the filename is not in use, in case multiple instances of the engine are run
if (FileExists(FileName))
{
RemoveExtension(FileName);
StdStrBuf sNewFilename;
for (int i=0; i<1000; ++i)
{
sNewFilename.Format("%s%x", FileName, (int)rand());
if (*GetExtension(szFilename))
{
sNewFilename.AppendChar('.');
sNewFilename.Append(GetExtension(szFilename));
}
if (!FileExists(sNewFilename.getData())) break;
}
SCopy(sNewFilename.getData(), FileName, _MAX_PATH);
}
if (!hGrp.ExtractEntry(szFilename, FileName)) { *FileName=0; return false; }
fIsTempFile = true;
}
// add the font resource
//if (!AddFontResourceEx(FileName, FR_PRIVATE, NULL)) requires win2k
if (!AddFontResource(FileName))
{
if (fIsTempFile) EraseFile(FileName);
*FileName='\0';
return false;
}
#else
if (!hGrp.LoadEntry(szFilename, Data)) return false;
#endif
// success
return true;
}
示例6:
StdStrBuf C4PropListStatic::GetDataString() const
{
StdStrBuf r;
if (Parent)
{
r.Take(Parent->GetDataString());
r.AppendChar('.');
}
assert(ParentKeyName);
if (ParentKeyName)
r.Append(ParentKeyName->GetData());
return r;
}
示例7:
bool C4MusicSystem::InitForScenario(C4Group & hGroup)
{
// check if the scenario contains music
bool fLocalMusic = false;
StdStrBuf MusicDir;
if (GrpContainsMusic(hGroup))
{
// clear global songs
ClearSongs();
fLocalMusic = true;
// add songs
MusicDir.Take(Game.ScenarioFile.GetFullName());
LoadDir(MusicDir.getData());
// log
LogF(LoadResStr("IDS_PRC_LOCALMUSIC"), MusicDir.getData());
}
// check for music folders in group set
C4Group *pMusicFolder = NULL;
while ((pMusicFolder = Game.GroupSet.FindGroup(C4GSCnt_Music, pMusicFolder)))
{
if (!fLocalMusic)
{
// clear global songs
ClearSongs();
fLocalMusic = true;
}
// add songs
MusicDir.Take(pMusicFolder->GetFullName());
MusicDir.AppendChar(DirectorySeparator);
MusicDir.Append(C4CFN_Music);
LoadDir(MusicDir.getData());
// log
LogF(LoadResStr("IDS_PRC_LOCALMUSIC"), MusicDir.getData());
}
// no music?
if (!SongCount) return false;
// set play list
SetPlayList(0);
// ok
return true;
}
示例8:
StdStrBuf C4KeyCodeEx::ToString(bool fHumanReadable, bool fShort) const
{
static StdStrBuf sResult;
sResult.Clear();
// Add shift
for (DWORD dwShiftCheck = KEYS_First; dwShiftCheck <= KEYS_Max; dwShiftCheck <<= 1)
if (dwShiftCheck & dwShift)
{
sResult.Append(KeyShift2String((C4KeyShiftState) dwShiftCheck));
sResult.AppendChar('+');
}
// Add key
if (sResult.getLength())
{
sResult.Append(KeyCode2String(Key, fHumanReadable, fShort));
return sResult;
}
else
{
return KeyCode2String(Key, fHumanReadable, fShort);
}
}
示例9: GetIndexedPlayer
StdStrBuf C4Team::GetNameWithParticipants() const
{
// compose team name like "Team 1 (boni, GhostBear, Clonko)"
// or just "Team 1" for empty team
StdStrBuf sTeamName;
sTeamName.Copy(GetName());
if (GetPlayerCount())
{
sTeamName.Append(" (");
int32_t iTeamPlrCount=0;
for (int32_t j=0; j<GetPlayerCount(); ++j)
{
int32_t iPlr = GetIndexedPlayer(j);
C4PlayerInfo *pPlrInfo;
if (iPlr) if ((pPlrInfo = Game.PlayerInfos.GetPlayerInfoByID(iPlr)))
{
if (iTeamPlrCount++) sTeamName.Append(", ");
sTeamName.Append(pPlrInfo->GetName());
}
}
sTeamName.AppendChar(')');
}
return sTeamName;
}
示例10: ircExtractPar
void C4Network2IRCClient::OnNumericCommand(const char *szSender, int iCommand, const char *szParameters)
{
bool fShowMessage = true;
// Get target
StdStrBuf Target = ircExtractPar(&szParameters);
// Handle command
switch(iCommand)
{
case 433: // Nickname already in use
{
StdStrBuf DesiredNick = ircExtractPar(&szParameters);
// Automatically try to choose a new one
DesiredNick.AppendChar('_');
Send("NICK", DesiredNick.getData());
break;
}
case 376: // End of MOTD
case 422: // MOTD missing
// Let's take this a sign that the connection is established.
OnConnected();
break;
case 331: // No topic set
case 332: // Topic notify / change
{
// Get Channel name and topic
StdStrBuf Channel = ircExtractPar(&szParameters);
StdStrBuf Topic = (iCommand == 332 ? ircExtractPar(&szParameters) : StdStrBuf(""));
// Set it
AddChannel(Channel.getData())->OnTopic(Topic.getData());
// Log
if(Topic.getLength())
PushMessage(MSG_Status, szSender, Channel.getData(), FormatString(LoadResStr("IDS_MSG_TOPICIN"), Channel.getData(), Topic.getData()).getData());
}
break;
case 333: // Last topic change
fShowMessage = false; // ignore
break;
case 353: // Names in channel
{
// Get Channel name and name list
StdStrBuf Junk = ircExtractPar(&szParameters); // ??!
StdStrBuf Channel = ircExtractPar(&szParameters);
StdStrBuf Names = ircExtractPar(&szParameters);
// Set it
AddChannel(Channel.getData())->OnUsers(Names.getData(), Prefixes.getData());
fShowMessage = false;
}
break;
case 366: // End of names list
{
// Get Channel name
StdStrBuf Channel = ircExtractPar(&szParameters);
// Finish
AddChannel(Channel.getData())->OnUsersEnd();
fShowMessage = false;
// Notify
if(pNotify) pNotify->PushEvent(Ev_IRC_Message, this);
}
break;
case 4: // Server version
fShowMessage = false; // ignore
break;
case 5: // Server support string
{
while(szParameters && *szParameters)
{
// Get support-token.
StdStrBuf Token = ircExtractPar(&szParameters);
StdStrBuf Parameter; Parameter.CopyUntil(Token.getData(), '=');
// Check if it's interesting and safe data if so.
if(SEqualNoCase(Parameter.getData(), "PREFIX"))
Prefixes.Copy(SSearch(Token.getData(), "="));
}
fShowMessage = false;
}
break;
}
// Show embedded message, if any?
if(fShowMessage)
{
// Check if first parameter is some sort of channel name
C4Network2IRCChannel *pChannel = NULL;
if(szParameters && *szParameters && *szParameters != ':')
pChannel = getChannel(ircExtractPar(&szParameters).getData());
// Go over other parameters
const char *pMsg = szParameters;
while(pMsg && *pMsg && *pMsg != ':')
pMsg = SSearch(pMsg, " ");
// Show it
if(pMsg && *pMsg)
if(!pChannel)
//.........这里部分代码省略.........
示例11: if
//.........这里部分代码省略.........
else if (szCmdName[0] == 'd' && !Game.Parameters.isLeague()) // deactivate
pCtrl = new C4ControlClientUpdate(pClient->getID(), CUT_Activate, false);
else if (szCmdName[0] == 'o' && !Game.Parameters.isLeague()) // observer
pCtrl = new C4ControlClientUpdate(pClient->getID(), CUT_SetObserver);
// perform it
if (pCtrl)
Game.Control.DoInput(CID_ClientUpdate, pCtrl, CDT_Sync);
else
Log(LoadResStr("IDS_LOG_COMMANDNOTALLOWEDINLEAGUE"));
return TRUE;
}
// control mode
if (SEqual(szCmdName, "centralctrl") || SEqual(szCmdName, "decentralctrl") ||
SEqual(szCmdName, "asyncctrl")) {
if (!Game.Network.isEnabled() || !Game.Network.isHost()) {
Log(LoadResStr("IDS_MSG_CMD_HOSTONLY"));
return FALSE;
}
if (Game.Parameters.isLeague() && *szCmdName == 'a') {
Log(LoadResStr("IDS_LOG_COMMANDNOTALLOWEDINLEAGUE"));
return FALSE;
}
Game.Network.SetCtrlMode(
*szCmdName == 'c' ? CNM_Central : *szCmdName == 'd' ? CNM_Decentral
: CNM_Async);
return TRUE;
}
// show chart
if (Game.IsRunning)
if (SEqual(szCmdName, "chart")) return Game.ToggleChart();
// custom command
C4MessageBoardCommand *pCmd;
if (Game.IsRunning)
if (pCmd = GetCommand(szCmdName)) {
StdStrBuf Script, CmdScript;
// replace %player% by calling player number
if (SSearch(pCmd->Script, "%player%")) {
int32_t iLocalPlr = NO_OWNER;
C4Player *pLocalPlr = Game.Players.GetLocalByIndex(0);
if (pLocalPlr) iLocalPlr = pLocalPlr->Number;
StdStrBuf sLocalPlr;
sLocalPlr.Format("%d", iLocalPlr);
CmdScript.Copy(pCmd->Script);
CmdScript.Replace("%player%", sLocalPlr.getData());
} else {
CmdScript.Ref(pCmd->Script);
}
// insert parameters
if (SSearch(CmdScript.getData(), "%d")) {
// make sure it's a number by converting
Script.Format(CmdScript.getData(), (int)atoi(pCmdPar));
} else if (SSearch(CmdScript.getData(), "%s")) {
// Unrestricted parameters?
// That's kind of a security risk as it will allow anyone to execute
// code
switch (pCmd->eRestriction) {
case C4MessageBoardCommand::C4MSGCMDR_Escaped: {
// escape strings
StdStrBuf Par;
Par.Copy(pCmdPar);
Par.EscapeString();
// compose script
Script.Format(CmdScript.getData(), Par.getData());
} break;
case C4MessageBoardCommand::C4MSGCMDR_Plain:
// unescaped
Script.Format(CmdScript.getData(), pCmdPar);
break;
case C4MessageBoardCommand::C4MSGCMDR_Identifier: {
// only allow identifier-characters
StdStrBuf Par;
while (IsIdentifier(*pCmdPar) || isspace((unsigned char)*pCmdPar))
Par.AppendChar(*pCmdPar++);
// compose script
Script.Format(CmdScript.getData(), Par.getData());
} break;
}
} else
Script = CmdScript.getData();
// add script
Game.Control.DoInput(CID_Script, new C4ControlScript(Script.getData()),
CDT_Decide);
// ok
return TRUE;
}
// unknown command
StdStrBuf sErr;
sErr.Format(LoadResStr("IDS_ERR_UNKNOWNCMD"), szCmdName);
if (pLobby)
pLobby->OnError(sErr.getData());
else
Log(sErr.getData());
return FALSE;
}
示例12: CreateNameTree
void StdCompilerINIRead::CreateNameTree()
{
FreeNameTree();
// Create root node
pName = pNameRoot = new NameNode();
// No input? Stop
if (!Buf) return;
// Start scanning
pPos = Buf.getPtr(0);
while (*pPos)
{
// Go over whitespace
int iIndent = 0;
while (*pPos == ' ' || *pPos == '\t')
{ pPos++; iIndent++; }
// Name/Section?
bool fSection = *pPos == '[' && isalpha((unsigned char)*(pPos+1));
if (fSection || isalpha((unsigned char)*pPos))
{
// Treat values as if they had more indention
// (so they become children of sections on the same level)
if (!fSection) iIndent++; else pPos++;
// Go up in tree structure if there is less indention
while (pName->Parent && pName->Indent >= iIndent)
pName = pName->Parent;
// Copy name
StdStrBuf Name;
while (isalnum((unsigned char)*pPos) || *pPos == ' ' || *pPos == '_')
Name.AppendChar(*pPos++);
while (*pPos == ' ' || *pPos == '\t') pPos++;
if ( *pPos != (fSection ? ']' : '=') )
// Warn, ignore
Warn(isprint((unsigned char)*pPos) ? "Unexpected character ('%c'): %s ignored" : "Unexpected character ('0x%02x'): %s ignored", unsigned(*pPos), fSection ? "section" : "value");
else
{
pPos++;
// Create new node
NameNode *pPrev = pName->LastChild;
pName =
pName->LastChild =
(pName->LastChild ? pName->LastChild->NextChild : pName->FirstChild) =
new NameNode(pName);
pName->PrevChild = pPrev;
pName->Name.Take(std::move(Name));
pName->Pos = pPos;
pName->Indent = iIndent;
pName->Section = fSection;
// Values don't have children (even if the indention looks like it)
if (!fSection)
pName = pName->Parent;
}
}
// Skip line
while (*pPos && (*pPos != '\n' && *pPos != '\r'))
pPos++;
while (*pPos == '\n' || *pPos == '\r')
pPos++;
}
// Set pointer back
pName = pNameRoot;
}
示例13: if
BOOL C4UpdatePackage::MkUp(C4Group *pGrp1, C4Group *pGrp2, C4GroupEx *pUpGrp,
BOOL *fModified) {
// (CAUTION: pGrp1 may be NULL - that means that there is no counterpart for
// Grp2
// in the base group)
// compare headers
if (!pGrp1 || pGrp1->GetCreation() != pGrp2->GetCreation() ||
pGrp1->GetOriginal() != pGrp2->GetOriginal() ||
!SEqual(pGrp1->GetMaker(), pGrp2->GetMaker()) ||
!SEqual(pGrp1->GetPassword(), pGrp2->GetPassword()))
*fModified = TRUE;
// set header
pUpGrp->SetHead(*pGrp2);
// compare entries
char strItemName[_MAX_PATH], strItemName2[_MAX_PATH];
StdStrBuf EntryList;
strItemName[0] = strItemName2[0] = 0;
pGrp2->ResetSearch();
if (!*fModified) pGrp1->ResetSearch();
int iChangedEntries = 0;
while (pGrp2->FindNextEntry("*", strItemName, NULL, NULL, !!strItemName[0])) {
// add to entry list
if (!!EntryList) EntryList.AppendChar('|');
EntryList.AppendFormat("%s=%d", strItemName, pGrp2->EntryTime(strItemName));
// no modification detected yet? then check order
if (!*fModified) {
if (!pGrp1->FindNextEntry("*", strItemName2, NULL, NULL,
!!strItemName2[0]))
*fModified = TRUE;
else if (!SEqual(strItemName, strItemName2))
*fModified = TRUE;
}
// TODO: write DeleteEntries.txt
// a child group?
C4GroupEx ChildGrp2;
if (ChildGrp2.OpenAsChild(pGrp2, strItemName)) {
// open in Grp1
C4Group *pChildGrp1 = new C4GroupEx();
if (!pGrp1 || !pChildGrp1->OpenAsChild(pGrp1, strItemName)) {
delete pChildGrp1;
pChildGrp1 = NULL;
}
// open group for update data
C4GroupEx UpdGroup;
char strTempGroupName[_MAX_FNAME + 1];
strTempGroupName[0] = 0;
if (!UpdGroup.OpenAsChild(pUpGrp, strItemName)) {
// create new group (may be temporary)
// SCopy(GetCfg()->AtTempPath("~upd"), strTempGroupName, _MAX_FNAME);
MakeTempFilename(strTempGroupName);
if (!UpdGroup.Open(strTempGroupName, TRUE)) {
delete pChildGrp1;
WriteLog("Error: could not create temp group\n");
return FALSE;
}
}
// do nested MkUp-search
BOOL Modified = FALSE;
BOOL fSuccess = MkUp(pChildGrp1, &ChildGrp2, &UpdGroup, &Modified);
// sort & close
extern const char **C4Group_SortList;
UpdGroup.SortByList(C4Group_SortList, ChildGrp2.GetName());
UpdGroup.Close(FALSE);
// check entry times
if (!pGrp1 ||
(pGrp1->EntryTime(strItemName) != pGrp2->EntryTime(strItemName)))
Modified = TRUE;
// add group (if modified)
if (fSuccess && Modified) {
if (strTempGroupName[0])
if (!pUpGrp->Move(strTempGroupName, strItemName)) {
WriteLog("Error: could not add modified group\n");
return FALSE;
}
// copy core
pUpGrp->SaveEntryCore(*pGrp2, strItemName);
pUpGrp->SetSavedEntryCore(strItemName);
// got a modification in a subgroup
*fModified = TRUE;
iChangedEntries++;
} else
// delete group (do not remove groups that existed before!)
if (strTempGroupName[0])
if (remove(strTempGroupName))
if (rmdir(strTempGroupName)) {
WriteLog("Error: could not delete temporary directory\n");
return FALSE;
}
delete pChildGrp1;
} else {
// compare them (size & crc32)
if (!pGrp1 ||
pGrp1->EntrySize(strItemName) != pGrp2->EntrySize(strItemName) ||
pGrp1->EntryCRC32(strItemName) != pGrp2->EntryCRC32(strItemName)) {
BOOL fCopied = FALSE;
// save core (EntryCRC32 might set additional fields)
//.........这里部分代码省略.........