change to namespaces

This commit is contained in:
Dennis Eichhorn 2022-09-19 18:57:59 +02:00
parent 04ab177b23
commit 9c0859daff
6 changed files with 116 additions and 96 deletions

View File

@ -14,11 +14,8 @@
#include <stdlib.h>
namespace Utils {
class ArraySort {
private:
public:
static inline
namespace ArraySort {
inline
void reverse_int(int *arr, int size)
{
for (int low = 0, high = size - 1; low < high; ++low, --high) {
@ -28,7 +25,7 @@ namespace Utils {
}
}
static inline
inline
void reverse_float(float *arr, int size)
{
for (int low = 0, high = size - 1; low < high; ++low, --high) {
@ -38,7 +35,7 @@ namespace Utils {
}
}
static inline
inline
void reverse_double(double *arr, int size)
{
for (int low = 0, high = size - 1; low < high; ++low, --high) {
@ -48,7 +45,7 @@ namespace Utils {
}
}
static inline
inline
void reverse_char(char *arr, int size)
{
for (int low = 0, high = size - 1; low < high; ++low, --high) {
@ -57,7 +54,7 @@ namespace Utils {
arr[high] = tmp;
}
}
};
}
}
#endif

View File

@ -45,6 +45,7 @@ namespace Utils {
return false;
}
}
}
#endif

View File

@ -113,6 +113,7 @@ namespace Utils {
return file;
}
}
}
#endif

View File

@ -136,6 +136,7 @@ namespace Utils {
return text_diff { diffValues, diffMasks, diffIndex };
}
}
}
#endif

View File

@ -13,7 +13,28 @@
#include <stdio.h>
#include "MathUtils.h"
#define ASSERT_EQUALS(a, b, t1, t2) \
#ifdef _MSC_VER
#define ASSERT_EQUALS(a, b, t1, t2) (\
if (a == b) { \
printf("."); \
} else { \
printf("[F]"); \
printf("\n\n%s - %i: ", __FILE__, __LINE__); \
printf(t1, a); printf(" != "); printf(t2, b); printf("\n"); \
return 0; } \
)
#define ASSERT_EQUALS_WITH_DELTA(a, b, delta, t1, t2) (\
if (oms_abs(a - b) <= _delta) { \
printf("."); \
} else { \
printf("[F]"); \
printf("\n\n%s - %i: ", __FILE__, __LINE__); \
printf(t1, a); printf(" != "); printf(t2, b); printf("\n"); \
return 0; } \
)
#else
#define ASSERT_EQUALS(a, b, t1, t2) \
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
if (_a == _b) { \
@ -21,11 +42,11 @@
} else { \
printf("[F]"); \
printf("\n\n%s - %i: ", __FILE__, __LINE__); \
printf(t1, a); printf(" != "); printf(t2, b); printf("\n"); \
printf(t1, _a); printf(" != "); printf(t2, _b); printf("\n"); \
return 0; } \
})
#define ASSERT_EQUALS_WITH_DELTA(a, b, delta, t1, t2) \
#define ASSERT_EQUALS_WITH_DELTA(a, b, delta, t1, t2) \
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
__typeof__ (delta) _delta = (delta); \
@ -35,8 +56,9 @@
} else { \
printf("[F]"); \
printf("\n\n%s - %i: ", __FILE__, __LINE__); \
printf(t1, a); printf(" != "); printf(t2, b); printf("\n"); \
printf(t1, _a); printf(" != "); printf(t2, _b); printf("\n"); \
return 0; } \
})
#endif
#endif

View File

@ -18,8 +18,7 @@
#include "FileUtils.h"
namespace Utils {
class WebUtils {
private:
namespace WebUtils {
static
int write_download_data (void *ptr, size_t size, size_t nmeb, void *stream)
{
@ -41,7 +40,6 @@ namespace Utils {
return out->size;
}
public:
static
Utils::FileUtils::file_body download (char *url)
{
@ -57,7 +55,7 @@ namespace Utils {
return page;
}
};
}
}
#endif