本文整理汇总了C++中STR::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ STR::clear方法的具体用法?C++ STR::clear怎么用?C++ STR::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类STR
的用法示例。
在下文中一共展示了STR::clear方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: operator
void operator () (char ch) {
str_ += ch;
if(str_.size() >= str_.capacity()) {
term_(str_.c_str(), str_.size());
str_.clear();
}
}
示例2: longest_word
/*
* Returns the longest word found in the specified string.
*/
STR longest_word( CSTR_R str ) {
STR builder = "", longest = "";
for ( unsigned i = 0; i < str.size(); ++i ) {
if ( ( str[i] >= 'A' && str[i] <= 'Z' ) ||
( str[i] >= 'a' && str[i] <= 'z' ) )
builder += str[i];
else
builder.clear();
if ( builder.size() > longest.size() )
longest = builder;
}
return longest;
}
示例3: flush
void flush() {
if(str_.size() > 0) {
term_(str_.c_str(), str_.size());
str_.clear();
}
}
示例4: clear
void clear() {
if(str_.size() > 0) {
term_(str_.c_str(), str_.size());
}
str_.clear();
}
示例5:
//.........这里部分代码省略.........
TS_ASSERT_EQUALS(str[29], "2"); //BIT_SIZE
TS_ASSERT_EQUALS(str[30], "2"); //U1_SIZE
TS_ASSERT_EQUALS(str[31], "2"); //U2_SIZE
TS_ASSERT_EQUALS(str[32], "2"); //U3_SIZE
TS_ASSERT_EQUALS(str[33], "5"); //UTX_SIZE
TS_ASSERT_EQUALS(str[34], "65535"); //CAP_BGN
TS_ASSERT_EQUALS(str[35], "0,1,2"); //LIM_INDX
TS_ASSERT_EQUALS(str[36], "0,1,2"); //LIM_SPEC
TS_ASSERT_EQUALS(str[37], "0,1,2,3,4"); //COND_LST
TS_ASSERT_EQUALS(str[38], "2"); //CYCO_CNT
TS_ASSERT_EQUALS(str[39], "0,1"); //CYC_OFST
TS_ASSERT_EQUALS(str[40], "2"); //PMR_CNT
TS_ASSERT_EQUALS(str[41], "0,1"); //PMR_INDX
TS_ASSERT_EQUALS(str[42], "2"); //CHN_CNT
TS_ASSERT_EQUALS(str[43], "0,1"); //CHN_NUM
TS_ASSERT_EQUALS(str[44], "2"); //EXP_CNT
TS_ASSERT_EQUALS(str[45], "0,1"); //EXP_DATA
TS_ASSERT_EQUALS(str[46], "2"); //CAP_CNT
TS_ASSERT_EQUALS(str[47], "0,1"); //CAP_DATA
TS_ASSERT_EQUALS(str[48], "2"); //NEW_CNT
TS_ASSERT_EQUALS(str[49], "0,1"); //NEW_DATA
TS_ASSERT_EQUALS(str[50], "2"); //PAT_CNT
TS_ASSERT_EQUALS(str[51], "0,1"); //PAT_NUM
TS_ASSERT_EQUALS(str[52], "2"); //BPOS_CNT
TS_ASSERT_EQUALS(str[53], "0,1"); //BIT_POS
TS_ASSERT_EQUALS(str[54], "2"); //USR1_CNT
TS_ASSERT_EQUALS(str[55], "0,1"); //USR1
TS_ASSERT_EQUALS(str[56], "2"); //USR2_CNT
TS_ASSERT_EQUALS(str[57], "0,1"); //USR2
TS_ASSERT_EQUALS(str[58], "2"); //USR3_CNT
TS_ASSERT_EQUALS(str[59], "0,1"); //USR3
TS_ASSERT_EQUALS(str[60], "3"); //TXT_CNT
TS_ASSERT_EQUALS(str[61], "cn1 ,cn2 ,cn3 ");//USER_TXT
stdfRec.clear();
str.clear();
stdfRec.to_string(str);
TS_ASSERT_EQUALS(str[0], "88");
TS_ASSERT_EQUALS(str[1], "15");
TS_ASSERT_EQUALS(str[2], "30");
TS_ASSERT_EQUALS(str[3], "00000000"); //CONT_FLG
TS_ASSERT_EQUALS(str[4], "0"); //TEST_NUM
TS_ASSERT_EQUALS(str[5], "0"); //HEAD_NUM
TS_ASSERT_EQUALS(str[6], "0"); //SITE_NUM
TS_ASSERT_EQUALS(str[7], "0"); //PSR_REF
TS_ASSERT_EQUALS(str[8], "00000000"); //TEST_FLG
TS_ASSERT_EQUALS(str[9], ""); //LOG_TYP
TS_ASSERT_EQUALS(str[10], ""); //TEST_TXT
TS_ASSERT_EQUALS(str[11], ""); //ALARM_ID
TS_ASSERT_EQUALS(str[12], ""); //PROG_TXT
TS_ASSERT_EQUALS(str[13], ""); //RSLT_TXT
TS_ASSERT_EQUALS(str[14], "0"); //Z_VAL
TS_ASSERT_EQUALS(str[15], "00000101");//FMU_FLG
TS_ASSERT_EQUALS(str[16], ""); //MASK_MAP
TS_ASSERT_EQUALS(str[17], ""); //FAL_MAP
TS_ASSERT_EQUALS(str[18], "0"); //CYC_CNT
TS_ASSERT_EQUALS(str[19], "0"); //TOTF_CNT
TS_ASSERT_EQUALS(str[20], "0"); //TOTL_CNT
TS_ASSERT_EQUALS(str[21], "0"); //CYC_BASE
TS_ASSERT_EQUALS(str[22], "0"); //BIT_BASE
TS_ASSERT_EQUALS(str[23], "0"); //COND_CNT
TS_ASSERT_EQUALS(str[24], "0"); //LIM_CNT
TS_ASSERT_EQUALS(str[25], "0"); //CYC_SIZE
TS_ASSERT_EQUALS(str[26], "0"); //PMR_SIZE
TS_ASSERT_EQUALS(str[27], "0"); //CHN_SIZE
TS_ASSERT_EQUALS(str[28], "0"); //PAT_SIZE
TS_ASSERT_EQUALS(str[29], "0"); //BIT_SIZE
TS_ASSERT_EQUALS(str[30], "0"); //U1_SIZE
TS_ASSERT_EQUALS(str[31], "0"); //U2_SIZE
TS_ASSERT_EQUALS(str[32], "0"); //U3_SIZE
TS_ASSERT_EQUALS(str[33], "0"); //UTX_SIZE
TS_ASSERT_EQUALS(str[34], "0"); //CAP_BGN
TS_ASSERT_EQUALS(str[35], ""); //LIM_INDX
TS_ASSERT_EQUALS(str[36], ""); //LIM_SPEC
TS_ASSERT_EQUALS(str[37], ""); //COND_LST
TS_ASSERT_EQUALS(str[38], "0"); //CYCO_CNT
TS_ASSERT_EQUALS(str[39], ""); //CYC_OFST
TS_ASSERT_EQUALS(str[40], "0"); //PMR_CNT
TS_ASSERT_EQUALS(str[41], ""); //PMR_INDX
TS_ASSERT_EQUALS(str[42], "0"); //CHN_CNT
TS_ASSERT_EQUALS(str[43], ""); //CHN_NUM
TS_ASSERT_EQUALS(str[44], "0"); //EXP_CNT
TS_ASSERT_EQUALS(str[45], ""); //EXP_DATA
TS_ASSERT_EQUALS(str[46], "0"); //CAP_CNT
TS_ASSERT_EQUALS(str[47], ""); //CAP_DATA
TS_ASSERT_EQUALS(str[48], "0"); //NEW_CNT
TS_ASSERT_EQUALS(str[49], ""); //NEW_DATA
TS_ASSERT_EQUALS(str[50], "0"); //PAT_CNT
TS_ASSERT_EQUALS(str[51], ""); //PAT_NUM
TS_ASSERT_EQUALS(str[52], "0"); //BPOS_CNT
TS_ASSERT_EQUALS(str[53], ""); //BIT_POS
TS_ASSERT_EQUALS(str[54], "0"); //USR1_CNT
TS_ASSERT_EQUALS(str[55], ""); //USR1
TS_ASSERT_EQUALS(str[56], "0"); //USR2_CNT
TS_ASSERT_EQUALS(str[57], ""); //USR2
TS_ASSERT_EQUALS(str[58], "0"); //USR3_CNT
TS_ASSERT_EQUALS(str[59], ""); //USR3
TS_ASSERT_EQUALS(str[60], "0"); //TXT_CNT
TS_ASSERT_EQUALS(str[61], ""); //USER_TXT
}