Spinning Topp Logo BlackTopp Studios
inc
stringtool.cpp
1 // © Copyright 2010 - 2016 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 #ifndef _stringtool_cpp
41 #define _stringtool_cpp
42 
43 #include "stringtool.h"
44 #include "exception.h"
45 
46 #include <sstream>
47 #include <algorithm>
48 #include <cctype>
49 //#include <locale>
50 
51 namespace
52 {
53  /// @internal
54  /// @brief Convenience multiplier used for converting a colour value for a single channel to a scalar value.
55  const Mezzanine::Real HexConversionMultiplier = Mezzanine::Real(1.0 / 255.0);
56 
57  /// @internal
58  /// @brief Converts a string containing hex to a ColourValue channel.
59  /// @param Hex The Hex value to be converted.
60  /// @return Returns a Real representing the converted Hex string that can be applied to a ColourValue channel.
61  Mezzanine::Real ConvertHexToColourChannel(const Mezzanine::String& Hex)
62  {
63  if( Hex.size() != 2 ) {
64  MEZZ_EXCEPTION(Mezzanine::ExceptionBase::PARAMETERS_EXCEPTION,"Hex code requires 2 characters to express a ColourValue channel.");
65  }
66 
67  Mezzanine::Real Ret = 0;
68  Mezzanine::StringStream Converter;
69  Converter << std::hex << Hex;
70  Converter >> Ret;
71  return std::min(Ret *= HexConversionMultiplier,Mezzanine::Real(1.0));
72  }
73  /// @internal
74  /// @brief Converts a ColourValue channel to Hex.
75  /// @param Channel The value to be converted to Hex.
76  /// @return Returns a two character string containing the hex expression for the provided channel value.
77  Mezzanine::String ConvertColourChannelToHex(const Mezzanine::Real Channel)
78  {
80  Mezzanine::StringStream Converter;
81  Converter << std::hex << static_cast<Mezzanine::UInt8>( Channel * 255.0 );
82  Converter >> Ret;
83 
84  if( Ret.size() == 1 ) {
85  Ret.insert(0,1,'0');
86  }
87  return Ret;
88  }
89 }
90 
91 namespace Mezzanine
92 {
93  namespace StringTools
94  {
95  ///////////////////////////////////////////////////////////////////////////////
96  // Character Manipulation and Checks
97 
99  { return ( ToCheck >= '0' && ToCheck <= '9' ); }
100 
102  { return ( ToCheck >= 'a' && ToCheck <= 'z' ); }
103 
105  { return ( ToCheck >= 'A' && ToCheck <= 'Z' ); }
106 
108  { return ( IsLowerAlphaLetter(ToCheck) || IsUpperAlphaLetter(ToCheck) ); }
109 
110  Boole IsLowerHexLetter(const Char8 ToCheck)
111  { return ( ToCheck >= 'a' && ToCheck <= 'f' ); }
112 
113  Boole IsUpperHexLetter(const Char8 ToCheck)
114  { return ( ToCheck >= 'A' && ToCheck <= 'F' ); }
115 
116  Boole IsHexLetter(const Char8 ToCheck)
117  { return ( IsLowerHexLetter(ToCheck) || IsUpperHexLetter(ToCheck) ); }
118 
120  { return ( IsDigit(ToCheck) || IsHexLetter(ToCheck) ); }
121 
122  Boole IsAlphanumeric(const Char8 ToCheck)
123  { return ( IsDigit(ToCheck) || IsAlphaLetter(ToCheck) ); }
124 
125  ///////////////////////////////////////////////////////////////////////////////
126  // String Manipulation and Checks
127 
128  void Trim(String& Source, Boole Left, Boole Right)
129  {
130  const String Delims = " \t\r";
131  if( Left ) {
132  Whole Forward = 0;
133  while( Forward < Source.size() )
134  {
135  if( Delims.find( Source[Forward] ) == String::npos ) {
136  break;
137  }
138  ++Forward;
139  }
140  Source.erase(0,Forward);
141  }
142  if( Right ) {
143  Whole Reverse = Source.size();
144  while( Reverse > 0 )
145  {
146  if( Delims.find( Source[Reverse-1] ) == String::npos ) {
147  break;
148  }
149  --Reverse;
150  }
151  Source.erase(Reverse);
152  }
153  }
154 
155  StringVector Split(const String& Source, const String& Delims, const Whole MaxSplits)
156  {
157  StringVector Ret;
158  Ret.reserve( MaxSplits ? MaxSplits + 1 : 10 );
159  Whole Splits = 0;
160 
161  size_t Start = 0;
162  size_t Pos = 0;
163 
164  do{
165  Pos = Source.find_first_of(Delims,Start);
166  if( Pos == Start ) {
167  Start = Pos + 1;
168  }else if( Pos == String::npos || ( MaxSplits && Splits == MaxSplits ) ) {
169  Ret.push_back(Source.substr(Start));
170  break;
171  }else{
172  Ret.push_back(Source.substr(Start,Pos - Start));
173  Start = Pos + 1;
174  }
175  Start = Source.find_first_not_of(Delims,Start);
176  ++Splits;
177  }while(Pos != String::npos);
178 
179  return Ret;
180  }
181 
182  void ToUpperCase(String& Source)
183  {
184  std::transform(Source.begin(),Source.end(),Source.begin(),::toupper);
185  }
186 
188  {
189  StringTools::ToUpperCase(Source);
190  return Source;
191  }
192 
193  void ToLowerCase(String& Source)
194  {
195  std::transform(Source.begin(),Source.end(),Source.begin(),::tolower);
196  }
197 
199  {
200  StringTools::ToLowerCase(Source);
201  return Source;
202  }
203 
204  void ToCamelCase(String& Source)
205  {
206  Boole PrevCharIsLetter = false;
207  for( String::iterator CurrIt = Source.begin() ; CurrIt != Source.end() ; ++CurrIt )
208  {
209  Boole CurrCharIsLowerLetter = StringTools::IsLowerAlphaLetter( *CurrIt );
210  Boole CurrCharIsUpperLetter = StringTools::IsUpperAlphaLetter( *CurrIt );
211  if( !PrevCharIsLetter && CurrCharIsLowerLetter ) {
212  (*CurrIt) -= 32;
213  }else if( PrevCharIsLetter && CurrCharIsUpperLetter ) {
214  (*CurrIt) += 32;
215  }
216  PrevCharIsLetter = CurrCharIsLowerLetter || CurrCharIsUpperLetter;
217  ++CurrIt;
218  }
219  }
220 
222  {
223  StringTools::ToCamelCase(Source);
224  return Source;
225  }
226 
227  Boole StartsWith(const String& Str, const String& Pattern, const Boole CaseSensitive)
228  {
229  size_t StrLen = Str.length();
230  size_t PatternLen = Pattern.length();
231  String Start = Str.substr(0,PatternLen);
232 
233  if( CaseSensitive ) {
234  return ( Start == Pattern );
235  }
236 
237  if( PatternLen > StrLen || PatternLen == 0 ) {
238  return false;
239  }
240 
241  String LowerPattern = Pattern;
243  StringTools::ToLowerCase(LowerPattern);
244  return (Start == LowerPattern);
245  }
246 
247  Boole EndsWith(const String& Str, const String& Pattern, const Boole CaseSensitive)
248  {
249  size_t StrLen = Str.length();
250  size_t PatternLen = Pattern.length();
251  String End = Str.substr(StrLen - PatternLen,PatternLen);
252 
253  if( CaseSensitive ) {
254  return ( End == Pattern );
255  }
256 
257  if( PatternLen > StrLen || PatternLen == 0 ) {
258  return false;
259  }
260 
261  String LowerPattern = Pattern;
263  StringTools::ToLowerCase(LowerPattern);
264  return ( End == LowerPattern );
265  }
266 
268  {
269  for( size_t CurrIndex = Source.find_first_of(" ") ; CurrIndex != String::npos ; CurrIndex = Source.find_first_of(" ",CurrIndex) )
270  {
271  size_t EndIndex = CurrIndex;
272  while( Source[EndIndex] == ' ' ) EndIndex++;
273  Source.replace(CurrIndex,EndIndex-CurrIndex," ");
274  CurrIndex++;
275  }
276  }
277 
278  ///////////////////////////////////////////////////////////////////////////////
279  // Data Class Utilities
280 
281  Vector2 ConvertToVector2(const String& ToConvert)
282  {
283  StringVector Digits = Split(ToConvert);
284  if( 2 == Digits.size() ) {
285  return Vector2(ConvertToReal(Digits.at(0)),ConvertToReal(Digits.at(1)));
286  }else{
287  MEZZ_EXCEPTION(ExceptionBase::PARAMETERS_EXCEPTION,"String does not contain 2 digits when attempting to convert.");
288  }
289  }
290 
291  String ConvertToString(const Vector2& ToConvert)
292  {
293  StringStream converter;
294  converter << ToConvert.X << " " << ToConvert.Y;
295  return converter.str();
296  }
297 
298  Vector3 ConvertToVector3(const String& ToConvert)
299  {
300  StringVector Digits = Split(ToConvert);
301  if( 3 == Digits.size() ) {
302  return Vector3(ConvertToReal(Digits.at(0)),ConvertToReal(Digits.at(1)),ConvertToReal(Digits.at(2)));
303  }else{
304  MEZZ_EXCEPTION(ExceptionBase::PARAMETERS_EXCEPTION,"String does not contain 3 digits when attempting to convert.");
305  }
306  }
307 
308  String ConvertToString(const Vector3& ToConvert)
309  {
310  StringStream converter;
311  converter << ToConvert.X << " " << ToConvert.Y << " " << ToConvert.Z;
312  return converter.str();
313  }
314 
316  {
317  StringVector Digits = Split(ToConvert);
318  if( 4 == Digits.size() ) {
319  return Quaternion(ConvertToReal(Digits.at(0)),ConvertToReal(Digits.at(1)),ConvertToReal(Digits.at(2)),ConvertToReal(Digits.at(3)));
320  }else{
321  MEZZ_EXCEPTION(ExceptionBase::PARAMETERS_EXCEPTION,"String does not contain 4 digits when attempting to convert.");
322  }
323  }
324 
326  {
327  StringStream converter;
328  converter << ToConvert.X << " " << ToConvert.Y << " " << ToConvert.Z << " " << ToConvert.W;
329  return converter.str();
330  }
331 
333  {
334  StringVector Digits = Split(ToConvert);
335  if( 4 == Digits.size() ) {
336  return ColourValue(ConvertToReal(Digits.at(0)),ConvertToReal(Digits.at(1)),ConvertToReal(Digits.at(2)),ConvertToReal(Digits.at(3)));
337  }else{
338  MEZZ_EXCEPTION(ExceptionBase::PARAMETERS_EXCEPTION,"String does not contain 4 digits when attempting to convert.");
339  }
340  }
341 
343  {
344  StringStream converter;
345  converter << ToConvert.RedChannel << " " << ToConvert.GreenChannel << " " << ToConvert.BlueChannel << " " << ToConvert.AlphaChannel;
346  return converter.str();
347  }
348 
350  {
351  if( ToConvert.size() < 6 ) {
352  MEZZ_EXCEPTION(ExceptionBase::PARAMETERS_EXCEPTION,"Hex code requires a minimum of 6 characters to express a ColourValue instance.");
353  }
354 
355  ColourValue Ret;
356  Ret.RedChannel = ConvertHexToColourChannel( ToConvert.substr(0,2) );
357  Ret.GreenChannel = ConvertHexToColourChannel( ToConvert.substr(2,2) );
358  Ret.BlueChannel = ConvertHexToColourChannel( ToConvert.substr(4,2) );
359 
360  if( ToConvert.size() == 6 ) Ret.AlphaChannel = 1.0;
361  else Ret.AlphaChannel = ConvertHexToColourChannel( ToConvert.substr(6,2) );
362 
363  return Ret;
364  }
365 
367  {
368  String Ret;
369  Ret.append( ConvertColourChannelToHex(ToConvert.RedChannel) );
370  Ret.append( ConvertColourChannelToHex(ToConvert.GreenChannel) );
371  Ret.append( ConvertColourChannelToHex(ToConvert.BlueChannel) );
372  Ret.append( ConvertColourChannelToHex(ToConvert.AlphaChannel) );
373  return Ret;
374  }
375 
376  ///////////////////////////////////////////////////////////////////////////////
377  // Convert-To-Data functions
378 
379  Boole ConvertToBool(const String& ToConvert, const Boole Default)
380  {
381  String StrCopy = ToConvert;
382  StringTools::ToLowerCase(StrCopy);
383  if("true" == StrCopy) return true;
384  else if("yes" == StrCopy) return true;
385  else if("1" == StrCopy) return true;
386  else if("false" == StrCopy) return false;
387  else if("no" == StrCopy) return false;
388  else if("0" == StrCopy) return false;
389  else return Default;
390  }
391 
392  Real ConvertToReal(const String& ToConvert)
393  {
394  StringStream converter(ToConvert);
395  Real Result;
396  converter >> Result;
397  return Result;
398  }
399 
400  Integer ConvertToInteger(const String& ToConvert)
401  {
402  StringStream converter(ToConvert);
403  Integer Result;
404  converter >> Result;
405  return Result;
406  }
407 
408  Whole ConvertToWhole(const String& ToConvert)
409  {
410  StringStream converter(ToConvert);
411  Whole Result;
412  converter >> Result;
413  return Result;
414  }
415 
416  Int8 ConvertToInt8(const String& ToConvert)
417  {
418  StringStream converter(ToConvert);
419  Int8 Result;
420  converter >> Result;
421  return Result;
422  }
423 
424  UInt8 ConvertToUInt8(const String& ToConvert)
425  {
426  StringStream converter(ToConvert);
427  UInt8 Result;
428  converter >> Result;
429  return Result;
430  }
431 
432  Int16 ConvertToInt16(const String& ToConvert)
433  {
434  StringStream converter(ToConvert);
435  Int16 Result;
436  converter >> Result;
437  return Result;
438  }
439 
440  UInt16 ConvertToUInt16(const String& ToConvert)
441  {
442  StringStream converter(ToConvert);
443  UInt16 Result;
444  converter >> Result;
445  return Result;
446  }
447 
448  Int32 ConvertToInt32(const String& ToConvert)
449  {
450  StringStream converter(ToConvert);
451  Int32 Result;
452  converter >> Result;
453  return Result;
454  }
455 
456  UInt32 ConvertToUInt32(const String& ToConvert)
457  {
458  StringStream converter(ToConvert);
459  UInt32 Result;
460  converter >> Result;
461  return Result;
462  }
463 
464  String ConvertToString(const Input::InputCode& Code, Boole ShiftPressed)
465  {
466  /// @todo Get this ( StringTools::ConvertToString ) to support non us keyboards
467  switch(Code)
468  {
469  case Input::KEY_A: return ( ShiftPressed ? "A" : "a" ); break;
470  case Input::KEY_B: return ( ShiftPressed ? "B" : "b" ); break;
471  case Input::KEY_C: return ( ShiftPressed ? "C" : "c" ); break;
472  case Input::KEY_D: return ( ShiftPressed ? "D" : "d" ); break;
473  case Input::KEY_E: return ( ShiftPressed ? "E" : "e" ); break;
474  case Input::KEY_F: return ( ShiftPressed ? "F" : "f" ); break;
475  case Input::KEY_G: return ( ShiftPressed ? "G" : "g" ); break;
476  case Input::KEY_H: return ( ShiftPressed ? "H" : "h" ); break;
477  case Input::KEY_I: return ( ShiftPressed ? "I" : "i" ); break;
478  case Input::KEY_J: return ( ShiftPressed ? "J" : "j" ); break;
479  case Input::KEY_K: return ( ShiftPressed ? "K" : "k" ); break;
480  case Input::KEY_L: return ( ShiftPressed ? "L" : "l" ); break;
481  case Input::KEY_M: return ( ShiftPressed ? "M" : "m" ); break;
482  case Input::KEY_N: return ( ShiftPressed ? "N" : "n" ); break;
483  case Input::KEY_O: return ( ShiftPressed ? "O" : "o" ); break;
484  case Input::KEY_P: return ( ShiftPressed ? "P" : "p" ); break;
485  case Input::KEY_Q: return ( ShiftPressed ? "Q" : "q" ); break;
486  case Input::KEY_R: return ( ShiftPressed ? "R" : "r" ); break;
487  case Input::KEY_S: return ( ShiftPressed ? "S" : "s" ); break;
488  case Input::KEY_T: return ( ShiftPressed ? "T" : "t" ); break;
489  case Input::KEY_U: return ( ShiftPressed ? "U" : "u" ); break;
490  case Input::KEY_V: return ( ShiftPressed ? "V" : "v" ); break;
491  case Input::KEY_W: return ( ShiftPressed ? "W" : "w" ); break;
492  case Input::KEY_X: return ( ShiftPressed ? "X" : "x" ); break;
493  case Input::KEY_Y: return ( ShiftPressed ? "Y" : "y" ); break;
494  case Input::KEY_Z: return ( ShiftPressed ? "Z" : "z" ); break;
495  case Input::KEY_1: return ( ShiftPressed ? "!" : "1" ); break;
496  case Input::KEY_2: return ( ShiftPressed ? "@" : "2" ); break;
497  case Input::KEY_3: return ( ShiftPressed ? "#" : "3" ); break;
498  case Input::KEY_4: return ( ShiftPressed ? "$" : "4" ); break;
499  case Input::KEY_5: return ( ShiftPressed ? "%" : "5" ); break;
500  case Input::KEY_6: return ( ShiftPressed ? "^" : "6" ); break;
501  case Input::KEY_7: return ( ShiftPressed ? "&" : "7" ); break;
502  case Input::KEY_8: return ( ShiftPressed ? "*" : "8" ); break;
503  case Input::KEY_9: return ( ShiftPressed ? "(" : "9" ); break;
504  case Input::KEY_0: return ( ShiftPressed ? ")" : "0" ); break;
505  case Input::KEY_MINUS: return ( ShiftPressed ? "_" : "-" ); break;
506  case Input::KEY_EQUALS: return ( ShiftPressed ? "+" : "=" ); break;
507  case Input::KEY_LEFTBRACKET: return ( ShiftPressed ? "{" : "[" ); break;
508  case Input::KEY_RIGHTBRACKET: return ( ShiftPressed ? "}" : "]" ); break;
509  case Input::KEY_BACKSLASH: return ( ShiftPressed ? "\\" : "|" ); break;
510  case Input::KEY_SEMICOLON: return ( ShiftPressed ? ":" : ";" ); break;
511  case Input::KEY_APOSTROPHE: return ( ShiftPressed ? "\"" : "'" ); break;
512  case Input::KEY_GRAVE: return ( ShiftPressed ? "~" : "`" ); break;
513  case Input::KEY_COMMA: return ( ShiftPressed ? "<" : "," ); break;
514  case Input::KEY_PERIOD: return ( ShiftPressed ? ">" : "." ); break;
515  case Input::KEY_SLASH: return ( ShiftPressed ? "?" : "/" ); break;
516  case Input::KEY_KP_1: return "1"; break;
517  case Input::KEY_KP_2: return "2"; break;
518  case Input::KEY_KP_3: return "3"; break;
519  case Input::KEY_KP_4: return "4"; break;
520  case Input::KEY_KP_5: return "5"; break;
521  case Input::KEY_KP_6: return "6"; break;
522  case Input::KEY_KP_7: return "7"; break;
523  case Input::KEY_KP_8: return "8"; break;
524  case Input::KEY_KP_9: return "9"; break;
525  case Input::KEY_KP_0: return "0"; break;
526  case Input::KEY_KP_PERIOD: return "."; break;
527  default: return ""; break;
528  }
529  }//StringTools::ConvertToString
530  }//StringTools
531 }//Mezzanine
532 
533 #endif
int32_t Int32
An 32-bit integer.
Definition: datatypes.h:124
InputCode
The InputCode enum defines all the posible types of inputs.
Boole StartsWith(const String &Str, const String &Pattern, const Boole CaseSensitive)
Checks a String to see if it starts with a specific pattern.
Definition: stringtool.cpp:227
Boole IsAlphaLetter(const Mezzanine::Char8 ToCheck)
Checks if a character is a lower or upper case letter.
Definition: stringtool.cpp:107
Boole IsUpperHexLetter(const Char8 ToCheck)
Checks if a character is a upper-case hexadecimal letter.
Definition: stringtool.cpp:113
Int16 ConvertToInt16(const String &ToConvert)
Converts a string into an Int16.
Definition: stringtool.cpp:432
std::vector< String > StringVector
This is a simple datatype for a vector container of strings.
Definition: datatypes.h:212
UInt32 ConvertToUInt32(const String &ToConvert)
Converts a string into a UInt32.
Definition: stringtool.cpp:456
bool Boole
Generally acts a single bit, true or false.
Definition: datatypes.h:173
ColourValue ConvertToColourValue(const String &ToConvert)
Convert four numbers in a string into a ColourValue.
Definition: stringtool.cpp:332
Real X
Coordinate on the X vector.
Definition: vector3.h:85
Real Z
Coordinate on the Z vector.
Definition: vector3.h:89
String ConvertToString(const Vector2 &ToConvert)
Converts a Vector2 into a string.
Definition: stringtool.cpp:291
Int32 ConvertToInt32(const String &ToConvert)
Converts an string into an Int32.
Definition: stringtool.cpp:448
String LowerCaseCopy(String Source)
Create a copy of the String that is lower case.
Definition: stringtool.cpp:198
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
Definition: exception.h:3048
int Integer
A datatype used to represent any integer close to.
Definition: datatypes.h:154
Real Y
The Y component of the Axis.
Definition: quaternion.h:77
Boole IsUpperAlphaLetter(const Mezzanine::Char8 ToCheck)
Checks if a character is a upper-case alphabetic letter.
Definition: stringtool.cpp:104
Vector3 ConvertToVector3(const String &ToConvert)
Convert three numbers in a string into a Vector3.
Definition: stringtool.cpp:298
Boole EndsWith(const String &Str, const String &Pattern, const Boole CaseSensitive)
Checks a String to see if it ends with a specific pattern.
Definition: stringtool.cpp:247
uint8_t UInt8
An 8-bit unsigned integer.
Definition: datatypes.h:118
void Trim(String &Source, Boole Left, Boole Right)
Trims all whitespaces and tabs from a one or both sides of a String.
Definition: stringtool.cpp:128
This is a simple class for holding 4 reals representing the colour any give object or lightsource can...
Definition: colourvalue.h:64
This implements the exception hiearchy for Mezzanine.
Boole IsLowerHexLetter(const Char8 ToCheck)
Checks if a character is a lower-case hexadecimal letter.
Definition: stringtool.cpp:110
std::stringstream StringStream
A Datatype used for streaming operations with strings.
Definition: datatypes.h:176
void ToLowerCase(String &Source)
Converts all upper case characters in a string to their respective lower case.
Definition: stringtool.cpp:193
UInt16 ConvertToUInt16(const String &ToConvert)
Converts a string into a UInt16.
Definition: stringtool.cpp:440
float Real
A Datatype used to represent a real floating point number.
Definition: datatypes.h:141
char Char8
A datatype to represent one character.
Definition: datatypes.h:169
uint16_t UInt16
An 16-bit unsigned integer.
Definition: datatypes.h:122
Integer ConvertToInteger(const String &ToConvert)
Converts a string into an Integer.
Definition: stringtool.cpp:400
Real GreenChannel
Value from 0.0 to 1.0 representing the amount of green present in the colour. 1.0 if very green...
Definition: colourvalue.h:73
Boole ConvertToBool(const String &ToConvert, const Boole Default)
Converts a string into a Boole.
Definition: stringtool.cpp:379
Real Y
Coordinate on the Y vector.
Definition: vector2.h:69
String CamelCaseCopy(String Source)
Create a copy of the String that has the first letter of each word upper case and other letters lower...
Definition: stringtool.cpp:221
Real X
Coordinate on the X vector.
Definition: vector2.h:67
Real W
Rotation on the Axis X, Y and Z defined.
Definition: quaternion.h:81
uint32_t UInt32
An 32-bit unsigned integer.
Definition: datatypes.h:126
This is used to represent a point on a 2 dimentional area, such as a screen.
Definition: vector2.h:63
Real AlphaChannel
Value from 0.0 to 1.0 representing the transparency of the colours. 1.0 is opaque and 0...
Definition: colourvalue.h:79
StringVector Split(const String &Source, const String &Delims, const Whole MaxSplits)
Splits a string into multiple substrings based on the specified delimiters.
Definition: stringtool.cpp:155
Real Y
Coordinate on the Y vector.
Definition: vector3.h:87
Boole IsLowerAlphaLetter(const Mezzanine::Char8 ToCheck)
Checks if a character is a lower-case alphabetic letter.
Definition: stringtool.cpp:101
String UpperCaseCopy(String Source)
Create a copy of the String that is upper case.
Definition: stringtool.cpp:187
String ConvertToHexString(const ColourValue &ToConvert)
Converts a ColourValue into a string as a Hex code.
Definition: stringtool.cpp:366
int16_t Int16
An 16-bit integer.
Definition: datatypes.h:120
Thrown when parameters are checked at runtime and found invalid.
Definition: exception.h:108
ColourValue ConvertHexToColourValue(const String &ToConvert)
Converts a Hex code in a string into a ColourValue.
Definition: stringtool.cpp:349
Whole ConvertToWhole(const String &ToConvert)
Converts a string into an Whole.
Definition: stringtool.cpp:408
void ToCamelCase(String &Source)
Converts the first letter of each word to upper case and all other letters to lower case...
Definition: stringtool.cpp:204
This is used to represent a point in space, or a vector through space.
Definition: vector3.h:77
UInt8 ConvertToUInt8(const String &ToConvert)
Converts a string into a UInt8.
Definition: stringtool.cpp:424
Boole IsDigit(const Mezzanine::Char8 ToCheck)
Checks if a character is a decimal digit.
Definition: stringtool.cpp:98
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
Definition: datatypes.h:151
Int8 ConvertToInt8(const String &ToConvert)
Converts a string into an Int8.
Definition: stringtool.cpp:416
Real BlueChannel
Value from 0.0 to 1.0 representing the amount of blue present in the colour. 1.0 if very blue...
Definition: colourvalue.h:76
Boole IsHexLetter(const Char8 ToCheck)
Checks if a character is a hexadecimal letter.
Definition: stringtool.cpp:116
void ToUpperCase(String &Source)
Converts all lower case characters in a string to their respective upper case.
Definition: stringtool.cpp:182
Quaternion ConvertToQuaternion(const String &ToConvert)
Convert four numbers in a string into a Quaternion.
Definition: stringtool.cpp:315
Real RedChannel
Value from 0.0 to 1.0 representing the amount of red present in the colour. 1.0 if very red...
Definition: colourvalue.h:70
Real X
The X component of the Axis.
Definition: quaternion.h:75
Boole IsAlphanumeric(const Char8 ToCheck)
Checks if a character is a letter or digit.
Definition: stringtool.cpp:122
This is used to store information about rotation in 3d space.
Definition: quaternion.h:68
void RemoveDuplicateWhitespaces(String &Source)
Replaces all instances of multiple consecutive whitespaces with only a single whitespace.
Definition: stringtool.cpp:267
int8_t Int8
An 8-bit integer.
Definition: datatypes.h:116
Vector2 ConvertToVector2(const String &ToConvert)
Convert two numbers in a string into a Vector2.
Definition: stringtool.cpp:281
Real Z
The Z component of the Axis.
Definition: quaternion.h:79
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159
Real ConvertToReal(const String &ToConvert)
Converts a string into a Real.
Definition: stringtool.cpp:392
Boole IsHexDigit(const Mezzanine::Char8 ToCheck)
Checks if a character is a hexadecimal digit.
Definition: stringtool.cpp:119