xref: /aosp_15_r20/external/lzma/CPP/Common/IntToString.h (revision f6dc9357d832569d4d1f5d24eacdb3935a1ae8e6)
1 // Common/IntToString.h
2 
3 #ifndef ZIP7_INC_COMMON_INT_TO_STRING_H
4 #define ZIP7_INC_COMMON_INT_TO_STRING_H
5 
6 #include "MyTypes.h"
7 
8 // return: the pointer to the "terminating" null character after written characters
9 
10 char * ConvertUInt32ToString(UInt32 value, char *s) throw();
11 char * ConvertUInt64ToString(UInt64 value, char *s) throw();
12 
13 wchar_t * ConvertUInt32ToString(UInt32 value, wchar_t *s) throw();
14 wchar_t * ConvertUInt64ToString(UInt64 value, wchar_t *s) throw();
15 void ConvertInt64ToString(Int64 value, char *s) throw();
16 void ConvertInt64ToString(Int64 value, wchar_t *s) throw();
17 
18 void ConvertUInt64ToOct(UInt64 value, char *s) throw();
19 
20 extern const char k_Hex_Upper[16];
21 extern const char k_Hex_Lower[16];
22 
23 #define GET_HEX_CHAR_UPPER(t)  (k_Hex_Upper[t])
24 #define GET_HEX_CHAR_LOWER(t)  (k_Hex_Lower[t])
25 /*
26 // #define GET_HEX_CHAR_UPPER(t) ((char)(((t < 10) ? ('0' + t) : ('A' + (t - 10)))))
27 static inline unsigned GetHex_Lower(unsigned v)
28 {
29   const unsigned v0 = v + '0';
30   v += 'a' - 10;
31   if (v < 'a')
32     v = v0;
33   return v;
34 }
35 static inline char GetHex_Upper(unsigned v)
36 {
37   return (char)((v < 10) ? ('0' + v) : ('A' + (v - 10)));
38 }
39 */
40 
41 
42 void ConvertUInt32ToHex(UInt32 value, char *s) throw();
43 void ConvertUInt64ToHex(UInt64 value, char *s) throw();
44 void ConvertUInt32ToHex8Digits(UInt32 value, char *s) throw();
45 // void ConvertUInt32ToHex8Digits(UInt32 value, wchar_t *s) throw();
46 
47 // use RawLeGuid only for RAW bytes that contain stored GUID as Little-endian.
48 char *RawLeGuidToString(const Byte *guid, char *s) throw();
49 char *RawLeGuidToString_Braced(const Byte *guid, char *s) throw();
50 
51 void ConvertDataToHex_Lower(char *dest, const Byte *src, size_t size) throw();
52 void ConvertDataToHex_Upper(char *dest, const Byte *src, size_t size) throw();
53 
54 #endif
55