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> #include <stdlib.h>
namespace Utils { namespace Utils {
class ArraySort { namespace ArraySort {
private: inline
public:
static inline
void reverse_int(int *arr, int size) void reverse_int(int *arr, int size)
{ {
for (int low = 0, high = size - 1; low < high; ++low, --high) { 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) void reverse_float(float *arr, int size)
{ {
for (int low = 0, high = size - 1; low < high; ++low, --high) { 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) void reverse_double(double *arr, int size)
{ {
for (int low = 0, high = size - 1; low < high; ++low, --high) { 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) void reverse_char(char *arr, int size)
{ {
for (int low = 0, high = size - 1; low < high; ++low, --high) { for (int low = 0, high = size - 1; low < high; ++low, --high) {
@ -57,7 +54,7 @@ namespace Utils {
arr[high] = tmp; arr[high] = tmp;
} }
} }
}; }
} }
#endif #endif

View File

@ -46,5 +46,6 @@ namespace Utils {
return false; return false;
} }
} }
}
#endif #endif

View File

@ -114,5 +114,6 @@ namespace Utils {
return file; return file;
} }
} }
}
#endif #endif

View File

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

View File

@ -13,6 +13,27 @@
#include <stdio.h> #include <stdio.h>
#include "MathUtils.h" #include "MathUtils.h"
#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) \ #define ASSERT_EQUALS(a, b, t1, t2) \
({ __typeof__ (a) _a = (a); \ ({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \ __typeof__ (b) _b = (b); \
@ -21,7 +42,7 @@
} else { \ } else { \
printf("[F]"); \ printf("[F]"); \
printf("\n\n%s - %i: ", __FILE__, __LINE__); \ 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; } \ return 0; } \
}) })
@ -35,8 +56,9 @@
} else { \ } else { \
printf("[F]"); \ printf("[F]"); \
printf("\n\n%s - %i: ", __FILE__, __LINE__); \ 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; } \ return 0; } \
}) })
#endif
#endif #endif

View File

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