@@ -32,6 +32,7 @@ SOFTWARE.
3232#include < cfloat>
3333#include < cstring> // stricmp / strcasecmp
3434#include < cstdarg> // variadic
35+ #include < sstream>
3536#include < iomanip>
3637#include < ctime>
3738#include < sys/stat.h>
@@ -386,19 +387,22 @@ namespace IGFD
386387 bool IGFD::Utils::WReplaceString (std::wstring& str, const std::wstring& oldStr, const std::wstring& newStr)
387388 {
388389 bool found = false ;
390+ #ifdef _IGFD_WIN_
389391 size_t pos = 0 ;
390392 while ((pos = str.find (oldStr, pos)) != std::wstring::npos)
391393 {
392394 found = true ;
393395 str.replace (pos, oldStr.length (), newStr);
394396 pos += newStr.length ();
395397 }
398+ #endif // _IGFD_WIN_
396399 return found;
397400 }
398401
399402 std::vector<std::wstring> IGFD::Utils::WSplitStringToVector (const std::wstring& text, char delimiter, bool pushEmpty)
400403 {
401404 std::vector<std::wstring> arr;
405+ #ifdef _IGFD_WIN_
402406 if (!text.empty ())
403407 {
404408 std::wstring::size_type start = 0 ;
@@ -415,54 +419,59 @@ namespace IGFD
415419 if (!token.empty () || (token.empty () && pushEmpty)) // -V728
416420 arr.push_back (token);
417421 }
422+ #endif // _IGFD_WIN_
418423 return arr;
419424 }
420425
421426 std::wstring IGFD::Utils::string_to_wstring (const std::string& str)
422427 {
423428 std::wstring ret;
429+ #ifdef _IGFD_WIN_
424430 if (!str.empty ())
425431 {
426432 size_t sz = 0U ;
427- #ifndef _MSC_VER
428- sz = std::mbstowcs (nullptr , str.c_str (), str.size ());
429- #else // _MSC_VER
433+ #ifdef _MSC_VER
430434 mbstowcs_s (&sz, nullptr , 0 , str.c_str (), str.size ());
435+ #else // _MSC_VER
436+ sz = std::mbstowcs (nullptr , str.c_str (), str.size ());
431437#endif // _MSC_VER
432438 if (sz)
433439 {
434440 ret.resize (sz);
435- #ifndef _MSC_VER
436- std::mbstowcs (ret.data (), str.c_str (), sz);
437- #else // _MSC_VER
441+ #ifdef _MSC_VER
438442 mbstowcs_s (nullptr , ret.data (), sz, str.c_str (), sz);
443+ #else // _MSC_VER
444+ std::mbstowcs ((wchar_t *)ret.data (), str.c_str (), sz);
439445#endif // _MSC_VER
440446 }
441447 }
448+ #endif // _IGFD_WIN_
442449 return ret;
443450 }
444451
445452 std::string IGFD::Utils::wstring_to_string (const std::wstring& str)
446453 {
447454 std::string ret;
455+ #ifdef _IGFD_WIN_
448456 if (!str.empty ())
449457 {
450458 size_t sz = 0U ;
451- #ifndef _MSC_VER
452- sz = std::wcstombs (nullptr , str.c_str (), str.size ());
453- #else // _MSC_VER
459+ #ifdef _MSC_VER
454460 wcstombs_s (&sz, nullptr , 0 , str.c_str (), str.size ());
461+ #else // _MSC_VER
462+ sz = std::wcstombs (nullptr , str.c_str (), str.size ());
455463#endif // _MSC_VER
456464 if (sz)
457465 {
458466 ret.resize (sz);
459- #ifndef _MSC_VER
460- std::wcstombs (ret.data (), str.c_str (), sz);
461- #else // _MSC_VER
467+ #ifdef _MSC_VER
462468 wcstombs_s (nullptr , ret.data (), sz, str.c_str (), sz);
469+ #else // _MSC_VER
470+ std::wcstombs ((char *)ret.data (), str.c_str (), sz);
463471#endif // _MSC_VER
464472 }
465473 }
474+ #endif // _IGFD_WIN_
466475 return ret;
467476 }
468477
0 commit comments