Någon som har lite roliga kommentarer på denna classen? Har nog fått lite type cast förmycket här och där... men jag har blivit så förvirrad på koden att jag inte orkar kolla på den mer just nu...
<font size="1" face="Verdana, Arial, Helvetica, sans-serif">Kod:<font size="1" face="Verdana, Arial, Helvetica, sans-serif" color="#666600">
#ifndef _pthread_string_hpp_
#define _pthread_string_hpp_
#include <pthread.h>
#include <iostream>
#include <unistd.h>
#include <string>
#include <bits/stl_pthread_alloc.h>
namespace std
{
typedef std::\__allocator\<char, std::pthread_alloc\> std_char_pthread_alloc;
typedef std::basic_string\< char, std::char_traits\<char\>, std_char_pthread_alloc \> std_pthread_basic_string;
class pthread_string : public std_pthread_basic_string
{
public:
pthread_string() throw(): std_pthread_basic_string()
{
}
pthread_string( const std_pthread_basic_string& pth_b_str ) throw(): std_pthread_basic_string( pth_b_str )
{
}
pthread_string( const char\* x, int& y ) throw(): std_pthread_basic_string( x, y )
{
}
pthread_string( const pthread_string& pth_str ) throw()
{
\*this = pth_str;
}
pthread_string( const string& str ) throw()
{
\*this = str.c_str();
}
pthread_string( const char\* str ) throw() : std_pthread_basic_string(str)
{
}
pthread_string& operator=( const std_pthread_basic_string& str) throw()
{
return (pthread_string&) (\*(std_pthread_basic_string\*)this = str);
}
pthread_string& operator=( const string& str ) throw()
{
return (pthread_string&) (\*this = str.c_str());
}
pthread_string& operator=( const char\* str ) throw()
{
return (pthread_string&) (\*(std_pthread_basic_string\*)this = str);
}
pthread_string& operator+=( const std_pthread_basic_string& str) throw()
{
return (pthread_string&) (\*(std_pthread_basic_string\*)this += str);
}
pthread_string& operator+=( const string& str) throw()
{
return (pthread_string&) (\*(std_pthread_basic_string\*)this += str.c_str());
}
pthread_string& operator+=( const char\* str ) throw()
{
return (pthread_string&) (\*(std_pthread_basic_string\*)this += str);
}
pthread_string& operator+=( const char& str ) throw()
{
this-\>push_back( str );
return \*this;
}
bool operator==( const string& str )
{
return !strcmp(this-\>c_str(), str.c_str());
}
bool operator==( const char\* str)
{
return !strcmp(this-\>c_str(), str );
}
string to_string( void ) const throw()
{
return this-\>c_str();
}
int to_int( void ) const throw()
{
return atoi( this-\>c_str());
}
string& convert( string& str) const throw()
{
str = this-\>c_str();
return str ;
}
int& convert( int& x) const throw()
{
return x = atoi( this-\>c_str());
}
};
}
#endif //_pthread_string_hpp_