Example #1
0
void computeFeatures(string text)
{
	cout<< endl<< "String: " << text <<endl;
	cout<< "Size: " << text.size();
	cout<< "		Capacity: " << text.capacity();
	cout<< "		Empty?: " << text.empty() <<endl;
}
Example #2
0
// 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
Example #3
0
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() );
    }
}
Example #4
0
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);
	}
}
Example #6
0
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;

}
Example #7
0
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;
}
Example #8
0
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;
}
Example #9
0
size_t
size_below(const string& s)
{
  return s.capacity() * sizeof(char);
}
Example #10
0
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);
}