mirror of
https://github.com/Karaka-Management/cOMS.git
synced 2026-02-18 11:08:41 +00:00
Update code style
This commit is contained in:
parent
b34004c1cb
commit
33b480fbae
|
|
@ -17,9 +17,7 @@
|
|||
#include "../DatabaseType.h"
|
||||
#include "../DatabaseStatus.h"
|
||||
|
||||
namespace DataStorage
|
||||
{
|
||||
namespace Database
|
||||
namespace DataStorage::Database
|
||||
{
|
||||
typedef struct {
|
||||
size_t rows = 0;
|
||||
|
|
@ -57,6 +55,5 @@ namespace DataStorage
|
|||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -21,9 +21,7 @@
|
|||
#include "PostgresqlConnection.h"
|
||||
#include "SQLiteConnection.h"
|
||||
|
||||
namespace DataStorage
|
||||
{
|
||||
namespace Database
|
||||
namespace DataStorage::Database
|
||||
{
|
||||
ConnectionAbstract *create_connection(DbConnectionConfig dbdata)
|
||||
{
|
||||
|
|
@ -57,6 +55,5 @@ namespace DataStorage
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -15,9 +15,7 @@
|
|||
|
||||
#include "../DatabaseType.h"
|
||||
|
||||
namespace DataStorage
|
||||
{
|
||||
namespace Database
|
||||
namespace DataStorage::Database
|
||||
{
|
||||
typedef struct {
|
||||
DatabaseType db = DatabaseType::UNDEFINED;
|
||||
|
|
@ -56,6 +54,5 @@ namespace DataStorage
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -20,9 +20,7 @@
|
|||
#include "../DatabaseType.h"
|
||||
#include "../DatabaseStatus.h"
|
||||
|
||||
namespace DataStorage
|
||||
{
|
||||
namespace Database
|
||||
namespace DataStorage::Database
|
||||
{
|
||||
struct MysqlConnection : ConnectionAbstract {
|
||||
MysqlConnection(DbConnectionConfig dbdata)
|
||||
|
|
@ -145,6 +143,5 @@ namespace DataStorage
|
|||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -20,9 +20,7 @@
|
|||
#include "../DatabaseType.h"
|
||||
#include "../DatabaseStatus.h"
|
||||
|
||||
namespace DataStorage
|
||||
{
|
||||
namespace Database
|
||||
namespace DataStorage::Database
|
||||
{
|
||||
struct PostgresqlConnection : ConnectionAbstract {
|
||||
PostgresqlConnection(DbConnectionConfig dbdata)
|
||||
|
|
@ -139,6 +137,5 @@ namespace DataStorage
|
|||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -20,9 +20,7 @@
|
|||
#include "../DatabaseType.h"
|
||||
#include "../DatabaseStatus.h"
|
||||
|
||||
namespace DataStorage
|
||||
{
|
||||
namespace Database
|
||||
namespace DataStorage::Database
|
||||
{
|
||||
struct SQLiteConnection : ConnectionAbstract {
|
||||
SQLiteConnection(DbConnectionConfig dbdata)
|
||||
|
|
@ -156,6 +154,5 @@ namespace DataStorage
|
|||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -10,9 +10,7 @@
|
|||
#ifndef DATASTORAGE_DATABASE_STATUS_H
|
||||
#define DATASTORAGE_DATABASE_STATUS_H
|
||||
|
||||
namespace DataStorage
|
||||
{
|
||||
namespace Database
|
||||
namespace DataStorage::Database
|
||||
{
|
||||
typedef enum {
|
||||
OK = 0,
|
||||
|
|
@ -23,6 +21,5 @@ namespace DataStorage
|
|||
CLOSED = 5
|
||||
} DatabaseStatus;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -12,9 +12,7 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
namespace DataStorage
|
||||
{
|
||||
namespace Database
|
||||
namespace DataStorage::Database
|
||||
{
|
||||
typedef enum {
|
||||
MYSQL = 1,
|
||||
|
|
@ -39,6 +37,5 @@ namespace DataStorage
|
|||
return DatabaseType::UNDEFINED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -18,9 +18,7 @@
|
|||
#include "ReadMapper.h"
|
||||
#include "MapperAbstract.h"
|
||||
|
||||
namespace DataStorage
|
||||
{
|
||||
namespace Database
|
||||
namespace DataStorage::Database
|
||||
{
|
||||
static DataStorage::Database::ConnectionAbstract *db;
|
||||
static const char *dateTimeFormat = "Y-m-d H:i:s";
|
||||
|
|
@ -54,6 +52,5 @@ namespace DataStorage
|
|||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -13,9 +13,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
namespace DataStorage
|
||||
{
|
||||
namespace Database
|
||||
namespace DataStorage::Database
|
||||
{
|
||||
typedef enum {
|
||||
MAPPER_DEFAULT = 0,
|
||||
|
|
@ -217,6 +215,5 @@ namespace DataStorage
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -12,13 +12,12 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "../Connection/ConnectionAbstract.h"
|
||||
#include "DataMapperTypes.h"
|
||||
|
||||
namespace DataStorage
|
||||
{
|
||||
namespace Database
|
||||
namespace DataStorage::Database
|
||||
{
|
||||
struct MapperAbstract {
|
||||
const DataStorage::Database::MapperData *mapper = NULL;
|
||||
|
|
@ -102,6 +101,5 @@ namespace DataStorage
|
|||
virtual void *execute(void *options = NULL);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -17,9 +17,7 @@
|
|||
#include "DataMapperFactory.h"
|
||||
#include "MapperAbstract.h"
|
||||
|
||||
namespace DataStorage
|
||||
{
|
||||
namespace Database
|
||||
namespace DataStorage::Database
|
||||
{
|
||||
struct ReadMapper : MapperAbstract {
|
||||
ReadMapper *get()
|
||||
|
|
@ -65,6 +63,5 @@ namespace DataStorage
|
|||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -13,9 +13,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
namespace DataStorage
|
||||
{
|
||||
namespace Database
|
||||
namespace DataStorage::Database
|
||||
{
|
||||
typedef struct {
|
||||
char *name;
|
||||
|
|
@ -57,6 +55,5 @@ namespace DataStorage
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -15,9 +15,7 @@
|
|||
|
||||
#include "DbField.h"
|
||||
|
||||
namespace DataStorage
|
||||
{
|
||||
namespace Database
|
||||
namespace DataStorage::Database
|
||||
{
|
||||
typedef struct {
|
||||
char *name;
|
||||
|
|
@ -42,6 +40,5 @@ namespace DataStorage
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -2,6 +2,8 @@
|
|||
#define HASH_MD5_H
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// https://www.rfc-editor.org/rfc/rfc1321
|
||||
|
||||
|
|
@ -37,7 +39,7 @@ namespace Hash {
|
|||
uint32_t a, b, c, d;
|
||||
uint32_t aa, bb, cc, dd;
|
||||
|
||||
ptr = data;
|
||||
ptr = (const unsigned char *) data;
|
||||
|
||||
a = ctx->a;
|
||||
b = ctx->b;
|
||||
|
|
|
|||
|
|
@ -116,6 +116,7 @@
|
|||
#define HASH_MEOW_H
|
||||
|
||||
// #include <immintrin.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if !defined(meow_u8)
|
||||
#define MEOW_HASH_VERSION 5
|
||||
|
|
@ -199,9 +200,7 @@
|
|||
pxor(r2, r3)
|
||||
#endif
|
||||
|
||||
namespace Hash
|
||||
{
|
||||
namespace Meow
|
||||
namespace Hash::Meow
|
||||
{
|
||||
#if MEOW_DUMP
|
||||
struct meow_dump
|
||||
|
|
@ -740,7 +739,6 @@ namespace Hash
|
|||
return (const char *) str;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#undef INSTRUCTION_REORDER_BARRIER
|
||||
#undef prefetcht0
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ void sha_256_write(struct Sha_256 *sha_256, const void *data, size_t len)
|
|||
{
|
||||
sha_256->total_len += len;
|
||||
|
||||
const uint8_t *p = data;
|
||||
const uint8_t *p = (uint8_t *) data;
|
||||
|
||||
while (len > 0) {
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -14,9 +14,7 @@
|
|||
#include <opencv2/opencv.hpp>
|
||||
#include <vector>
|
||||
|
||||
namespace Image
|
||||
{
|
||||
namespace BillDetection
|
||||
namespace Image::BillDetection
|
||||
{
|
||||
cv::Mat highlightBill(cv::Mat in)
|
||||
{
|
||||
|
|
@ -76,6 +74,5 @@ namespace Image
|
|||
return out;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -13,9 +13,7 @@
|
|||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
namespace Image
|
||||
{
|
||||
namespace ImageUtils
|
||||
namespace Image::ImageUtils
|
||||
{
|
||||
inline
|
||||
float lightnessFromRgb(int r, int g, int b)
|
||||
|
|
@ -33,17 +31,6 @@ namespace Image
|
|||
|
||||
return lStar / 100.0;
|
||||
}
|
||||
|
||||
inline
|
||||
int rgbToInt(int r, int g, int b)
|
||||
{
|
||||
int rgb = r;
|
||||
rgb = (rgb << 8) + g;
|
||||
rgb = (rgb << 8) + b;
|
||||
|
||||
return rgb;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
#include "ImageUtils.h"
|
||||
#include "../Utils/MathUtils.h"
|
||||
|
||||
namespace Image
|
||||
namespace Image::Kernel
|
||||
{
|
||||
const float KERNEL_RIDGE_1[3][3] = {
|
||||
{0.0, -1.0, 0.0},
|
||||
|
|
@ -62,8 +62,6 @@ namespace Image
|
|||
{-1.0 / 256.0, -4.0 / 256.0, -6.0 / 256.0, -4.0 / 256.0, -1.0 / 256.0},
|
||||
};
|
||||
|
||||
namespace Kernel
|
||||
{
|
||||
inline
|
||||
cv::Mat convolve(cv::Mat in, const float kernel[][3])
|
||||
{
|
||||
|
|
@ -76,6 +74,5 @@ namespace Image
|
|||
return out;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -16,9 +16,7 @@
|
|||
|
||||
#include "../Utils/MathUtils.h"
|
||||
|
||||
namespace Image
|
||||
{
|
||||
namespace Skew
|
||||
namespace Image::Skew
|
||||
{
|
||||
cv::Mat deskewHoughLines(cv::Mat in, int maxDegree = 45)
|
||||
{
|
||||
|
|
@ -88,6 +86,5 @@ namespace Image
|
|||
return out;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -16,9 +16,7 @@
|
|||
#include "ImageUtils.h"
|
||||
#include "../Utils/MathUtils.h"
|
||||
|
||||
namespace Image
|
||||
{
|
||||
namespace Thresholding
|
||||
namespace Image::Thresholding
|
||||
{
|
||||
cv::Mat integralThresholding(cv::Mat in)
|
||||
{
|
||||
|
|
@ -76,6 +74,5 @@ namespace Image
|
|||
return out;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -16,9 +16,7 @@
|
|||
|
||||
#include "../Hash/MeowHash.h"
|
||||
|
||||
namespace Stdlib
|
||||
{
|
||||
namespace HashTable
|
||||
namespace Stdlib::HashTable
|
||||
{
|
||||
typedef struct {
|
||||
const char *key;
|
||||
|
|
@ -216,6 +214,5 @@ namespace Stdlib
|
|||
free(table->entries);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -48,9 +48,7 @@ namespace Utils
|
|||
|
||||
if (pos != NULL) {
|
||||
memcpy(dir, arg, (pos - arg) * sizeof(char));
|
||||
|
||||
chdir(dir);
|
||||
|
||||
free(dir);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,9 +13,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
namespace Utils
|
||||
{
|
||||
namespace ArraySort
|
||||
namespace Utils::ArraySort
|
||||
{
|
||||
inline
|
||||
void reverse_int(int64_t *arr, size_t size)
|
||||
|
|
@ -57,6 +55,5 @@ namespace Utils
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -16,9 +16,7 @@
|
|||
|
||||
#include "StringUtils.h"
|
||||
|
||||
namespace Utils
|
||||
{
|
||||
namespace ArrayUtils
|
||||
namespace Utils::ArrayUtils
|
||||
{
|
||||
inline
|
||||
char* get_arg(const char *id, char **argv, size_t size)
|
||||
|
|
@ -194,18 +192,17 @@ namespace Utils
|
|||
}
|
||||
|
||||
for (size_t i = 0; i < size1; ++i) {
|
||||
merged[i] = (char*) malloc((strlen(arr1[i]) + 1) * sizeof(char));
|
||||
strcpy(merged[i], arr1[i]);
|
||||
merged[i] = (char*) malloc((strlen(array1[i]) + 1) * sizeof(char));
|
||||
strcpy(merged[i], array1[i]);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < size2; ++i) {
|
||||
merged[i] = (char*) malloc((strlen(arr2[i]) + 1) * sizeof(char));
|
||||
strcpy(merged[i], arr2[i]);
|
||||
merged[i] = (char*) malloc((strlen(array2[i]) + 1) * sizeof(char));
|
||||
strcpy(merged[i], array2[i]);
|
||||
}
|
||||
|
||||
return merged;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
57
Utils/ColorUtils.h
Normal file
57
Utils/ColorUtils.h
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
/**
|
||||
* Karaka
|
||||
*
|
||||
* @package Utils
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
#ifndef UTILS_STRING_UTILS_H
|
||||
#define UTILS_STRING_UTILS_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
namespace Utils::ColorUtils
|
||||
{
|
||||
typedef struct {
|
||||
char r = 0;
|
||||
char g = 0;
|
||||
char b = 0;
|
||||
} RGB;
|
||||
|
||||
inline
|
||||
RGB* int_to_rgb(int rgb)
|
||||
{
|
||||
RGB* result = (RGB*) malloc(1 * sizeof(RGB));
|
||||
|
||||
result->r = rgb & 255;
|
||||
result->g = (rgb >> 8) & 255;
|
||||
result->b = (rgb >> 16) & 255;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
inline
|
||||
int rgb_to_int(RGB* rgb)
|
||||
{
|
||||
int i = (255 & rgb->r) << 16;
|
||||
i += (255 & rgb->g) << 8;
|
||||
i += (255 & rgb->b);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
inline
|
||||
int rgb_to_int(char r, char g, char b)
|
||||
{
|
||||
int i = (255 & r) << 16;
|
||||
i += (255 & g) << 8;
|
||||
i += (255 & b);
|
||||
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -23,9 +23,7 @@
|
|||
|
||||
#include "OSWrapper.h"
|
||||
|
||||
namespace Utils
|
||||
{
|
||||
namespace FileUtils
|
||||
namespace Utils::FileUtils
|
||||
{
|
||||
inline
|
||||
bool file_exists (const char *filename)
|
||||
|
|
@ -129,6 +127,5 @@ namespace Utils
|
|||
return file;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -14,11 +14,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
namespace Utils
|
||||
{
|
||||
namespace Rng
|
||||
{
|
||||
namespace StringUtils
|
||||
namespace Utils::Rng::StringUtils
|
||||
{
|
||||
inline
|
||||
char* generate_string(
|
||||
|
|
@ -39,5 +35,5 @@ namespace Utils
|
|||
return randomString;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -17,9 +17,7 @@
|
|||
#include "MathUtils.h"
|
||||
#include "ArraySort.h"
|
||||
|
||||
namespace Utils
|
||||
{
|
||||
namespace StringUtils
|
||||
namespace Utils::StringUtils
|
||||
{
|
||||
inline
|
||||
char *search_replace(const char *haystack, const char *needle, const char *replace)
|
||||
|
|
@ -97,6 +95,7 @@ namespace Utils
|
|||
return count;
|
||||
}
|
||||
|
||||
inline
|
||||
char *strsep(char **sp, char *sep)
|
||||
{
|
||||
char *p, *s;
|
||||
|
|
@ -117,6 +116,8 @@ namespace Utils
|
|||
return(s);
|
||||
}
|
||||
|
||||
// @todo Implement delim as const char* (also allow \0 length)
|
||||
inline
|
||||
int str_split(char **list, char *str, const char delim)
|
||||
{
|
||||
size_t splits = str_count(str, (char *) &delim) + 1;
|
||||
|
|
@ -135,16 +136,47 @@ namespace Utils
|
|||
return i;
|
||||
}
|
||||
|
||||
// @todo Implement delim as const char* (also allow \0 length)
|
||||
inline
|
||||
char* str_combine(char **str, size_t size, const char delim)
|
||||
{
|
||||
if (size < 1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t total_size = 0;
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
total_size += strlen(str[i]);
|
||||
}
|
||||
|
||||
// If delim ever becomes a string replace * 1 with * strlen(delimiter)
|
||||
total_size += (size - 1) * 1 + 1;
|
||||
|
||||
char *result = (char *) malloc(total_size * sizeof(char));
|
||||
if (!result) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
strcpy(result, str[0]);
|
||||
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
strcat(result, &delim);
|
||||
strcat(result, str[i]);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
char **values;
|
||||
int *masks;
|
||||
int size;
|
||||
int64_t *masks;
|
||||
size_t size;
|
||||
} text_diff;
|
||||
|
||||
text_diff computeLCSDiff(char **from, int fromSize, char **to, int toSize)
|
||||
{
|
||||
char **diffValues = (char **) malloc(fromSize * toSize * sizeof(char *));
|
||||
int *diffMasks = (int *) calloc(fromSize * toSize, sizeof(int));
|
||||
int64_t *diffMasks = (int64_t *) calloc(fromSize * toSize, sizeof(int64_t));
|
||||
|
||||
int *dm = (int *) calloc((fromSize + 1) * (toSize + 1), sizeof(int));
|
||||
|
||||
|
|
@ -173,7 +205,7 @@ namespace Utils
|
|||
}
|
||||
}
|
||||
|
||||
int diffIndex = 0;
|
||||
size_t diffIndex = 0;
|
||||
|
||||
i = fromSize;
|
||||
j = toSize;
|
||||
|
|
@ -254,7 +286,7 @@ namespace Utils
|
|||
}
|
||||
diffValues = diffValuesT;
|
||||
|
||||
int *diffMasksT = (int *) realloc(diffMasks, diffIndex * sizeof(int));
|
||||
int64_t *diffMasksT = (int64_t *) realloc(diffMasks, diffIndex * sizeof(int64_t));
|
||||
if (!diffMasksT) {
|
||||
free(diffMasks);
|
||||
}
|
||||
|
|
@ -272,6 +304,5 @@ namespace Utils
|
|||
return text_diff{diffValues, diffMasks, diffIndex};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -23,9 +23,7 @@
|
|||
|
||||
#include "FileUtils.h"
|
||||
|
||||
namespace Utils
|
||||
{
|
||||
namespace WebUtils
|
||||
namespace Utils::WebUtils
|
||||
{
|
||||
static bool CURL_SETUP = false;
|
||||
|
||||
|
|
@ -294,6 +292,5 @@ namespace Utils
|
|||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
Loading…
Reference in New Issue
Block a user