本文整理汇总了C++中TString::erase方法的典型用法代码示例。如果您正苦于以下问题:C++ TString::erase方法的具体用法?C++ TString::erase怎么用?C++ TString::erase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TString
的用法示例。
在下文中一共展示了TString::erase方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Replace
void Replace(TString &s, const TString &search, const TString &replace, size_t num) {
size_t repl_num = 0;
for( size_t pos = 0; ; pos += replace.length() ) {
if(repl_num>=num) break;
// Locate the subTString to replace
pos = s.find( search, pos );
if( pos == TString::npos ) break;
// Replace by erasing and inserting
s.erase( pos, search.length() );
s.insert( pos, replace );
repl_num+=1;
}
}
示例2: GetString
//Return the complete callstack in a continuous string
TString Stackage::GetString()
{
vector<TCHAR*>::iterator it;
TString stack;
TString separator = TEXT(" -> ");
//Build Stack String
for(it=vStack.begin(); it!=vStack.end(); ++it)
{
stack.append(*it);
stack.append(separator);
}
//Remove last separator
if(stack.length() >= separator.length())
stack.erase(stack.end() - separator.length(), stack.end());
return stack;
}
示例3: ReadDatabase
//.........这里部分代码省略.........
power["P"] = 3;
power["PTA"] = 4;
power["L"] = 4; // pathlength from z=0 (target) to focal plane (meters)
power["XF"] = 5; // forward: target to focal-plane (I think)
power["TF"] = 5;
power["PF"] = 5;
power["YF"] = 5;
map<string,vector<THaMatrixElement>*> matrix_map;
matrix_map["t"] = &fFPMatrixElems;
matrix_map["y"] = &fFPMatrixElems;
matrix_map["p"] = &fFPMatrixElems;
matrix_map["D"] = &fDMatrixElems;
matrix_map["T"] = &fTMatrixElems;
matrix_map["Y"] = &fYMatrixElems;
matrix_map["YTA"] = &fYTAMatrixElems;
matrix_map["P"] = &fPMatrixElems;
matrix_map["PTA"] = &fPTAMatrixElems;
matrix_map["L"] = &fLMatrixElems;
map <string,int> fp_map;
fp_map["t"] = 0;
fp_map["y"] = 1;
fp_map["p"] = 2;
// Read in as many of the matrix elements as there are.
// Read in line-by-line, so as to be able to handle tensors of
// different orders.
while( fgets(buff, LEN, file) ) {
string line(buff);
// Erase trailing newline
if( line.size() > 0 && line[line.size()-1] == '\n' ) {
buff[line.size()-1] = 0;
line.erase(line.size()-1,1);
}
// Split the line into whitespace-separated fields
vector<string> line_spl = Split(line);
// Stop if the line does not start with a string referring to
// a known type of matrix element. In particular, this will
// stop on a subsequent timestamp or configuration tag starting with "["
if(line_spl.empty())
continue; //ignore empty lines
const char* w = line_spl[0].c_str();
vsiz_t npow = power[w];
if( npow == 0 )
break;
// Looks like a good line, go parse it.
THaMatrixElement ME;
ME.pw.resize(npow);
ME.iszero = true; ME.order = 0;
vsiz_t pos;
for (pos=1; pos<=npow && pos<line_spl.size(); pos++) {
ME.pw[pos-1] = atoi(line_spl[pos].c_str());
}
vsiz_t p_cnt;
for ( p_cnt=0; pos<line_spl.size() && p_cnt<kPORDER && pos<=npow+kPORDER;
pos++,p_cnt++ ) {
ME.poly[p_cnt] = atof(line_spl[pos].c_str());
if (ME.poly[p_cnt] != 0.0) {
ME.iszero = false;
ME.order = p_cnt+1;
}
}
if (p_cnt < 1) {