OpenBarnyard
Loading...
Searching...
No Matches
Platform_Win.cpp
Go to the documentation of this file.
1
#include "ToshiPCH.h"
2
#include "
Toshi/Platform.h
"
3
#include "
Toshi/TString8.h
"
4
#include "
Toshi/TString16.h
"
5
#include "
Toshi/T2String.h
"
6
#include "
ToshiTools/T2DynamicVector.h
"
7
8
#include <Windows.h>
9
10
//-----------------------------------------------------------------------------
11
// Enables memory debugging.
12
// Note: Should be the last include!
13
//-----------------------------------------------------------------------------
14
#include "
Core/TMemoryDebugOn.h
"
15
16
TOSHI_NAMESPACE_START
17
18
// $Barnyard: FUNCTION 006bb8a0
19
void
ThreadSleep
(
TUINT
dwMilliseconds )
20
{
21
Sleep( dwMilliseconds );
22
}
23
24
void
FixPathSlashes
(
TString8
& a_rPath )
25
{
26
for
(
TINT
i = 0; i < a_rPath.
Length
(); i++ )
27
{
28
if
( a_rPath[ i ] ==
'/'
)
29
a_rPath[ i ] =
'\\'
;
30
}
31
}
32
33
void
FixPathSlashesBack
(
TString8
& a_rPath )
34
{
35
for
(
TINT
i = 0; i < a_rPath.
Length
(); i++ )
36
{
37
if
( a_rPath[ i ] ==
'\\'
)
38
a_rPath[ i ] =
'/'
;
39
}
40
}
41
42
TString8
Platform_UnicodeToUTF8
(
const
TWCHAR
* a_wszUnicodeString )
43
{
44
TINT
iStrLen;
45
if
( a_wszUnicodeString && ( iStrLen =
T2String16::Length
( a_wszUnicodeString ) ) )
46
{
47
TINT
sizeRequired = WideCharToMultiByte( CP_UTF8, 0, a_wszUnicodeString, -1, NULL, 0, NULL, NULL );
48
49
if
( sizeRequired > 0 )
50
{
51
T2DynamicVector<TCHAR>
utf8String;
52
utf8String.
SetSize
( sizeRequired );
53
54
TINT
bytesConverted = WideCharToMultiByte( CP_UTF8, 0, a_wszUnicodeString, -1, &utf8String[ 0 ], sizeRequired, NULL, NULL );
55
56
if
( bytesConverted != 0 )
57
return
&utf8String[ 0 ];
58
}
59
}
60
61
return
""
;
62
}
63
64
TString16
Platform_UTF8ToUnicode
(
const
TCHAR
* a_pchUTF8String )
65
{
66
if
( a_pchUTF8String && (
T2String8::Length
( a_pchUTF8String ) ) )
67
{
68
TINT
sizeRequired = MultiByteToWideChar( CP_UTF8, 0, a_pchUTF8String, -1, NULL, 0 );
69
70
if
( sizeRequired > 0 )
71
{
72
T2DynamicVector<TWCHAR>
utf16String;
73
utf16String.
SetSize
( sizeRequired );
74
75
TINT
bytesConverted = MultiByteToWideChar( CP_UTF8, 0, a_pchUTF8String, -1, &utf16String[ 0 ], sizeRequired );
76
77
if
( bytesConverted != 0 )
78
return
&utf16String[ 0 ];
79
}
80
}
81
82
return
L
""
;
83
}
84
85
TOSHI_NAMESPACE_END
TMemoryDebugOn.h
TOSHI_NAMESPACE_START
#define TOSHI_NAMESPACE_START
Definition
Defines.h:47
TOSHI_NAMESPACE_END
#define TOSHI_NAMESPACE_END
Definition
Defines.h:50
Platform.h
Platform_UTF8ToUnicode
TString16 Platform_UTF8ToUnicode(const TCHAR *a_pchUTF8String)
ThreadSleep
void ThreadSleep(TUINT dwMilliseconds)
Platform_UnicodeToUTF8
TString8 Platform_UnicodeToUTF8(const TWCHAR *a_wszUnicodeString)
FixPathSlashes
void FixPathSlashes(TString8 &a_rPath)
FixPathSlashesBack
void FixPathSlashesBack(TString8 &a_rPath)
T2String.h
TString16.h
TString8.h
Char string implementation for the Toshi engine.
TWCHAR
wchar_t TWCHAR
Definition
Typedefs.h:21
TUINT
unsigned int TUINT
Definition
Typedefs.h:8
TCHAR
char TCHAR
Definition
Typedefs.h:20
TINT
int TINT
Definition
Typedefs.h:7
T2DynamicVector.h
Dynamic vector container for the Toshi engine.
T2String16::Length
static TSIZE Length(const TWCHAR *str)
Definition
T2String16.cpp:129
T2String8::Length
static TSIZE Length(const TCHAR *str)
Definition
T2String8.cpp:127
TString16
Definition
TString16.h:8
TString8
Definition
TString8.h:21
TString8::Length
TINT Length() const
Definition
TString8.h:93
T2DynamicVector
Definition
T2DynamicVector.h:51
T2DynamicVector::SetSize
void SetSize(TINT a_iNewSize)
Definition
T2DynamicVector.h:399
D:
_dev
OpenBarnyard
Source
Toshi
Source
Platform
Windows
Platform_Win.cpp
Generated by
1.13.2