本文整理汇总了C++中Ztring::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ Ztring::clear方法的具体用法?C++ Ztring::clear怎么用?C++ Ztring::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ztring
的用法示例。
在下文中一共展示了Ztring::clear方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Write
//---------------------------------------------------------------------------
// Write
void ZtringList::Write(const Ztring &ToWrite)
{
clear();
if (!&ToWrite || !ToWrite.size())
return;
size_type PosC=0;
bool Fini=false;
Ztring C1;
Ztring DelimiterL;
Ztring DelimiterR;
do
{
if (ToWrite.size()>PosC && Quote.size()>0 && ToWrite[PosC]==Quote[0] && ToWrite.substr(PosC, Quote.size())==Quote) //Quote found (ToWrite[PosC]==Quote[0] is here for optimization
{
DelimiterL=Quote;
DelimiterR=Quote+Separator[0];
}
else
{
DelimiterL.clear();
DelimiterR=Separator[0];
}
C1=ToWrite.SubString(DelimiterL, DelimiterR, PosC, Ztring_AddLastItem);
if (DelimiterR.size()>Separator[0].size() && C1.size()==ToWrite.size()-Quote.size()-PosC) //This is the last item of the line, we must suppress the Quote at the end
C1.resize(C1.size()-Quote.size());
if (size()<Max[0])
push_back(C1);
else
{
//No more adding is permit, we add to the last element (with the separator)
at(size()-1)+=Separator[0];
at(size()-1)+=C1;
}
PosC+=C1.size()+DelimiterL.size()+DelimiterR.size();
if (PosC>=ToWrite.size())
Fini=true;
}
while (!Fini);
return;
}
示例2: Enums_Create_Item
//---------------------------------------------------------------------------
// Open an item
ZenLib::Ztring Enums_Create_Item(const Ztring &Directory, const Ztring &Name, Ztring &Contents)
{
Contents.clear();
Ztring Result;
//Load header
Ztring Partial;
Result=Enums_Create_Load(L"../Source/Resource/Text/Enums_.2.txt", Partial);
if (!Result.empty())
return Result;
Partial.FindAndReplace(L"%Name%", Ztring(Name).MakeLowerCase());
Contents+=Partial;
//Load line template
Ztring Line;
Result=Enums_Create_Load(L"../Source/Resource/Text/Enums_.5.txt", Line);
if (!Result.empty())
return Result;
//Read input file
ZtringListListF ZLL;
ZLL.Load(Ztring(L"../Source/Resource/Text/")+Directory+L"/"+Name+L".csv");
for (size_t Pos=0; Pos<ZLL.size(); Pos++)
{
Ztring Line_Temp=Line;
Line_Temp.FindAndReplace(L"%Name%", Name);
Ztring &ToAdd=ZLL(Pos, 0);
ToAdd.FindAndReplace(__T("/"), __T("_"), 0, Ztring_Recursive); //C++ does not accept "/" in names
ToAdd.FindAndReplace(__T("("), __T("_")); //C++ does not accept "(" in names
ToAdd.FindAndReplace(__T(")"), __T("_")); //C++ does not accept ")" in names
ToAdd.FindAndReplace(__T("*"), __T("_")); //C++ does not accept "*" in names
ToAdd.FindAndReplace(__T("-"), __T("_")); //C++ does not accept "-" in names
Line_Temp.FindAndReplace(L"%Line%", ToAdd);
Contents+=Line_Temp;
}
//Load footer template
Result=Enums_Create_Load(L"../Source/Resource/Text/Enums_.8.txt", Partial);
if (!Result.empty())
return Result;
Contents+=Partial;
return L"";
}
示例3: Get_Next
//---------------------------------------------------------------------------
bool File_Pdf::Get_Next(string &Key, Ztring &Value)
{
Key.clear();
Value.clear();
string Line;
//Removig end of lines
while (Element_Offset<Element_Size && (Buffer[Buffer_Offset+(size_t)Element_Offset]=='\r' || Buffer[Buffer_Offset+(size_t)Element_Offset]=='\n' || Buffer[Buffer_Offset+(size_t)Element_Offset]==' '))
Element_Offset++;
//End
if (Element_Offset>=Element_Size)
return true;
//Testing Catalog
Peek_String (2, Line);
if (Line=="<<")
{
Element_Offset+=2;
Catalog_Level++;
return true;
}
else if (Line==">>")
{
Element_Offset+=2;
Catalog_Level--;
return true;
}
//Getting a complete line
Peek_String (SizeOfLine(), Line);
//Testing Catalog
size_t Catalog_End=Line.find(">>");
if (Catalog_End!=String::npos)
Line.resize(Catalog_End);
//Testing stream
if (Line=="stream")
{
Skip_String(Line.size(), "Stream, Header");
Key=Line;
return false;
}
if (Line=="endstream")
{
Skip_String(Line.size(), "Stream, Footer");
Key=Line;
return false;
}
//Testing object
if (Line=="endobj")
{
Skip_String(Line.size(), "Footer");
Key=Line;
return false;
}
//Base
int64u Line_Base=Element_Offset;
//Testing next key
size_t Line_End=0;
size_t Line_Begin=Line_End;
// Key-Value
if (Line_Begin<Line.size() && Line[Line_Begin]=='/')
{
Line_End= Line_Begin+1;
size_t HasParenthesis=0;
size_t HasBracket=0;
size_t HasSpace=0;
size_t HasValue=0;
for (;;)
{
if (Line_End==Line.size())
break;
if (!HasParenthesis && !HasBracket && HasValue && Line[Line_End]=='<' && Line_End+1<Line.size() && Line[Line_End+1]=='<')
break;
if (!HasParenthesis && !HasBracket && HasValue && Line[Line_End]=='/')
break;
else if (!HasValue && Line[Line_End]=='/')
++HasValue;
else if (!HasValue && HasSpace)
++HasValue;
if (Line[Line_End]==' ')
++HasSpace;
if (Line[Line_End]=='(')
++HasParenthesis;
if (HasParenthesis && Line[Line_End]==')')
--HasParenthesis;
if (Line[Line_End]=='[')
++HasBracket;
//.........这里部分代码省略.........
示例4: contextMenuEvent
//---------------------------------------------------------------------------
void GUI_Main_Core_Table::contextMenuEvent (QContextMenuEvent* Event)
{
//Retrieving data
QTableWidgetItem* Item=itemAt(Event->pos());
if (Item==NULL)
return;
string FileName=FileName_Before+item(Item->row(), 0)->text().toLocal8Bit().data();
string Field=horizontalHeaderItem(Item->column())->text().toLocal8Bit().data();
ZtringList History; History.Write(C->History(FileName, Field));
Ztring Date;
if (Field=="OriginationDate" || Field=="OriginationTime" || Field=="ICRD")
{
Date=C->FileDate_Get(FileName);
if (Date.size()>=10+1+8)
{
if (Date.size()>=10+1+8)
Date.resize(10+1+8);
if (Field=="ICRD")
Date.insert(0, "&Set ICRD to file creation timestamp ("); //If you change this, change at the end of method too
else
Date.insert(0, "&Set originationDate and Time to file creation timestamp ("); //If you change this, change at the end of method too
Date.append(")");
}
else
Date.clear();
}
//Creating menu
QMenu menu(this);
//Handling AllFiles display
{
menu.addAction(new QAction("Fill all open files with this field value", this)); //If you change this, change the test text too
menu.addSeparator();
}
//Handling Clear display
if (!item(Item->row(), Item->column())->text().isEmpty() && C->IsValid(FileName, Field, string()))
{
menu.addAction(new QAction("Clear this value", this)); //If you change this, change the test text too
menu.addSeparator();
}
//Handling date display
if (!Date.empty())
{
menu.addAction(new QAction(QString().fromUtf8(Date.To_Local().c_str()), this));
menu.addSeparator();
}
//Handling history display
size_t Pos=History.size();
if (!History.empty())
do
{
Pos--;
QString Text=QString().fromUtf8(History[Pos].To_Local().c_str());
if (!Text.isEmpty())
{
QAction* Action=new QAction(Text, this);
menu.addAction(Action);
}
}
while (Pos>0);
//Displaying
QAction* Action=menu.exec(Event->globalPos());
if (Action==NULL)
return;
//Retrieving data
QString Text=Action->text();
//Special cases
if (Text=="Fill all open files with this field value") //If you change this, change the creation text too
{
for (int Row=0; Row<rowCount(); Row++)
{
item(Row, Item->column())->setText(QString().fromUtf8(Ztring(C->Get(FileName, Field)).To_Local().c_str()));
dataChanged(indexFromItem(item(Row, Item->column())), indexFromItem(item(Row, Item->column())));
//Special cases
if (Field=="UMID" || Field=="LoudnessValue" || Field=="LoudnessRange" || Field=="MaxTruePeakLevel" || Field=="MaxMomentaryLoudness" || Field=="MaxShortTermLoudness")
{
//Changing BextVersion Enabled value
SetText (*Item, "BextVersion");
SetEnabled(*Item, "BextVersion");
}
}
return;
}
if (Text=="Clear this value") //If you change this, change the creation text too
Text.clear();
//Filling
if (Text.contains("&Set ")) //If you change this, change the creation text too
{
//.........这里部分代码省略.........