2
// Copyright � 1997 - 2001, Paul C. Gregory
4
// Contact: pgregory@aqsis.com
6
// This library is free software; you can redistribute it and/or
7
// modify it under the terms of the GNU General Public
8
// License as published by the Free Software Foundation; either
9
// version 2 of the License, or (at your option) any later version.
11
// This library is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
// General Public License for more details.
16
// You should have received a copy of the GNU General Public
17
// License along with this library; if not, write to the Free Software
18
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
\brief Declares an extended string class, CqString, derived from std::string
23
\author Paul C. Gregory (pgregory@aqsis.com)
26
//? Is .h included already?
27
#ifndef SSTRING_H_INCLUDED
28
#define SSTRING_H_INCLUDED 1
37
START_NAMESPACE( Aqsis )
39
typedef std::string CqStringBase;
41
//----------------------------------------------------------------------
43
* An extended string class, derived from std::string
46
class CqString : public CqStringBase
49
CqString() : CqStringBase()
51
CqString( const CqString& str ) : CqStringBase( str )
53
CqString( const CqStringBase& str ) : CqStringBase( str )
55
CqString( const TqChar* s ) : CqStringBase( s )
57
/** Construct from an integer,
63
/** Construct from a float,
70
// Format a string printf style.
71
CqString& Format( const TqChar* Format, ... );
72
CqString ExpandEscapes() const;
73
CqString TranslateEscapes() const;
75
// Concatenation functions not provided by std::string
76
CqString& operator+=( const CqString& str );
77
CqString& operator+=( const TqChar* str );
78
CqString& operator+=( TqChar c );
79
CqString& operator+=( TqInt i );
80
CqString& operator+=( TqFloat f );
84
// Some useful functions
85
std::ostream& operator<<( std::ostream & stmOutput, const CqString& strString );
86
CqString operator+( const CqString& strAdd1, const CqString& strAdd2 );
87
CqString operator+( const TqChar* strAdd1, const CqString& strAdd2 );
88
CqString operator+( const CqString& strAdd1, const TqChar* strAdd2 );
89
CqString operator+( const CqString& strAdd1, TqChar ch );
90
CqString operator+( TqChar ch, const CqString& strAdd2 );
92
// These must be defined so that std::string can be used as a type in the ShaderVM and
93
// in the parameter dicing code.
94
CqString operator/( const CqString& strAdd1, const CqString& strAdd2 );
95
CqString operator*( const CqString& strAdd1, const CqString& strAdd2 );
96
CqString operator*( const CqString& strAdd1, TqFloat f );
97
CqString operator-( const CqString& strAdd1, const CqString& strAdd2 );
99
/// The ultimate function for converting anything into a string
100
template<typename value_t>
101
CqString ToString(const value_t& Value)
103
std::ostringstream buffer;
105
return CqString(buffer.str());
108
//-----------------------------------------------------------------------
110
END_NAMESPACE( Aqsis )
112
#endif // !SSTRING_H_INCLUDED