void computeFeatures(string text) { cout<< endl<< "String: " << text <<endl; cout<< "Size: " << text.size(); cout<< " Capacity: " << text.capacity(); cout<< " Empty?: " << text.empty() <<endl; }
// display string statistics void printStatistics( const string &stringRef ) { cout << "capacity: " << stringRef.capacity() << "\nmax size: " << stringRef.max_size() << "\nsize: " << stringRef.size() << "\nlength: " << stringRef.length() << "\nempty: " << stringRef.empty(); } // end printStatistics
void StringTest::capacity() { string s; CPPUNIT_CHECK( s.capacity() >= 0 ); CPPUNIT_CHECK( s.capacity() < s.max_size() ); CPPUNIT_CHECK( s.capacity() >= s.size() ); for ( int i = 0; i < 16 + 2; ++i ) { s += ' '; CPPUNIT_CHECK( s.capacity() > 0 ); CPPUNIT_CHECK( s.capacity() < s.max_size() ); CPPUNIT_CHECK( s.capacity() >= s.size() ); } }
void MAFParse::parseLineLC(ifstream & mafin, string & acttoken, string & actline) { checkParseIsInContig(acttoken); mafin >> MAF_contig_len; if(MAF_contig_len>actline.capacity()) actline.reserve(MAF_contig_len+10); }
void SelfGrow( string& s, size_t appendlength ) { size_t c = s.capacity(); if( c <= ( s.length() + appendlength ) ) { while( (c *= 2) <= ( s.length() + appendlength ) ); s.reserve(c); } }
void check (string s, string name){ cout << "checking " << name << endl; cout << name << " contains " << s << endl; cout << name << " capacity() is " << s.capacity() << endl; cout << name << " length() is " << s.length() << endl; cout << name << " size() is " << s.size() << endl; cout << name << " max_size() is " << s.max_size() << endl << endl; }
bool istream::read(string& s, bool loop /* = true */) { s.clear(); int ret; if ((ret = read(s.buf(), s.capacity(), loop)) == -1) return false; s.set_offset(ret); return true; }
string SimpleCurl::escape(string toEscape) { char* escapedString = curl_easy_escape(this->curlHandle, toEscape.c_str(), toEscape.capacity()); string escapedStringRet = string(escapedString); curl_free(escapedString); return escapedStringRet; }
size_t size_below(const string& s) { return s.capacity() * sizeof(char); }
void MAFParse::parseLineLR(ifstream & mafin, string & acttoken, string & actline) { checkParseIsInRead(acttoken); mafin >> MAF_read_len; if(MAF_read_len>actline.capacity()) actline.reserve(MAF_read_len+10); }