ca493615a78fa1736135f7380e67e87c338a451e
[jabaws.git] / binaries / src / muscle / typetostr.cpp
1 #include "muscle.h"\r
2 #include <stdio.h>\r
3 \r
4 const char *SecsToStr(unsigned long Secs)\r
5         {\r
6         static char Str[16];\r
7         long hh, mm, ss;\r
8 \r
9         hh = Secs/(60*60);\r
10         mm = (Secs/60)%60;\r
11         ss = Secs%60;\r
12 \r
13         sprintf(Str, "%02d:%02d:%02d", hh, mm, ss);\r
14         return Str;\r
15         }\r
16 \r
17 const char *BoolToStr(bool b)\r
18         {\r
19         return b ? "True" : "False";\r
20         }\r
21 \r
22 const char *ScoreToStr(SCORE Score)\r
23         {\r
24         if (MINUS_INFINITY >= Score)\r
25                 return "       *";\r
26 // Hack to use "circular" buffer so when called multiple\r
27 // times in a printf-like argument list it works OK.\r
28         const int iBufferCount = 16;\r
29         const int iBufferLength = 16;\r
30         static char szStr[iBufferCount*iBufferLength];\r
31         static int iBufferIndex = 0;\r
32         iBufferIndex = (iBufferIndex + 1)%iBufferCount;\r
33         char *pStr = szStr + iBufferIndex*iBufferLength;\r
34         sprintf(pStr, "%8g", Score);\r
35         return pStr;\r
36         }\r
37 \r
38 // Left-justified version of ScoreToStr\r
39 const char *ScoreToStrL(SCORE Score)\r
40         {\r
41         if (MINUS_INFINITY >= Score)\r
42                 return "*";\r
43 // Hack to use "circular" buffer so when called multiple\r
44 // times in a printf-like argument list it works OK.\r
45         const int iBufferCount = 16;\r
46         const int iBufferLength = 16;\r
47         static char szStr[iBufferCount*iBufferLength];\r
48         static int iBufferIndex = 0;\r
49         iBufferIndex = (iBufferIndex + 1)%iBufferCount;\r
50         char *pStr = szStr + iBufferIndex*iBufferLength;\r
51         sprintf(pStr, "%.3g", Score);\r
52         return pStr;\r
53         }\r
54 \r
55 const char *WeightToStr(WEIGHT w)\r
56         {\r
57         return ScoreToStr(w);\r
58         }\r