本文整理汇总了C++中Ztring::substr方法的典型用法代码示例。如果您正苦于以下问题:C++ Ztring::substr方法的具体用法?C++ Ztring::substr怎么用?C++ Ztring::substr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ztring
的用法示例。
在下文中一共展示了Ztring::substr方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: File_Curl_Set
//---------------------------------------------------------------------------
void MediaInfo_Config_MediaInfo::File_Curl_Set (const Ztring &NewValue)
{
size_t Pos=NewValue.find(_T(','));
if (Pos==string::npos)
Pos=NewValue.find(_T(';'));
if (Pos!=string::npos)
{
Ztring Field=NewValue.substr(0, Pos); Field.MakeLowerCase();
Ztring Value=NewValue.substr(Pos+1, string::npos);
CriticalSectionLocker CSL(CS);
Curl[Field]=Value;
}
}
示例2: Write
//---------------------------------------------------------------------------
// Set
void Translation::Write(const Ztring &NewLanguage)
{
clear();
if (!&NewLanguage || !NewLanguage.size())
return;
size_t Pos1=0, Pos2_EOL=0, Pos2_Separator=0;
while (Pos2_EOL!=(size_t)-1)
{
Pos2_EOL=NewLanguage.find(__T('\n'), Pos1);
Pos2_Separator=NewLanguage.find(__T(';'), Pos1);
if (Pos2_Separator<Pos2_EOL)
{
operator[](NewLanguage.substr(Pos1, Pos2_Separator-Pos1))=NewLanguage.substr(Pos2_Separator+1, Pos2_EOL-Pos2_Separator-1);
}
Pos1=Pos2_EOL+1;
}
}
示例3: Write
//---------------------------------------------------------------------------
// Set
void InfoMap::Write(const Ztring &NewInfoMap)
{
clear();
if (NewInfoMap.empty())
return;
size_t Pos1=0, Pos2_EOL=0, Pos2_Separator=0;
while (Pos2_EOL!=(size_t)-1)
{
Pos2_EOL=NewInfoMap.find(__T('\n'), Pos1);
Pos2_Separator=NewInfoMap.find(__T(';'), Pos1);
if (Pos2_Separator<Pos2_EOL)
{
ZtringList List; List.Write(NewInfoMap.substr(Pos1, Pos2_EOL-Pos1));
insert (pair<Ztring, ZtringList>(NewInfoMap.substr(Pos1, Pos2_Separator-Pos1), List));
}
Pos1=Pos2_EOL+1;
}
}
示例4: Write
//---------------------------------------------------------------------------
// Write
void ZtringList::Write(const Ztring &ToWrite)
{
clear();
if (ToWrite.empty())
return;
size_type PosC=0;
bool Fini=false;
Ztring C1;
Ztring DelimiterL;
Ztring DelimiterR;
do
{
//Searching quotes
if (ToWrite[PosC]==Quote[0])
{
size_t Pos_End=PosC+1;
while (Pos_End<ToWrite.size())
{
if (ToWrite[Pos_End]==Quote[0] && Pos_End+1<ToWrite.size() && ToWrite[Pos_End+1]==Quote[0])
Pos_End+=2; //Double quote, skipping
else
{
if (ToWrite[Pos_End]==Quote[0])
break;
Pos_End++;
}
}
C1=ToWrite.substr(PosC+Quote.size(), Pos_End-PosC);
PosC+=C1.size()+Quote.size();
if (C1.size()>0 && C1[C1.size()-1]==Quote[0])
{
C1.resize(C1.size()-1);
PosC+=Quote.size();
}
}
else //Normal
{
C1=ToWrite.SubString(tstring(), Separator[0], PosC, Ztring_AddLastItem);
PosC+=C1.size()+Separator[0].size();
}
C1.FindAndReplace(Quote+Quote, Quote, 0, Ztring_Recursive);
if (size()<Max[0])
push_back(C1);
if (PosC>=ToWrite.size())
Fini=true;
}
while (!Fini);
return;
}
示例5: Configure
//---------------------------------------------------------------------------
void File__Duplicate__Writer::Configure (const Ztring &Target)
{
//Form: "memory://pointer:size" <--Memory block is specified by user
//WARNING: pointer must be in ***DECIMAL*** format.
//Example: "memory://123456789:1316"
if (Target.find(__T("memory://"))==0 && Target.find(__T(":"), 9)!=std::string::npos)
{
size_t SemiColumn_Pos=Target.find(__T(":"), 9);
Ztring Address=Target.substr(9, SemiColumn_Pos-9);
Ztring Size=Target.substr(SemiColumn_Pos+1);
Method=method_buffer;
Buffer=(int8u*)Address.To_int64u();
Buffer_Size_Max=(size_t)Size.To_int64u();
}
//Form: "file://filename" or <--the exported filename is specified by user
else if (Target.find(__T("file://"))==0)
{
Method=method_filename;
File_Name=Target.substr(7, std::string::npos);
}
}
示例6: NettoyerEspaces
//---------------------------------------------------------------------------
// Nettoyage
bool ZtringListListF::NettoyerEspaces (Ztring &ANettoyer)
{
size_t Debut=0;
while (Debut<ANettoyer.size() && ANettoyer[Debut]==__T(' '))
Debut++;
size_t Fin=ANettoyer.size()-1;
while (Fin!=(size_t)-2 && ANettoyer[Fin]==__T(' '))
Fin--;
if (Fin>=Debut)
ANettoyer=ANettoyer.substr(Debut, Fin-Debut+1);
else
ANettoyer=Ztring();
return true;
}
示例7: 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;
}
示例8: Write
//---------------------------------------------------------------------------
// Write
void ZtringListList::Write(const Ztring &ToWrite)
{
clear();
if (ToWrite.empty())
return;
size_type PosC=0;
bool Fini=false;
Ztring C1;
ZtringList ZL1;
ZL1.Separator_Set(0, Separator[1]);
ZL1.Quote_Set(Quote);
ZL1.Max_Set(0, Max[1]);
//Detecting carriage return format
Ztring WriteSeparator;
if (Separator[0]==EOL)
{
size_t CarriageReturn_Pos=ToWrite.find_first_of(__T("\r\n"));
if (CarriageReturn_Pos!=string::npos)
{
if (ToWrite[CarriageReturn_Pos]==__T('\r'))
{
if (CarriageReturn_Pos+1<ToWrite.size() && ToWrite[CarriageReturn_Pos+1]==__T('\n'))
WriteSeparator=__T("\r\n");
else
WriteSeparator=__T("\r");
}
else
WriteSeparator=__T("\n");
}
else
WriteSeparator=Separator[0];
}
else
WriteSeparator=Separator[0];
do
{
//Searching end of line, but it must not be in quotes
bool InQuotes=false;
Ztring CharsToFind=WriteSeparator+Quote;
size_t Pos_End=PosC;
while (Pos_End<ToWrite.size())
{
Pos_End=ToWrite.find(WriteSeparator, Pos_End);
if (Pos_End!=string::npos)
{
if (Pos_End+Quote.size()<ToWrite.size() && ToWrite[Pos_End]==Quote[0] && ToWrite[Pos_End+1]!=Quote[0])
{
InQuotes=!InQuotes; //This is not double quotes, so this is a normal quote
/*if (!InQuotes)
{
C1=ToWrite.substr(PosC, Pos_End-PosC);
break;
}*/
}
if (!InQuotes && Pos_End+WriteSeparator.size()<=ToWrite.size() && ToWrite[Pos_End]==WriteSeparator[0])
{
C1=ToWrite.substr(PosC, Pos_End-PosC);
break;
}
if (InQuotes && Pos_End+Quote.size()*2<ToWrite.size() && ToWrite[Pos_End]==Quote[0] && ToWrite[Pos_End+1]==Quote[0])
Pos_End+=2;
else
Pos_End++;
}
}
if (Pos_End>=ToWrite.size())
C1=ToWrite.substr(PosC, string::npos);
ZL1.Write(C1);
push_back(ZL1);
PosC+=C1.size()+WriteSeparator.size();
if (PosC>=ToWrite.size())
Fini=true;
}
while (!Fini);
}