-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathToString.h
More file actions
57 lines (56 loc) · 2.92 KB
/
ToString.h
File metadata and controls
57 lines (56 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* ToString.h - Conversions to Strings
*
* Author : Alexander J. Yee
* Date Created : 07/07/2013
* Last Modified : 08/24/2014
*
*/
#pragma once
#ifndef ymp_ToString_H
#define ymp_ToString_H
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Dependencies
#include <string>
#include "PublicLibs/CompilerSettings.h"
#include "PublicLibs/Types.h"
namespace ymp{
namespace StringTools{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
enum NumberFormat{
NORMAL = 0,
COMMAS = 1,
BYTES = 2,
BYTES_EXPANDED = 3
};
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Integer
YM_NO_INLINE std::string tostr (uiL_t x, NumberFormat format = NORMAL);
YM_NO_INLINE std::string tostr (siL_t x, NumberFormat format = NORMAL);
static std::string tostr (u32_t x, NumberFormat format = NORMAL){ return tostr((uiL_t)x, format); }
static std::string tostr (s32_t x, NumberFormat format = NORMAL){ return tostr((siL_t)x, format); }
YM_NO_INLINE std::string tostrln (uiL_t x, NumberFormat format = NORMAL);
YM_NO_INLINE std::string tostrln (siL_t x, NumberFormat format = NORMAL);
static std::string tostrln (u32_t x, NumberFormat format = NORMAL){ return tostrln((uiL_t)x, format); }
static std::string tostrln (s32_t x, NumberFormat format = NORMAL){ return tostrln((siL_t)x, format); }
YM_NO_INLINE std::string tostr_width (uiL_t x, int width);
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Float
YM_NO_INLINE std::string tostr_float (double x, int precision = 0);
YM_NO_INLINE std::string tostrln_float (double x, int precision = 0);
YM_NO_INLINE std::string tostr_fixed (double x, int precision = 3);
YM_NO_INLINE std::string tostrln_fixed (double x, int precision = 3);
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
}
}
#endif