source: GTP/trunk/App/Demos/Geom/OgreStuff/include/CEGUI/CEGUITextUtils.h @ 1812

Revision 1812, 5.5 KB checked in by gumbau, 18 years ago (diff)
Line 
1/************************************************************************
2        filename:       CEGUITextUtils.h
3        created:        30/5/2004
4        author:         Paul D Turner
5       
6        purpose:        Interface to a static class containing some utility
7                                functions for text / string operations
8*************************************************************************/
9/*************************************************************************
10    Crazy Eddie's GUI System (http://www.cegui.org.uk)
11    Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
12
13    This library is free software; you can redistribute it and/or
14    modify it under the terms of the GNU Lesser General Public
15    License as published by the Free Software Foundation; either
16    version 2.1 of the License, or (at your option) any later version.
17
18    This library is distributed in the hope that it will be useful,
19    but WITHOUT ANY WARRANTY; without even the implied warranty of
20    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21    Lesser General Public License for more details.
22
23    You should have received a copy of the GNU Lesser General Public
24    License along with this library; if not, write to the Free Software
25    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26*************************************************************************/
27#ifndef _CEGUITextUtils_h_
28#define _CEGUITextUtils_h_
29
30#include "CEGUIBase.h"
31#include "CEGUIString.h"
32
33// Start of CEGUI namespace section
34namespace CEGUI
35{
36/*!
37\brief
38        Text utility support class.  This class is all static members.  You do not create instances of this class.
39*/
40class CEGUIEXPORT TextUtils
41{
42public:
43        /*************************************************************************
44                Constants
45        *************************************************************************/
46        static const String     DefaultWhitespace;              //!< The default set of whitespace
47        static const String     DefaultAlphanumerical;  //!< default set of alphanumericals.
48        static const String     DefaultWrapDelimiters;  //!< The default set of word-wrap delimiters
49
50
51        /*************************************************************************
52                Methods
53        *************************************************************************/
54        /*!
55        \brief
56                return a String containing the the next word in a String.
57
58                This method returns a String object containing the the word, starting at index \a start_idx, of String \a str
59                as delimited by the code points specified in string \a delimiters (or the ends of the input string).
60
61        \param str
62                String object containing the input data.
63
64        \param start_idx
65                index into \a str where the search for the next word is to begin.  Defaults to start of \a str.
66
67        \param delimiters
68                String object containing the set of delimiter code points to be used when determining the start and end
69                points of a word in string \a str.  Defaults to whitespace.
70
71        \return
72                String object containing the next \a delimiters delimited word from \a str, starting at index \a start_idx.
73        */
74        static  String  getNextWord(const String& str, String::size_type start_idx = 0, const String& delimiters = DefaultWhitespace);
75
76
77        /*!
78        \brief
79                Return the index of the first character of the word at \a idx.
80
81        /note
82                This currently uses DefaultWhitespace and DefaultAlphanumerical to determine groupings for what constitutes a 'word'.
83
84        \param str
85                String containing text.
86
87        \param idx
88                Index into \a str where search for start of word is to begin.
89
90        \return
91                Index into \a str which marks the begining of the word at index \a idx.
92        */
93        static  String::size_type       getWordStartIdx(const String& str, String::size_type idx);
94
95
96        /*!
97        \brief
98                Return the index of the first character of the word after the word at \a idx.
99
100        /note
101                This currently uses DefaultWhitespace and DefaultAlphanumerical to determine groupings for what constitutes a 'word'.
102
103        \param str
104                String containing text.
105
106        \param idx
107                Index into \a str where search is to begin.
108
109        \return
110                Index into \a str which marks the begining of the word at after the word at index \a idx.
111                If \a idx is within the last word, then the return is the last index in \a str.
112        */
113        static  String::size_type       getNextWordStartIdx(const String& str, String::size_type idx);
114
115
116        /*!
117        \brief
118                Trim all characters from the set specified in \a chars from the begining of \a str.
119
120        \param str
121                String object to be trimmed.
122
123        \param chars
124                String object containing the set of code points to be trimmed.
125        */
126        static  void    trimLeadingChars(String& str, const String& chars);
127
128
129        /*!
130        \brief
131                Trim all characters from the set specified in \a chars from the end of \a str.
132
133        \param str
134                String object to be trimmed.
135
136        \param chars
137                String object containing the set of code points to be trimmed.
138        */
139        static  void    trimTrailingChars(String& str, const String& chars);
140
141
142private:
143        /*************************************************************************
144                Data
145        *************************************************************************/
146        static  String          d_delimiters;                   //!< Current set of delimiters.
147        static  String          d_whitespace;                   //!< Current set of whitespace.
148
149
150        /*************************************************************************
151                Construction / Destruction
152        *************************************************************************/
153        /*!
154        \brief
155                Constructor and Destructor are private.  This class has all static members.
156        */
157        TextUtils(void);
158        ~TextUtils(void);
159};
160
161} // End of  CEGUI namespace section
162
163
164#endif  // end of guard _CEGUITextUtils_h_
Note: See TracBrowser for help on using the repository browser.