1 #ifndef STRINGHELPERSH_H
2 #define STRINGHELPERSH_H
4 #ifndef HELPERS_IMP_EXP
6 #define HELPERS_IMP_EXP __declspec(dllexport)
8 #define HELPERS_IMP_EXP __declspec(dllimport)
13 #if defined(__linux__)
26 inline char*
uniCpy(
char* str1,
const char* str2) {
return strcpy(str1, str2); }
27 inline WCHAR*
uniCpy(WCHAR* str1,
const WCHAR* str2) {
return wcscpy(str1, str2); }
28 inline char*
uniNCpy(
char* str1,
const char* str2,
size_t count) {
return strncpy(str1, str2, count); }
29 inline WCHAR*
uniNCpy(WCHAR* str1,
const WCHAR* str2,
size_t count) {
return wcsncpy(str1, str2, count); }
30 inline char*
uniCat(
char* str1,
const char* str2) {
return strcat(str1, str2); }
31 inline WCHAR*
uniCat(WCHAR* str1,
const WCHAR* str2) {
return wcscat(str1, str2); }
32 inline const char*
uniStr(
const char* str1,
const char* str2) {
return strstr(str1, str2); }
33 inline const WCHAR*
uniStr(
const WCHAR* str1,
const WCHAR* str2) {
return wcsstr(str1, str2); }
34 inline char*
uniStr(
char* str1,
const char* str2) {
return strstr(str1, str2); }
35 inline WCHAR*
uniStr(WCHAR* str1,
const WCHAR* str2) {
return wcsstr(str1, str2); }
36 inline size_t uniLen(
const char* str1) {
return strlen(str1); }
37 inline size_t uniLen(
const WCHAR* str1) {
return wcslen(str1); }
41 template <
class _Type>
46 _Type backslashStr[2] = {
'\\', 0x00};
47 _Type colonStr[2] = {
':', 0x00};
49 if ((inFile[0] ==
'\\') || (inFile[0] ==
'/')) {
52 i = (int)
uniLen(outFile) - 1;
54 if (outFile[i] ==
':')
61 }
else if (
uniStr(inFile, colonStr)) {
67 if ((i > 0) && (outFile[i - 1] !=
'\\') && (outFile[i - 1] !=
'/'))
68 uniCat(outFile, backslashStr);
74 template <
class _Type>
75 void getRelativePath(_Type *outPathFile,
const _Type *inPath,
const _Type *inPathFile)
80 _Type tmpInPath[1000];
81 strcpy (tmpInPath, inPath);
83 if ((i <= 0) || ((tmpInPath[i - 1] !=
'\\') && (tmpInPath[i - 1] !=
'/'))) {
86 tmpInPath[i + 1] = 0x00;
93 while ((tmpInPath[inPos] != 0x00) && (tolower(tmpInPath[inPos]) == tolower(tmpPath[inPos]))) {
98 if (tmpInPath[inPos] == 0x00) {
100 if (tmpPath[inPos] == 0x00) {
103 outPathFile[0] =
'.';
104 outPathFile[1] = 0x00;
108 uniCpy(outPathFile, tmpPath + inPos);
116 while (tmpInPath[i] != 0x00) {
117 if ((tmpInPath[i] ==
'\\') || (tmpInPath[i] ==
'/')) {
118 outPathFile[outPos] =
'.';
119 outPathFile[outPos + 1] =
'.';
120 outPathFile[outPos + 2] =
'\\';
126 while ((inPos >= 0) && (tmpPath[inPos - 1] !=
'\\') && (tmpPath[inPos - 1] !=
'/')) {
131 uniCpy(outPathFile + outPos, tmpPath + inPos);
156 template <
class _Type>
160 int i = (int)
uniLen(inFile) - 1;
162 if ((inFile[i] ==
'\\') || (inFile[i] ==
'/')) {
163 uniNCpy(outPath, inFile, i + 1);
173 template <
class _Type>
175 int i = (int)
uniLen(inFile) - 1;
177 if ((inFile[i] ==
'\\') || (inFile[i] ==
'/')) {
179 outFile[
uniLen(inFile) - i - 1] = 0;
188 template <
class _Type>
192 int i = (int)
uniLen(inFile) - 1;
194 if ((inFile[i] ==
'\\') || (inFile[i] ==
'/'))
198 if (inFile[i] ==
'.') {
211 template <
class _Type>
215 int i = (int)
uniLen(inFile) - 1;
217 if ((inFile[i] ==
'\\') || (inFile[i] ==
'/'))
221 if (inFile[i] ==
'.') {
223 outExt[
uniLen(inFile) - i - 1] = 0;