本文整理汇总了C++中string::Clear方法的典型用法代码示例。如果您正苦于以下问题:C++ string::Clear方法的具体用法?C++ string::Clear怎么用?C++ string::Clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类string
的用法示例。
在下文中一共展示了string::Clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UnSerializeString
bool SearchTreeNode::UnSerializeString(const string& s,string& result)
{
result.Clear();
size_t i;
int mode = 0;
wxString entity(_T(""));
unsigned int u;
for(i = 0;mode >=0 && i<s.length();i++)
{
wxChar ch = s[i];
if(ch==_T('"') || ch==_T('>') || ch==_T('<'))
{
mode = -1; // Error
break;
}
switch(mode)
{
case 0: // normal
if(ch==_T('&'))
{
mode = 1;
entity.Clear();
}
else
result << ch;
case 1: // escaped
if(ch==_T('&'))
{
mode = -1; // Error
break;
}
else if(ch==_T(';'))
{
mode = 0;
if(entity==_T("quot"))
ch = _T('"');
else if(entity==_T("amp"))
ch = _T('&');
else if(entity==_T("apos"))
ch = _T('\'');
else if(entity==_T("lt"))
ch = _T('<');
else if(entity==_T("gt"))
ch = _T('>');
else if(entity[0]==_T('#') && s2u(entity.substr(1),u))
ch = u;
else
{
mode = -1; // Error: Unrecognized entity
break;
}
result << ch;
}
break;
}
}
if(mode < 0)
result.Clear();
return (mode >= 0);
}
示例2: Clear
void Clear()
{
Flags=0;
TopStr=0;
CurX=CurY=0;
strHelpMask.Clear();
strHelpPath.Clear();
strHelpTopic.Clear();
strSelTopic.Clear();
}
示例3: Clear
void Clear()
{
dwFileAttributes=0;
ClearStruct(ftCreationTime);
ClearStruct(ftLastAccessTime);
ClearStruct(ftLastWriteTime);
ClearStruct(ftChangeTime);
nFileSize=0;
nAllocationSize=0;
dwReserved0=0;
dwReserved1=0;
FileId = 0;
strFileName.Clear();
strAlternateFileName.Clear();
}
示例4: ReadLastItem
bool History::ReadLastItem(const wchar_t *RegKey, string &strStr)
{
strStr.Clear();
HKEY hKey=OpenRegKey(RegKey);
if (!hKey)
return false;
DWORD Type;
DWORD Size=0;
if (RegQueryValueEx(hKey,L"Lines",0,&Type,nullptr,&Size)!=ERROR_SUCCESS || Size<sizeof(wchar_t)) // Нету ничерта
return false;
wchar_t *Buffer=(wchar_t*)xf_malloc(Size);
if (!Buffer)
return false;
if (RegQueryValueEx(hKey,L"Lines",0,&Type,(unsigned char *)Buffer,&Size)!=ERROR_SUCCESS)
{
xf_free(Buffer);
return false;
}
Buffer[Size/sizeof(wchar_t)-1]=0; //safety
strStr = Buffer; //last item is first in registry, null terminated
xf_free(Buffer);
return true;
}
示例5:
HistoryRecord()
{
Lock = false;
Type = 0;
strName.Clear();
Timestamp.dwLowDateTime=0;
Timestamp.dwHighDateTime=0;
}
示例6: Clear
void Clear()
{
ClearStruct(*static_cast<FarDialogItem*>(this));
ListPos=0;
strHistory.Clear();
strMask.Clear();
strData.Clear();
ID=0;
IFlags.ClearAll();
AutoCount=0;
AutoPtr=nullptr;
UserData=0;
ObjPtr=nullptr;
ListPtr=nullptr;
UCData=nullptr;
SelStart=0;
SelEnd=0;
}
示例7: GetNext
void History::GetNext(string &strStr)
{
if (CurrentItem)
CurrentItem=HistoryList.Next(CurrentItem);
if (CurrentItem)
strStr = CurrentItem->strName;
else
strStr.Clear();
}
示例8: GetPrev
void History::GetPrev(string &strStr)
{
CurrentItem=HistoryList.Prev(CurrentItem);
if (!CurrentItem)
CurrentItem=HistoryList.First();
if (CurrentItem)
strStr = CurrentItem->strName;
else
strStr.Clear();
}
示例9:
FolderTree::FolderTree(string &strResultFolder,int iModalMode,int IsStandalone,bool IsFullScreen):
Tree(nullptr),
FindEdit(nullptr),
ModalMode(iModalMode),
IsFullScreen(IsFullScreen),
IsStandalone(IsStandalone),
PrevMacroMode(CtrlObject->Macro.GetMode())
{
SetDynamicallyBorn(FALSE);
SetRestoreScreenMode(TRUE);
if (ModalMode != MODALTREE_FREE)
strResultFolder.Clear();
KeyBarVisible = TRUE; // Заставим обновлятся кейбар
//TopScreen=new SaveScreen;
SetCoords();
if ((Tree=new TreeList(FALSE)))
{
CtrlObject->Macro.SetMode(MACRO_FINDFOLDER);
MacroMode = MACRO_FINDFOLDER;
strLastName.Clear();
Tree->SetModalMode(ModalMode);
Tree->SetPosition(X1,Y1,X2,Y2);
if (ModalMode == MODALTREE_FREE)
Tree->SetRootDir(strResultFolder);
Tree->SetVisible(TRUE);
Tree->Update(0);
// если было прерывание в процессе сканирования и это было дерево копира...
if (Tree->GetExitCode())
{
if (!(FindEdit=new Edit))
{
SetExitCode(XC_OPEN_ERROR);
return;
}
FindEdit->SetEditBeyondEnd(FALSE);
FindEdit->SetPersistentBlocks(Global->Opt->Dialogs.EditBlock);
InitKeyBar();
FrameManager->ExecuteModal(this); //OT
}
strResultFolder = strNewFolder;
}
else
{
SetExitCode(XC_OPEN_ERROR);
}
}
示例10: Clear
void Clear()
{
Flags = 0;
strName.Clear();
AccelKey = 0;
UserDataSize = 0;
UserData = nullptr;
AmpPos = 0;
Len[0] = 0;
Len[1] = 0;
Idx2 = 0;
ShowPos = 0;
}
示例11: GetFileOwner
bool GetFileOwner(const wchar_t *Computer,const wchar_t *Name, string &strOwner)
{
bool Result=false;
/*
if(!Owner)
{
SIDCacheFlush();
return TRUE;
}
*/
strOwner.Clear();
SECURITY_INFORMATION si=OWNER_SECURITY_INFORMATION|GROUP_SECURITY_INFORMATION;;
DWORD LengthNeeded=0;
NTPath strName(Name);
PSECURITY_DESCRIPTOR sd=reinterpret_cast<PSECURITY_DESCRIPTOR>(sddata);
if (GetFileSecurity(strName,si,sd,sizeof(sddata),&LengthNeeded) && LengthNeeded<=sizeof(sddata))
{
PSID pOwner;
BOOL OwnerDefaulted;
if (GetSecurityDescriptorOwner(sd,&pOwner,&OwnerDefaulted))
{
if (IsValidSid(pOwner))
{
const wchar_t *Owner=GetNameFromSIDCache(pOwner);
if (!Owner)
{
Owner=AddSIDToCache(Computer,pOwner);
}
if (Owner)
{
strOwner=Owner;
Result=true;
}
}
}
}
return Result;
}
示例12: _MakePath1
int _MakePath1(DWORD Key, string &strPathName, const wchar_t *Param2,int ShortNameAsIs)
{
int RetCode=FALSE;
int NeedRealName=FALSE;
strPathName.Clear();
switch (Key)
{
case KEY_CTRLALTBRACKET: // Вставить сетевое (UNC) путь из левой панели
case KEY_RCTRLRALTBRACKET:
case KEY_CTRLRALTBRACKET:
case KEY_RCTRLALTBRACKET:
case KEY_CTRLALTBACKBRACKET: // Вставить сетевое (UNC) путь из правой панели
case KEY_RCTRLRALTBACKBRACKET:
case KEY_CTRLRALTBACKBRACKET:
case KEY_RCTRLALTBACKBRACKET:
case KEY_ALTSHIFTBRACKET: // Вставить сетевое (UNC) путь из активной панели
case KEY_RALTSHIFTBRACKET:
case KEY_ALTSHIFTBACKBRACKET: // Вставить сетевое (UNC) путь из пассивной панели
case KEY_RALTSHIFTBACKBRACKET:
NeedRealName=TRUE;
case KEY_CTRLBRACKET: // Вставить путь из левой панели
case KEY_RCTRLBRACKET:
case KEY_CTRLBACKBRACKET: // Вставить путь из правой панели
case KEY_RCTRLBACKBRACKET:
case KEY_CTRLSHIFTBRACKET: // Вставить путь из активной панели
case KEY_RCTRLSHIFTBRACKET:
case KEY_CTRLSHIFTBACKBRACKET: // Вставить путь из пассивной панели
case KEY_RCTRLSHIFTBACKBRACKET:
case KEY_CTRLSHIFTNUMENTER: // Текущий файл с пасс.панели
case KEY_RCTRLSHIFTNUMENTER:
case KEY_SHIFTNUMENTER: // Текущий файл с актив.панели
case KEY_CTRLSHIFTENTER: // Текущий файл с пасс.панели
case KEY_RCTRLSHIFTENTER:
case KEY_SHIFTENTER: // Текущий файл с актив.панели
{
Panel *SrcPanel=nullptr;
FilePanels *Cp=CtrlObject->Cp();
switch (Key)
{
case KEY_CTRLALTBRACKET:
case KEY_RCTRLRALTBRACKET:
case KEY_CTRLRALTBRACKET:
case KEY_RCTRLALTBRACKET:
case KEY_CTRLBRACKET:
case KEY_RCTRLBRACKET:
SrcPanel=Cp->LeftPanel;
break;
case KEY_CTRLALTBACKBRACKET:
case KEY_RCTRLRALTBACKBRACKET:
case KEY_CTRLRALTBACKBRACKET:
case KEY_RCTRLALTBACKBRACKET:
case KEY_CTRLBACKBRACKET:
case KEY_RCTRLBACKBRACKET:
SrcPanel=Cp->RightPanel;
break;
case KEY_SHIFTNUMENTER:
case KEY_SHIFTENTER:
case KEY_ALTSHIFTBRACKET:
case KEY_RALTSHIFTBRACKET:
case KEY_CTRLSHIFTBRACKET:
case KEY_RCTRLSHIFTBRACKET:
SrcPanel=Cp->ActivePanel;
break;
case KEY_CTRLSHIFTNUMENTER:
case KEY_RCTRLSHIFTNUMENTER:
case KEY_CTRLSHIFTENTER:
case KEY_RCTRLSHIFTENTER:
case KEY_ALTSHIFTBACKBRACKET:
case KEY_RALTSHIFTBACKBRACKET:
case KEY_CTRLSHIFTBACKBRACKET:
case KEY_RCTRLSHIFTBACKBRACKET:
SrcPanel=Cp->GetAnotherPanel(Cp->ActivePanel);
break;
}
if (SrcPanel)
{
if (Key == KEY_SHIFTENTER || Key == KEY_CTRLSHIFTENTER || Key == KEY_RCTRLSHIFTENTER || Key == KEY_SHIFTNUMENTER || Key == KEY_CTRLSHIFTNUMENTER || Key == KEY_RCTRLSHIFTNUMENTER)
{
string strShortFileName;
SrcPanel->GetCurName(strPathName,strShortFileName);
if (SrcPanel->GetShowShortNamesMode()) // учтем короткость имен :-)
strPathName = strShortFileName;
}
else
{
/* TODO: Здесь нужно учесть, что у TreeList тоже есть путь :-) */
if (!(SrcPanel->GetType()==FILE_PANEL || SrcPanel->GetType()==TREE_PANEL))
return FALSE;
SrcPanel->GetCurDir(strPathName);
if (SrcPanel->GetMode()!=PLUGIN_PANEL)
{
FileList *SrcFilePanel=(FileList *)SrcPanel;
SrcFilePanel->GetCurDir(strPathName);
{
//.........这里部分代码省略.........
示例13: GetTypeAndName
int FolderTree::GetTypeAndName(string &strType, string &strName)
{
strType = MSG(MFolderTreeType);
strName.Clear();
return MODALTYPE_FINDFOLDER;
}
示例14: Message
//.........这里部分代码省略.........
ItemsNumber++;
}
for (size_t J=0; J < ItemsNumber-(EmptyText?1:0); ++J, ++I)
{
Str[I]=Items[J];
}
for (size_t i = 0; i < ItemsNumber-Buttons; ++i)
{
strClipText.Append(Items[i]).Append(L"\r\n");
}
strClipText.Append(L"\r\n");
for (size_t i = ItemsNumber-Buttons; i < ItemsNumber; ++i)
{
if(i > ItemsNumber-Buttons)
{
strClipText.Append(L' ');
}
strClipText.Append(Items[i]);
}
StrCount+=CountErrorLine;
MessageX1=X1=(int(ScrX-MaxLength))/2-4;
MessageX2=X2=X1+MaxLength+9;
Y1=(ScrY-static_cast<int>(StrCount))/2-2;
if (Y1 < 0)
Y1=0;
MessageY1=Y1;
MessageY2=Y2=Y1+StrCount+3;
string strHelpTopic(strMsgHelpTopic);
strMsgHelpTopic.Clear();
// *** ¬ариант с ƒиалогом ***
if (Buttons>0)
{
size_t ItemCount=StrCount+Buttons+1;
DialogItemEx *PtrMsgDlg;
DialogItemEx *MsgDlg = new DialogItemEx[ItemCount+1];
if (!MsgDlg)
{
xf_free(Str);
return -1;
}
for (DWORD i=0; i<ItemCount+1; i++)
MsgDlg[i].Clear();
int RetCode;
MessageY2=++Y2;
MsgDlg[0].Type=DI_DOUBLEBOX;
MsgDlg[0].X1=3;
MsgDlg[0].Y1=1;
MsgDlg[0].X2=X2-X1-3;
MsgDlg[0].Y2=Y2-Y1-1;
if (Title && *Title)
MsgDlg[0].strData = Title;
FARDIALOGITEMTYPES TypeItem=DI_TEXT;
unsigned __int64 FlagsItem=DIF_SHOWAMPERSAND;
BOOL IsButton=FALSE;
int CurItem=0;
示例15: FarFormatText
string& WINAPI FarFormatText(const wchar_t *SrcText, // источник
int Width, // заданная ширина
string &strDestText, // приемник
const wchar_t* Break, // брик, если = nullptr, то принимается '\n'
DWORD Flags) // один из FFTM_*
{
const wchar_t *breakchar;
breakchar = Break?Break:L"\n";
if (!SrcText || !*SrcText)
{
strDestText.Clear();
return strDestText;
}
string strSrc = SrcText; //copy string in case of SrcText == strDestText
if (!wcspbrk(strSrc,breakchar) && strSrc.GetLength() <= static_cast<size_t>(Width))
{
strDestText = strSrc;
return strDestText;
}
long i=0, l=0, pgr=0, last=0;
wchar_t *newtext;
const wchar_t *text= strSrc;
long linelength = Width;
int breakcharlen = StrLength(breakchar);
int docut = Flags&FFTM_BREAKLONGWORD?1:0;
/* Special case for a single-character break as it needs no
additional storage space */
if (breakcharlen == 1 && !docut)
{
newtext = xf_wcsdup(text);
if (!newtext)
{
strDestText.Clear();
return strDestText;
}
while (newtext[i] != L'\0')
{
/* prescan line to see if it is greater than linelength */
l = 0;
while (newtext[i+l] != breakchar[0])
{
if (newtext[i+l] == L'\0')
{
l--;
break;
}
l++;
}
if (l >= linelength)
{
pgr = l;
l = linelength;
/* needs breaking; work backwards to find previous word */
while (l >= 0)
{
if (newtext[i+l] == L' ')
{
newtext[i+l] = breakchar[0];
break;
}
l--;
}
if (l == -1)
{
/* couldn't break is backwards, try looking forwards */
l = linelength;
while (l <= pgr)
{
if (newtext[i+l] == L' ')
{
newtext[i+l] = breakchar[0];
break;
}
l++;
}
}
}
i += l+1;
}
}
else
{
/* Multiple character line break */
newtext = (wchar_t*)xf_malloc((strSrc.GetLength() * (breakcharlen+1)+1)*sizeof(wchar_t));
//.........这里部分代码省略.........