indent classes, align by spaces
This commit is contained in:
@@ -39,54 +39,54 @@ inline void StringPool_analyse( StringPool& pool ){
|
||||
template<typename PoolContext>
|
||||
class PooledString
|
||||
{
|
||||
StringPool::iterator m_i;
|
||||
static StringPool::iterator increment( StringPool::iterator i ){
|
||||
++( *i ).value;
|
||||
return i;
|
||||
}
|
||||
static StringPool::iterator insert( const char* string ){
|
||||
StringPool::iterator i = PoolContext::instance().find( const_cast<char*>( string ) );
|
||||
if ( i == PoolContext::instance().end() ) {
|
||||
return PoolContext::instance().insert( string_clone( string ), 1 );
|
||||
StringPool::iterator m_i;
|
||||
static StringPool::iterator increment( StringPool::iterator i ){
|
||||
++( *i ).value;
|
||||
return i;
|
||||
}
|
||||
return increment( i );
|
||||
}
|
||||
static void erase( StringPool::iterator i ){
|
||||
if ( --( *i ).value == 0 ) {
|
||||
char* string = ( *i ).key;
|
||||
PoolContext::instance().erase( i );
|
||||
string_release( string, string_length( string ) );
|
||||
static StringPool::iterator insert( const char* string ){
|
||||
StringPool::iterator i = PoolContext::instance().find( const_cast<char*>( string ) );
|
||||
if ( i == PoolContext::instance().end() ) {
|
||||
return PoolContext::instance().insert( string_clone( string ), 1 );
|
||||
}
|
||||
return increment( i );
|
||||
}
|
||||
static void erase( StringPool::iterator i ){
|
||||
if ( --( *i ).value == 0 ) {
|
||||
char* string = ( *i ).key;
|
||||
PoolContext::instance().erase( i );
|
||||
string_release( string, string_length( string ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
public:
|
||||
PooledString() : m_i( insert( "" ) ){
|
||||
}
|
||||
PooledString( const PooledString& other ) : m_i( increment( other.m_i ) ){
|
||||
}
|
||||
PooledString( const char* string ) : m_i( insert( string ) ){
|
||||
}
|
||||
~PooledString(){
|
||||
erase( m_i );
|
||||
}
|
||||
PooledString& operator=( const PooledString& other ){
|
||||
PooledString tmp( other );
|
||||
tmp.swap( *this );
|
||||
return *this;
|
||||
}
|
||||
PooledString& operator=( const char* string ){
|
||||
PooledString tmp( string );
|
||||
tmp.swap( *this );
|
||||
return *this;
|
||||
}
|
||||
void swap( PooledString& other ){
|
||||
std::swap( m_i, other.m_i );
|
||||
}
|
||||
bool operator==( const PooledString& other ) const {
|
||||
return m_i == other.m_i;
|
||||
}
|
||||
const char* c_str() const {
|
||||
return ( *m_i ).key;
|
||||
}
|
||||
PooledString() : m_i( insert( "" ) ){
|
||||
}
|
||||
PooledString( const PooledString& other ) : m_i( increment( other.m_i ) ){
|
||||
}
|
||||
PooledString( const char* string ) : m_i( insert( string ) ){
|
||||
}
|
||||
~PooledString(){
|
||||
erase( m_i );
|
||||
}
|
||||
PooledString& operator=( const PooledString& other ){
|
||||
PooledString tmp( other );
|
||||
tmp.swap( *this );
|
||||
return *this;
|
||||
}
|
||||
PooledString& operator=( const char* string ){
|
||||
PooledString tmp( string );
|
||||
tmp.swap( *this );
|
||||
return *this;
|
||||
}
|
||||
void swap( PooledString& other ){
|
||||
std::swap( m_i, other.m_i );
|
||||
}
|
||||
bool operator==( const PooledString& other ) const {
|
||||
return m_i == other.m_i;
|
||||
}
|
||||
const char* c_str() const {
|
||||
return ( *m_i ).key;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user