| 1 | #ifndef SEAD_STRING_UTIL_H_ |
| 2 | #define SEAD_STRING_UTIL_H_ |
| 3 | |
| 4 | #include <stdarg.h> |
| 5 | #include <stdio.h> |
| 6 | |
| 7 | #include <basis/seadTypes.h> |
| 8 | #include <container/seadBuffer.h> |
| 9 | #include <prim/seadSafeString.h> |
| 10 | |
| 11 | namespace sead |
| 12 | { |
| 13 | namespace StringUtil |
| 14 | { |
| 15 | struct Char16Pair |
| 16 | { |
| 17 | char16 before; |
| 18 | char16 after; |
| 19 | }; |
| 20 | |
| 21 | enum class CardinalNumber |
| 22 | { |
| 23 | BaseAuto = -1, |
| 24 | Base2 = 2, |
| 25 | Base8 = 8, |
| 26 | Base10 = 10, |
| 27 | Base16 = 16, |
| 28 | }; |
| 29 | |
| 30 | bool tryParseU64(u64* out, const SafeString& str, CardinalNumber base); |
| 31 | bool tryParseS64(s64* out, const SafeString& str, CardinalNumber base); |
| 32 | bool tryParseU32(u32* out, const SafeString& str, CardinalNumber base); |
| 33 | bool tryParseS32(s32* out, const SafeString& str, CardinalNumber base); |
| 34 | bool tryParseU16(u16* out, const SafeString& str, CardinalNumber base); |
| 35 | bool tryParseS16(s16* out, const SafeString& str, CardinalNumber base); |
| 36 | bool tryParseU8(u8* out, const SafeString& str, CardinalNumber base); |
| 37 | bool tryParseS8(s8* out, const SafeString& str, CardinalNumber base); |
| 38 | bool tryParseF32(f32* out, const SafeString& str); |
| 39 | bool tryParseF64(f64* out, const SafeString& str); |
| 40 | |
| 41 | u64 parseU64(const SafeString& str, CardinalNumber base); |
| 42 | s64 parseS64(const SafeString& str, CardinalNumber base); |
| 43 | u32 parseU32(const SafeString& str, CardinalNumber base); |
| 44 | s32 parseS32(const SafeString& str, CardinalNumber base); |
| 45 | u16 parseU16(const SafeString& str, CardinalNumber base); |
| 46 | s16 parseS16(const SafeString& str, CardinalNumber base); |
| 47 | u8 parseU8(const SafeString& str, CardinalNumber base); |
| 48 | s8 parseS8(const SafeString& str, CardinalNumber base); |
| 49 | f32 parseF32(const SafeString& str); |
| 50 | f64 parseF64(const SafeString& str); |
| 51 | |
| 52 | char16* wcs16cpy(char16*, size_t n, const char16*); |
| 53 | |
| 54 | s32 snprintf(char* s, size_t n, const char* format, ...); |
| 55 | s32 sw16printf(char16* s, size_t n, const char16* format, ...); |
| 56 | s32 vsnprintf(char* s, size_t n, const char* format, va_list args); |
| 57 | s32 vsw16printf(char16* s, size_t n, const char16* format, std::va_list args); |
| 58 | // TODO |
| 59 | s32 vsnw16printf(char16* s, size_t n, const char16* format, std::va_list args); |
| 60 | |
| 61 | s32 convertSjisToUtf16(char16* dst, u32 dst_len, const char* src, s32 src_len); |
| 62 | s32 convertUtf16ToSjis(char* dst, u32 dst_len, const char16* src, s32 src_len); |
| 63 | s32 convertUtf8ToUtf16(char16* dst, u32 dst_len, const char* src, s32 src_len); |
| 64 | s32 convertUtf16ToUtf8(char* dst, u32 dst_len, const char16* src, s32 src_len); |
| 65 | s32 convertSjisToUtf8(char* dst, u32 dst_len, const char* src, s32 src_len); |
| 66 | s32 convertUtf8ToSjis(char* dst, u32 dst_len, const char* src, s32 src_len); |
| 67 | |
| 68 | char16 replace(char16 c, const Buffer<const Char16Pair>& sorted_table); |
| 69 | |
| 70 | char16 toUpperCapital(char16 c); |
| 71 | void toUpperCapitalFirstCharactor(WBufferedSafeString* str); |
| 72 | |
| 73 | char16 toLowerCapital(char16 c); |
| 74 | void toLowerCapitalFirstCharactor(WBufferedSafeString* str); |
| 75 | |
| 76 | } // namespace StringUtil |
| 77 | } // namespace sead |
| 78 | |
| 79 | #endif // SEAD_STRING_UTIL_H_ |
| 80 | |