本文整理汇总了C++中cString::Length方法的典型用法代码示例。如果您正苦于以下问题:C++ cString::Length方法的具体用法?C++ cString::Length怎么用?C++ cString::Length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cString
的用法示例。
在下文中一共展示了cString::Length方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FromString
/*int cStringList::FromMem(struct memfile &f) {
int len;
int bytes=0;
bytes+=memread(f,&len,sizeof(int));
cString temp="";
char * tempchar=NULL;
for(int i=0; i<len; i++) {
tempchar=(char*)f.start;
tempchar+=f.offset;
temp=tempchar;
bytes+=temp.Length()+1;
f.offset+=temp.Length()+1;
(*this)+=temp;
temp="";
}
if((*this)[-1]=="" && Length()!=0) used--;
return bytes;
}
*/
void cStringList::FromString(const cString &strng, cString delim) {
if(delim.Length()==1) return FromString(strng,delim[0]);
delete [] Array;
Array=NULL;
allocated=0;
used=0;
Resize(500);
cString substrng=delim;
cString temp;
used=1;
for(int i=0; i<strng.Length(); ) FromString_innerloop(strng,delim,substrng, i);
}
示例2: FromString_innerloop
void cStringList::FromString_innerloop(const cString & strng, cString delim, cString &substrng, int & i) {
int s=strng.Length();
for(int j=0; j<delim.Length() && i+j<strng.Length(); j++) substrng[j]=strng[i+j];
if(substrng!=delim && i<s) {
if(used+1>allocated) {
Resize(allocated+500);
}
Array[used-1]+=strng[i];
i++;
} else {
used++;
i+=substrng.Length();
}
}
示例3: SetFromString
bool cTimeAndDate::SetFromString(cString s) {
//date string must be of the form mmddyy
//but it can be in mddyy if m<10
if(s.Length()<5) return false;
if(s.Length()!=6) s="0"+s;
cString m=" ",d=" ",y=" ";
m[0]=s[0];
m[1]=s[1];
d[0]=s[2];
d[1]=s[3];
y[0]=s[4];
y[1]=s[5];
cTimeAndDate tempdate(m.AtoI(),d.AtoI(), y.AtoI()+2000);
*this=tempdate;
return true;
}
示例4: FromParagraph
void cStringList::FromParagraph(const cString &mystring, int width) {
if(mystring.Length()<width) {
this->Resize(0);
(*this)+=mystring;
}
//step one, create a list of words
cStringList words;
words.FromString(mystring," ");
cStringList newlist;
//step two, reconstruct a new list of multiple lines with multiple words,
//conditions: each line may be no more than <width> chars long
//each line must end in a space.
cString linebuffer="";
cString templinebuffer="";
for(int i=0; i<words.Length(); i++) {
if(linebuffer=="") {
linebuffer=words[i];
templinebuffer=linebuffer;
} else {
templinebuffer=linebuffer+" "+words[i];
}
if(templinebuffer.Length()>width) {
//cerr<<"adding "<<linebuffer<<endl;
newlist+=linebuffer;
linebuffer=words[i];
}
else {
//if(linebuffer=="") linebuffer=words[i];
//else
linebuffer=templinebuffer;
}
}
newlist+=linebuffer;
(*this)=newlist;
}