~ubuntu-branches/ubuntu/warty/aqsis/warty

« back to all changes in this revision

Viewing changes to libaqsistypes/sstring.h

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2004-08-24 07:25:04 UTC
  • Revision ID: james.westby@ubuntu.com-20040824072504-zf993vnevvisdsvb
Tags: upstream-0.9.1
Import upstream version 0.9.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Aqsis
 
2
// Copyright � 1997 - 2001, Paul C. Gregory
 
3
//
 
4
// Contact: pgregory@aqsis.com
 
5
//
 
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.
 
10
//
 
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.
 
15
//
 
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
 
19
 
 
20
 
 
21
/** \file
 
22
                \brief Declares an extended string class, CqString, derived from std::string
 
23
                \author Paul C. Gregory (pgregory@aqsis.com)
 
24
*/
 
25
 
 
26
//? Is .h included already?
 
27
#ifndef SSTRING_H_INCLUDED
 
28
#define SSTRING_H_INCLUDED 1
 
29
 
 
30
#include <string>
 
31
#include <sstream>
 
32
#include <iostream>
 
33
 
 
34
#include "aqsis.h"
 
35
 
 
36
 
 
37
START_NAMESPACE( Aqsis )
 
38
 
 
39
typedef std::string CqStringBase;
 
40
 
 
41
//----------------------------------------------------------------------
 
42
/** \class CqString
 
43
 * An extended string class, derived from std::string
 
44
 */
 
45
 
 
46
class CqString : public CqStringBase
 
47
{
 
48
public:
 
49
    CqString() : CqStringBase()
 
50
    {}
 
51
    CqString( const CqString& str ) : CqStringBase( str )
 
52
    {}
 
53
    CqString( const CqStringBase& str ) : CqStringBase( str )
 
54
    {}
 
55
    CqString( const TqChar* s ) : CqStringBase( s )
 
56
    {}
 
57
    /** Construct from an integer,
 
58
     */
 
59
    CqString( TqInt i )
 
60
    {
 
61
        *this += i;
 
62
    }
 
63
    /** Construct from a float,
 
64
     */
 
65
    CqString( TqFloat f )
 
66
    {
 
67
        *this += f;
 
68
    }
 
69
 
 
70
    // Format a string printf style.
 
71
    CqString&   Format( const TqChar* Format, ... );
 
72
    CqString    ExpandEscapes() const;
 
73
    CqString    TranslateEscapes() const;
 
74
 
 
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 );
 
81
};
 
82
 
 
83
 
 
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 );
 
91
 
 
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 );
 
98
 
 
99
/// The ultimate function for converting anything into a string
 
100
template<typename value_t>
 
101
CqString ToString(const value_t& Value)
 
102
{
 
103
    std::ostringstream buffer;
 
104
    buffer << Value;
 
105
    return CqString(buffer.str());
 
106
}
 
107
 
 
108
//-----------------------------------------------------------------------
 
109
 
 
110
END_NAMESPACE( Aqsis )
 
111
 
 
112
#endif  // !SSTRING_H_INCLUDED
 
113