#include <stdlib.h>
#include <time.h>
#include "String.h"
#if defined VCZH_MSVC
#include <Windows.h>
#elif defined VCZH_GCC
#include <stdio.h>
#include <ctype.h>
#include <wctype.h>
#define _strtoi64 strtoll
#define _strtoui64 strtoull
#define _wcstoi64 wcstoll
#define _wcstoui64 wcstoull
#endif
namespace
{
#if defined VCZH_GCC
void _itoa_s(vint32_t value, char* buffer, size_t size, vint radix)
{
sprintf(buffer, "%d", value);
}
void _itow_s(vint32_t value, wchar_t* buffer, size_t size, vint radix)
{
swprintf(buffer, size - 1, L"%d", value);
}
void _i64toa_s(vint64_t value, char* buffer, size_t size, vint radix)
{
sprintf(buffer, "%ld", value);
}
void _i64tow_s(vint64_t value, wchar_t* buffer, size_t size, vint radix)
{
swprintf(buffer, size - 1, L"%ld", value);
}
void _uitoa_s(vuint32_t value, char* buffer, size_t size, vint radix)
{
sprintf(buffer, "%u", value);
}
void _uitow_s(vuint32_t value, wchar_t* buffer, size_t size, vint radix)
{
swprintf(buffer, size - 1, L"%u", value);
}
void _ui64toa_s(vuint64_t value, char* buffer, size_t size, vint radix)
{
sprintf(buffer, "%lu", value);
}
void _ui64tow_s(vuint64_t value, wchar_t* buffer, size_t size, vint radix)
{
swprintf(buffer, size - 1, L"%lu", value);
}
void _gcvt_s(char* buffer, size_t size, double value, vint numberOfDigits)
{
sprintf(buffer, "%f", value);
char* point = strchr(buffer, '.');
if(!point) return;
char* zero = buffer + strlen(buffer);
while(zero[-1] == '0')
{
*--zero = '\0';
}
if(zero[-1] == '.') *--zero = '\0';
}
void _strlwr_s(char* buffer, size_t size)
{
while(*buffer)
{
*buffer=(char)tolower(*buffer);
buffer++;
}
}
void _strupr_s(char* buffer, size_t size)
{
while(*buffer)
{
*buffer=(char)toupper(*buffer);
buffer++;
}
}
void _wcslwr_s(wchar_t* buffer, size_t size)
{
while(*buffer)
{
*buffer=(char)towlower(*buffer);
buffer++;
}
}
void _wcsupr_s(wchar_t* buffer, size_t size)
{
while(*buffer)
{
*buffer=(char)towupper(*buffer);
buffer++;
}
}
void wcscpy_s(wchar_t* buffer, size_t size, const wchar_t* text)
{
wcscpy(buffer, text);
}
#endif
(
const
&
,
bool
&
)
{
char
*
=
0
;
=
(
.
(), &
endptr
,
10
);
=
endptr
==
.
() +
.
() &&
(
result
) ==
;
return
result
;
}
(
const
&
,
bool
&
)
{
wchar_t
*
=
0
;
=
(
.
(), &
endptr
,
10
);
=
endptr
==
.
() +
.
() &&
(
result
) ==
;
return
result
;
}
(
const
&
,
bool
&
)
{
char
*
=
0
;
=
(
.
(), &
endptr
,
10
);
=
endptr
==
.
() +
.
() &&
(
result
) ==
;
return
result
;
}
(
const
&
,
bool
&
)
{
wchar_t
*
=
0
;
=
(
.
(), &
endptr
,
10
);
=
endptr
==
.
() +
.
() &&
(
result
) ==
;
return
result
;
}
(
const
&
,
bool
&
)
{
char
*
=
0
;
=
(
.
(), &
endptr
,
10
);
=
endptr
==
.
() +
.
() &&
(
result
) ==
;
return
result
;
}
(
const
&
,
bool
&
)
{
wchar_t
*
=
0
;
=
(
.
(), &
endptr
,
10
);
=
endptr
==
.
() +
.
() &&
(
result
) ==
;
return
result
;
}
(
const
&
,
bool
&
)
{
char
*
=
0
;
=
(
.
(), &
endptr
,
10
);
=
endptr
==
.
() +
.
() &&
(
result
) ==
;
return
result
;
}
(
const
&
,
bool
&
)
{
wchar_t
*
=
0
;
=
(
.
(), &
endptr
,
10
);
=
endptr
==
.
() +
.
() &&
(
result
) ==
;
return
result
;
}
double
(
const
&
,
bool
&
)
{
char
*
=
0
;
double
=
(
.
(), &
endptr
);
=
endptr
==
.
() +
.
();
return
result
;
}
double
(
const
&
,
bool
&
)
{
wchar_t
*
=
0
;
double
=
(
.
(), &
endptr
);
=
endptr
==
.
() +
.
();
return
result
;
}
(
const
&
)
{
bool
=
false
;
return
(
,
success
);
}
(
const
&
)
{
bool
=
false
;
return
(
,
success
);
}
(
const
&
)
{
bool
=
false
;
return
(
,
success
);
}
(
const
&
)
{
bool
=
false
;
return
(
,
success
);
}
(
const
&
)
{
bool
=
false
;
return
(
,
success
);
}
(
const
&
)
{
bool
=
false
;
return
(
,
success
);
}
(
const
&
)
{
bool
=
false
;
return
(
,
success
);
}
(
const
&
)
{
bool
=
false
;
return
(
,
success
);
}
double
(
const
&
)
{
bool
=
false
;
return
(
,
success
);
}
double
(
const
&
)
{
bool
=
false
;
return
(
,
success
);
}
(
)
{
char
[
100
];
ITOA_S(number, buffer, sizeof(buffer) / sizeof(*buffer), 10);
(
,
buffer
,
sizeof
(
buffer
) /
sizeof
(*
buffer
),
10
);
return
buffer
;
}
(
)
{
wchar_t
[
100
];
ITOW_S(number, buffer, sizeof(buffer) / sizeof(*buffer), 10);
(
,
buffer
,
sizeof
(
buffer
) /
sizeof
(*
buffer
),
10
);
return
buffer
;
}
(
)
{
char
[
100
];
I64TOA_S(number, buffer, sizeof(buffer) / sizeof(*buffer), 10);
(
,
buffer
,
sizeof
(
buffer
) /
sizeof
(*
buffer
),
10
);
return
buffer
;
}
(
)
{
wchar_t
[
100
];
I64TOW_S(number, buffer, sizeof(buffer) / sizeof(*buffer), 10);
(
,
buffer
,
sizeof
(
buffer
) /
sizeof
(*
buffer
),
10
);
return
buffer
;
}
(
)
{
char
[
100
];
UITOA_S(number, buffer, sizeof(buffer) / sizeof(*buffer), 10);
(
,
buffer
,
sizeof
(
buffer
) /
sizeof
(*
buffer
),
10
);
return
buffer
;
}
(
)
{
wchar_t
[
100
];
UITOW_S(number, buffer, sizeof(buffer) / sizeof(*buffer), 10);
(
,
buffer
,
sizeof
(
buffer
) /
sizeof
(*
buffer
),
10
);
return
buffer
;
}
(
)
{
char
[
100
];
UI64TOA_S(number, buffer, sizeof(buffer) / sizeof(*buffer), 10);
(
,
buffer
,
sizeof
(
buffer
) /
sizeof
(*
buffer
),
10
);
return
buffer
;
}
(
)
{
wchar_t
[
100
];
UI64TOW_S(number, buffer, sizeof(buffer) / sizeof(*buffer), 10);
(
,
buffer
,
sizeof
(
buffer
) /
sizeof
(*
buffer
),
10
);
return
buffer
;
}
(
double
)
{
char
[
320
];
(
buffer
,
320
,
,
30
);
= (
)
(
buffer
);
if
(
buffer
[
len
-
1
] ==
'.'
)
{
buffer
[
len
-
1
] =
'\0'
;
}
return
buffer
;
}
(
double
)
{
return
(
(
));
}
(
const
wchar_t
*
,
char
*
,
)
{
#if defined VCZH_MSVC
return WideCharToMultiByte(CP_THREAD_ACP, 0, w, -1, a, (int)(a ? chars : 0), 0, 0);
return
(
3
,
0
,
, -
1
,
, (
int
)(
?
:
0
),
0
,
0
);
#elif defined VCZH_GCC
return wcstombs(a, w, chars-1)+1;
#endif
}
(
const
&
)
{
=
(
.
(),
0
,
0
);
char
*
=
new
char
[
len
];
(
buffer
,
0
,
len
*
sizeof
(*
buffer
));
(
.
(),
buffer
, (
int
)
len
);
=
buffer
;
delete
[]
buffer
;
return
s
;
}
(
const
char
*
,
wchar_t
*
,
)
{
#if defined VCZH_MSVC
return MultiByteToWideChar(CP_THREAD_ACP, 0, a, -1, w, (int)(w ? chars : 0));
return
(
3
,
0
,
, -
1
,
, (
int
)(
?
:
0
));
#elif defined VCZH_GCC
return mbstowcs(w, a, chars-1)+1;
#endif
}
(
const
&
)
{
=
(
.
(),
0
,
0
);
wchar_t
*
=
new
wchar_t
[
len
];
(
buffer
,
0
,
len
*
sizeof
(*
buffer
));
(
.
(),
buffer
, (
int
)
len
);
=
buffer
;
delete
[]
buffer
;
return
s
;
}
(
const
&
)
{
=
.
();
((
char
*)
result
.
(),
result
.
() +
1
);
return
result
;
}
(
const
&
)
{
=
.
();
((
wchar_t
*)
result
.
(),
result
.
() +
1
);
return
result
;
}
(
const
&
)
{
=
.
();
((
char
*)
result
.
(),
result
.
() +
1
);
return
result
;
}
(
const
&
)
{
=
.
();
((
wchar_t
*)
result
.
(),
result
.
() +
1
);
return
result
;
}
(
,
)
{
static
const
wchar_t
*
[] =
{
L"lorem"
,
L"ipsum"
,
L"dolor"
,
L"sit"
,
L"amet"
,
L"consectetur"
,
L"adipiscing"
,
L"elit"
,
L"integer"
,
L"nec"
,
L"odio"
,
L"praesent"
,
L"libero"
,
L"sed"
,
L"cursus"
,
L"ante"
,
L"dapibus"
,
L"diam"
,
L"sed"
,
L"nisi"
,
L"nulla"
,
L"quis"
,
L"sem"
,
L"at"
,
L"nibh"
,
L"elementum"
,
L"imperdiet"
,
L"duis"
,
L"sagittis"
,
L"ipsum"
,
L"praesent"
,
L"mauris"
,
L"fusce"
,
L"nec"
,
L"tellus"
,
L"sed"
,
L"augue"
,
L"semper"
,
L"porta"
,
L"mauris"
,
L"massa"
,
L"vestibulum"
,
L"lacinia"
,
L"arcu"
,
L"eget"
,
L"nulla"
,
L"class"
,
L"aptent"
,
L"taciti"
,
L"sociosqu"
,
L"ad"
,
L"litora"
,
L"torquent"
,
L"per"
,
L"conubia"
,
L"nostra"
,
L"per"
,
L"inceptos"
,
L"himenaeos"
,
L"curabitur"
,
L"sodales"
,
L"ligula"
,
L"in"
,
L"libero"
,
L"sed"
,
L"dignissim"
,
L"lacinia"
,
L"nunc"
,
L"curabitur"
,
L"tortor"
,
L"pellentesque"
,
L"nibh"
,
L"aenean"
,
L"quam"
,
L"in"
,
L"scelerisque"
,
L"sem"
,
L"at"
,
L"dolor"
,
L"maecenas"
,
L"mattis"
,
L"sed"
,
L"convallis"
,
L"tristique"
,
L"sem"
,
L"proin"
,
L"ut"
,
L"ligula"
,
L"vel"
,
L"nunc"
,
L"egestas"
,
L"porttitor"
,
L"morbi"
,
L"lectus"
,
L"risus"
,
L"iaculis"
,
L"vel"
,
L"suscipit"
,
L"quis"
,
L"luctus"
,
L"non"
,
L"massa"
,
L"fusce"
,
L"ac"
,
L"turpis"
,
L"quis"
,
L"ligula"
,
L"lacinia"
,
L"aliquet"
,
L"mauris"
,
L"ipsum"
,
L"nulla"
,
L"metus"
,
L"metus"
,
L"ullamcorper"
,
L"vel"
,
L"tincidunt"
,
L"sed"
,
L"euismod"
,
L"in"
,
L"nibh"
,
L"quisque"
,
L"volutpat"
,
L"condimentum"
,
L"velit"
,
L"class"
,
L"aptent"
,
L"taciti"
,
L"sociosqu"
,
L"ad"
,
L"litora"
,
L"torquent"
,
L"per"
,
L"conubia"
,
L"nostra"
,
L"per"
,
L"inceptos"
,
L"himenaeos"
,
L"nam"
,
L"nec"
,
L"ante"
,
L"sed"
,
L"lacinia"
,
L"urna"
,
L"non"
,
L"tincidunt"
,
L"mattis"
,
L"tortor"
,
L"neque"
,
L"adipiscing"
,
L"diam"
,
L"a"
,
L"cursus"
,
L"ipsum"
,
L"ante"
,
L"quis"
,
L"turpis"
,
L"nulla"
,
L"facilisi"
,
L"ut"
,
L"fringilla"
,
L"suspendisse"
,
L"potenti"
,
L"nunc"
,
L"feugiat"
,
L"mi"
,
L"a"
,
L"tellus"
,
L"consequat"
,
L"imperdiet"
,
L"vestibulum"
,
L"sapien"
,
L"proin"
,
L"quam"
,
L"etiam"
,
L"ultrices"
,
L"suspendisse"
,
L"in"
,
L"justo"
,
L"eu"
,
L"magna"
,
L"luctus"
,
L"suscipit"
,
L"sed"
,
L"lectus"
,
L"integer"
,
L"euismod"
,
L"lacus"
,
L"luctus"
,
L"magna"
,
L"quisque"
,
L"cursus"
,
L"metus"
,
L"vitae"
,
L"pharetra"
,
L"auctor"
,
L"sem"
,
L"massa"
,
L"mattis"
,
L"sem"
,
L"at"
,
L"interdum"
,
L"magna"
,
L"augue"
,
L"eget"
,
L"diam"
,
L"vestibulum"
,
L"ante"
,
L"ipsum"
,
L"primis"
,
L"in"
,
L"faucibus"
,
L"orci"
,
L"luctus"
,
L"et"
,
L"ultrices"
,
L"posuere"
,
L"cubilia"
,
L"curae;"
,
L"morbi"
,
L"lacinia"
,
L"molestie"
,
L"dui"
,
L"praesent"
,
L"blandit"
,
L"dolor"
,
L"sed"
,
L"non"
,
L"quam"
,
L"in"
,
L"vel"
,
L"mi"
,
L"sit"
,
L"amet"
,
L"augue"
,
L"congue"
,
L"elementum"
,
L"morbi"
,
L"in"
,
L"ipsum"
,
L"sit"
,
L"amet"
,
L"pede"
,
L"facilisis"
,
L"laoreet"
,
L"donec"
,
L"lacus"
,
L"nunc"
,
L"viverra"
,
L"nec"
,
L"blandit"
,
L"vel"
,
L"egestas"
,
L"et"
,
L"augue"
,
L"vestibulum"
,
L"tincidunt"
,
L"malesuada"
,
L"tellus"
,
L"ut"
,
L"ultrices"
,
L"ultrices"
,
L"enim"
,
L"curabitur"
,
L"sit"
,
L"amet"
,
L"mauris"
,
L"morbi"
,
L"in"
,
L"dui"
,
L"quis"
,
L"est"
,
L"pulvinar"
,
L"ullamcorper"
,
L"nulla"
,
L"facilisi"
,
L"integer"
,
L"lacinia"
,
L"sollicitudin"
,
L"massa"
,
L"cras"
,
L"metus"
,
L"sed"
,
L"aliquet"
,
L"risus"
,
L"a"
,
L"tortor"
,
L"integer"
,
L"id"
,
L"quam"
,
L"morbi"
,
L"mi"
,
L"quisque"
,
L"nisl"
,
L"felis"
,
L"venenatis"
,
L"tristique"
,
L"dignissim"
,
L"in"
,
L"ultrices"
,
L"sit"
,
L"amet"
,
L"augue"
,
L"proin"
,
L"sodales"
,
L"libero"
,
L"eget"
,
L"ante"
,
L"nulla"
,
L"quam"
,
L"aenean"
,
L"laoreet"
,
L"vestibulum"
,
L"nisi"
,
L"lectus"
,
L"commodo"
,
L"ac"
,
L"facilisis"
,
L"ac"
,
L"ultricies"
,
L"eu"
,
L"pede"
,
L"ut"
,
L"orci"
,
L"risus"
,
L"accumsan"
,
L"porttitor"
,
L"cursus"
,
L"quis"
,
L"aliquet"
,
L"eget"
,
L"justo"
,
L"sed"
,
L"pretium"
,
L"blandit"
,
L"orci"
,
L"ut"
,
L"eu"
,
L"diam"
,
L"at"
,
L"pede"
,
L"suscipit"
,
L"sodales"
,
L"aenean"
,
L"lectus"
,
L"elit"
,
L"fermentum"
,
L"non"
,
L"convallis"
,
L"id"
,
L"sagittis"
,
L"at"
,
L"neque"
,
L"nullam"
,
L"mauris"
,
L"orci"
,
L"aliquet"
,
L"et"
,
L"iaculis"
,
L"et"
,
L"viverra"
,
L"vitae"
,
L"ligula"
,
L"nulla"
,
L"ut"
,
L"felis"
,
L"in"
,
L"purus"
,
L"aliquam"
,
L"imperdiet"
,
L"maecenas"
,
L"aliquet"
,
L"mollis"
,
L"lectus"
,
L"vivamus"
,
L"consectetuer"
,
L"risus"
,
L"et"
,
L"tortor"
};
static
=
0
;
const
=
sizeof
(
words
) /
sizeof
(*
words
);
if
(
<
0
)
=
0
;
=
+
20
;
wchar_t
*
=
new
wchar_t
[
bufferLength
+
1
];
buffer
[
0
] =
0
;
=
0
;
wchar_t
*
=
buffer
;
while
(
used
<
)
{
if
(
used
!=
0
)
{
*
writing
++ =
L' '
;
used
++;
}
= (
)
(
words
[
index
]);
(
writing
,
bufferLength
-
used
,
words
[
index
]);
if
(
==
::
|| (
==
::
&&
used
==
0
))
{
*
writing
-=
L'a'
-
L'A'
;
}
if
(
used
!=
0
&&
used
+
wordSize
>
)
{
=
-
used
+
1
;
=
used
+
wordSize
-
;
if
(
deltaShort
<
deltaLong
)
{
*--
writing
=
0
;
used
--;
break
;
}
}
writing
+=
wordSize
;
used
+=
wordSize
;
index
= (
index
+
1
) %
WordCount
;
}
=
buffer
;
delete
[]
buffer
;
return
result
;
}
(
)
{
return
(
,
::
);
}
(
)
{
return
(
,
::
) +
L"."
;
}
(
)
{
((
unsigned
)
(
0
));
auto
=
::
;
=
0
;
;
while
(
result
.
() <
)
{
=
-
result
.
();
if
(
comma
==
0
)
{
comma
=
() %
4
+
1
;
}
=
() %
45
+
15
;
if
(
offset
<
20
)
{
comma
=
0
;
length
=
offset
-
1
;
}
else
if
(
length
>
offset
)
{
comma
=
0
;
length
=
offset
+
() %
11
-
5
;
}
result
(
length
,
casing
);
if
(
comma
==
0
)
{
result
+=
L"."
;
break
;
}
else
if
(
comma
==
1
)
{
result
+=
L". "
;
casing
=
::
;
}
else
{
result
+=
L", "
;
casing
=
::
;
}
comma
--;
}
return
result
;
}
}