CUGL
Cornell University Game Library
CUStrings.h
1 //
2 // CUStrings.h
3 // Cornell University Game Library (CUGL)
4 //
5 // Android does not support a lot of the built-in string methods. Therefore,
6 // we need alternate definitions that are platform agnostic. Note that these
7 // functions have names that are very similar to those in the std namespace,
8 // but all live in the cocos2d namespace.
9 //
10 // Note that this module does not refer to the integral types as short, int,
11 // long, etc. Those types are NOT cross-platform. For example, a long is
12 // 8 bytes on Unix/OS X, but 4 bytes on some Win32 platforms.
13 //
14 // CUGL zlib License:
15 // This software is provided 'as-is', without any express or implied
16 // warranty. In no event will the authors be held liable for any damages
17 // arising from the use of this software.
18 //
19 // Permission is granted to anyone to use this software for any purpose,
20 // including commercial applications, and to alter it and redistribute it
21 // freely, subject to the following restrictions:
22 //
23 // 1. The origin of this software must not be misrepresented; you must not
24 // claim that you wrote the original software. If you use this software
25 // in a product, an acknowledgment in the product documentation would be
26 // appreciated but is not required.
27 //
28 // 2. Altered source versions must be plainly marked as such, and must not
29 // be misrepresented as being the original software.
30 //
31 // 3. This notice may not be removed or altered from any source distribution.
32 //
33 // Author: Walker White
34 // Version: 2/10/16
35 //
36 #ifndef CU_STRINGS_H
37 #define CU_STRINGS_H
38 #include <SDL/SDL.h>
39 #include <string>
40 
41 namespace cugl {
42 
43 #pragma mark NUMBER TO STRING FUNCTIONS
44 
53  std::string to_string(Uint8 value);
54 
62  std::string to_string(Sint16 value);
63 
71  std::string to_string(Uint16 value);
72 
80  std::string to_string(Sint32 value);
81 
89  std::string to_string(Uint32 value );
90 
98  std::string to_string(Sint64 value );
99 
107  std::string to_string(Uint64 value );
108 
118  std::string to_string(float value);
119 
129  std::string to_string(double value);
130 
131 
132 #pragma mark -
133 #pragma mark ARRAY TO STRING FUNCTIONS
134 
145  std::string to_string(Uint8* array, size_t length, size_t offset=0);
146 
158  std::string to_string(Sint16* array, size_t length, size_t offset=0);
159 
171  std::string to_string(Uint16* array, size_t length, size_t offset=0);
172 
184  std::string to_string(Sint32* array, size_t length, size_t offset=0);
185 
197  std::string to_string(Uint32* array, size_t length, size_t offset=0);
198 
210  std::string to_string(Sint64* array, size_t length, size_t offset=0);
211 
223  std::string to_string(Uint64* array, size_t length, size_t offset=0);
224 
236  std::string to_string(float* array, size_t length, size_t offset=0);
237 
249  std::string to_string(double* array, size_t length, size_t offset=0);
250 
251 
252 #pragma mark -
253 #pragma mark STRING TO NUMBER FUNCTIONS
254 
268  Uint8 stou8(const std::string& str, std::size_t* pos = 0, int base = 10);
269 
284  Sint16 stos16(const std::string& str, std::size_t* pos = 0, int base = 10);
285 
300  Uint16 stou16(const std::string& str, std::size_t* pos = 0, int base = 10);
301 
316  Sint32 stos32(const std::string& str, std::size_t* pos = 0, int base = 10);
317 
332  Uint32 stou32(const std::string& str, std::size_t* pos = 0, int base = 10);
333 
348  Sint64 stos64(const std::string& str, std::size_t* pos = 0, int base = 10);
349 
364  Uint64 stou64(const std::string& str, std::size_t* pos = 0, int base = 10);
365 
379  float stof(const std::string& str, std::size_t* pos = 0);
380 
394  double stod(const std::string& str, std::size_t* pos = 0);
395 
396 }
397 
398 #endif /* CU_STRINGS_H */
Uint64 stou64(const std::string &str, std::size_t *pos=0, int base=10)
Uint32 stou32(const std::string &str, std::size_t *pos=0, int base=10)
Sint64 stos64(const std::string &str, std::size_t *pos=0, int base=10)
float stof(const std::string &str, std::size_t *pos=0)
double stod(const std::string &str, std::size_t *pos=0)
Sint16 stos16(const std::string &str, std::size_t *pos=0, int base=10)
Uint16 stou16(const std::string &str, std::size_t *pos=0, int base=10)
std::string to_string(Uint8 value)
Sint32 stos32(const std::string &str, std::size_t *pos=0, int base=10)
Uint8 stou8(const std::string &str, std::size_t *pos=0, int base=10)
Definition: CUAnimationNode.h:52