Mercurial > foo_out_sdl
comparison foosdk/sdk/pfc/charDownConvert.h @ 1:20d02a178406 default tip
*: check in everything else
yay
| author | Paper <paper@tflc.us> |
|---|---|
| date | Mon, 05 Jan 2026 02:15:46 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 0:e9bb126753e7 | 1:20d02a178406 |
|---|---|
| 1 #pragma once | |
| 2 #include "string_base.h" | |
| 3 #include "fixed_map.h" | |
| 4 | |
| 5 // This converts to ASCII *and* lowercases for simplified search matching | |
| 6 namespace pfc { | |
| 7 class CharStorage { | |
| 8 public: | |
| 9 CharStorage() { } | |
| 10 template<typename TSource> CharStorage(const TSource& in) { Import(in); } | |
| 11 template<typename TSource> const CharStorage& operator=(const TSource& in) { Import(in); return *this; } | |
| 12 | |
| 13 const char* ptr() const { return m_data; } | |
| 14 | |
| 15 void Import(t_uint32 c) { | |
| 16 t_size l = pfc::utf8_encode_char(c, m_data); | |
| 17 m_data[l] = 0; | |
| 18 } | |
| 19 void Import(const char* c) { | |
| 20 PFC_ASSERT(strlen(c) < PFC_TABSIZE(m_data)); | |
| 21 #ifdef _MSC_VER | |
| 22 strcpy_s(m_data, c); | |
| 23 #else | |
| 24 strcpy(m_data, c); | |
| 25 #endif | |
| 26 } | |
| 27 | |
| 28 char m_data[16] = {}; | |
| 29 }; | |
| 30 | |
| 31 class CharDownConvert { | |
| 32 public: | |
| 33 CharDownConvert(); | |
| 34 | |
| 35 void TransformCharCachedAppend(t_uint32 c, pfc::string_base& out); | |
| 36 void TransformStringAppend(pfc::string_base& out, const char* src, size_t len = SIZE_MAX); | |
| 37 void TransformStringHere(pfc::string_base& out, const char* src, size_t len = SIZE_MAX); | |
| 38 string8 TransformString(const char* src) { pfc::string8 ret; TransformStringAppend(ret, src); return ret; } | |
| 39 void TransformString(pfc::string_base& out, const char* src) { | |
| 40 out.reset(); TransformStringAppend(out, src); | |
| 41 } | |
| 42 | |
| 43 static CharDownConvert& instance(); | |
| 44 | |
| 45 struct charMapping_t { | |
| 46 uint16_t from, to; | |
| 47 }; | |
| 48 static const charMapping_t* mappings(); | |
| 49 static size_t numMappings(); | |
| 50 | |
| 51 private: | |
| 52 fixed_map<uint32_t, CharStorage> m_charConvertMap; | |
| 53 }; | |
| 54 } |
