mirror of
https://github.com/Karaka-Management/cOMS.git
synced 2026-02-16 18:28:42 +00:00
Update code style
This commit is contained in:
parent
b34004c1cb
commit
33b480fbae
|
|
@ -17,10 +17,8 @@
|
||||||
#include "../DatabaseType.h"
|
#include "../DatabaseType.h"
|
||||||
#include "../DatabaseStatus.h"
|
#include "../DatabaseStatus.h"
|
||||||
|
|
||||||
namespace DataStorage
|
namespace DataStorage::Database
|
||||||
{
|
{
|
||||||
namespace Database
|
|
||||||
{
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
size_t rows = 0;
|
size_t rows = 0;
|
||||||
size_t columns = 0;
|
size_t columns = 0;
|
||||||
|
|
@ -56,7 +54,6 @@ namespace DataStorage
|
||||||
return QueryResult();
|
return QueryResult();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -21,10 +21,8 @@
|
||||||
#include "PostgresqlConnection.h"
|
#include "PostgresqlConnection.h"
|
||||||
#include "SQLiteConnection.h"
|
#include "SQLiteConnection.h"
|
||||||
|
|
||||||
namespace DataStorage
|
namespace DataStorage::Database
|
||||||
{
|
{
|
||||||
namespace Database
|
|
||||||
{
|
|
||||||
ConnectionAbstract *create_connection(DbConnectionConfig dbdata)
|
ConnectionAbstract *create_connection(DbConnectionConfig dbdata)
|
||||||
{
|
{
|
||||||
switch (dbdata.db) {
|
switch (dbdata.db) {
|
||||||
|
|
@ -56,7 +54,6 @@ namespace DataStorage
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -15,10 +15,8 @@
|
||||||
|
|
||||||
#include "../DatabaseType.h"
|
#include "../DatabaseType.h"
|
||||||
|
|
||||||
namespace DataStorage
|
namespace DataStorage::Database
|
||||||
{
|
{
|
||||||
namespace Database
|
|
||||||
{
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
DatabaseType db = DatabaseType::UNDEFINED;
|
DatabaseType db = DatabaseType::UNDEFINED;
|
||||||
|
|
||||||
|
|
@ -55,7 +53,6 @@ namespace DataStorage
|
||||||
dbdata->password = NULL;
|
dbdata->password = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -20,10 +20,8 @@
|
||||||
#include "../DatabaseType.h"
|
#include "../DatabaseType.h"
|
||||||
#include "../DatabaseStatus.h"
|
#include "../DatabaseStatus.h"
|
||||||
|
|
||||||
namespace DataStorage
|
namespace DataStorage::Database
|
||||||
{
|
{
|
||||||
namespace Database
|
|
||||||
{
|
|
||||||
struct MysqlConnection : ConnectionAbstract {
|
struct MysqlConnection : ConnectionAbstract {
|
||||||
MysqlConnection(DbConnectionConfig dbdata)
|
MysqlConnection(DbConnectionConfig dbdata)
|
||||||
{
|
{
|
||||||
|
|
@ -144,7 +142,6 @@ namespace DataStorage
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -20,10 +20,8 @@
|
||||||
#include "../DatabaseType.h"
|
#include "../DatabaseType.h"
|
||||||
#include "../DatabaseStatus.h"
|
#include "../DatabaseStatus.h"
|
||||||
|
|
||||||
namespace DataStorage
|
namespace DataStorage::Database
|
||||||
{
|
{
|
||||||
namespace Database
|
|
||||||
{
|
|
||||||
struct PostgresqlConnection : ConnectionAbstract {
|
struct PostgresqlConnection : ConnectionAbstract {
|
||||||
PostgresqlConnection(DbConnectionConfig dbdata)
|
PostgresqlConnection(DbConnectionConfig dbdata)
|
||||||
{
|
{
|
||||||
|
|
@ -138,7 +136,6 @@ namespace DataStorage
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -20,10 +20,8 @@
|
||||||
#include "../DatabaseType.h"
|
#include "../DatabaseType.h"
|
||||||
#include "../DatabaseStatus.h"
|
#include "../DatabaseStatus.h"
|
||||||
|
|
||||||
namespace DataStorage
|
namespace DataStorage::Database
|
||||||
{
|
{
|
||||||
namespace Database
|
|
||||||
{
|
|
||||||
struct SQLiteConnection : ConnectionAbstract {
|
struct SQLiteConnection : ConnectionAbstract {
|
||||||
SQLiteConnection(DbConnectionConfig dbdata)
|
SQLiteConnection(DbConnectionConfig dbdata)
|
||||||
{
|
{
|
||||||
|
|
@ -155,7 +153,6 @@ namespace DataStorage
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -10,10 +10,8 @@
|
||||||
#ifndef DATASTORAGE_DATABASE_STATUS_H
|
#ifndef DATASTORAGE_DATABASE_STATUS_H
|
||||||
#define DATASTORAGE_DATABASE_STATUS_H
|
#define DATASTORAGE_DATABASE_STATUS_H
|
||||||
|
|
||||||
namespace DataStorage
|
namespace DataStorage::Database
|
||||||
{
|
{
|
||||||
namespace Database
|
|
||||||
{
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
OK = 0,
|
OK = 0,
|
||||||
MISSING_DATABASE = 1,
|
MISSING_DATABASE = 1,
|
||||||
|
|
@ -22,7 +20,6 @@ namespace DataStorage
|
||||||
READONLY = 4,
|
READONLY = 4,
|
||||||
CLOSED = 5
|
CLOSED = 5
|
||||||
} DatabaseStatus;
|
} DatabaseStatus;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -12,10 +12,8 @@
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
namespace DataStorage
|
namespace DataStorage::Database
|
||||||
{
|
{
|
||||||
namespace Database
|
|
||||||
{
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
MYSQL = 1,
|
MYSQL = 1,
|
||||||
SQLITE = 2,
|
SQLITE = 2,
|
||||||
|
|
@ -38,7 +36,6 @@ namespace DataStorage
|
||||||
|
|
||||||
return DatabaseType::UNDEFINED;
|
return DatabaseType::UNDEFINED;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -18,10 +18,8 @@
|
||||||
#include "ReadMapper.h"
|
#include "ReadMapper.h"
|
||||||
#include "MapperAbstract.h"
|
#include "MapperAbstract.h"
|
||||||
|
|
||||||
namespace DataStorage
|
namespace DataStorage::Database
|
||||||
{
|
{
|
||||||
namespace Database
|
|
||||||
{
|
|
||||||
static DataStorage::Database::ConnectionAbstract *db;
|
static DataStorage::Database::ConnectionAbstract *db;
|
||||||
static const char *dateTimeFormat = "Y-m-d H:i:s";
|
static const char *dateTimeFormat = "Y-m-d H:i:s";
|
||||||
|
|
||||||
|
|
@ -53,7 +51,6 @@ namespace DataStorage
|
||||||
return readMapper->getAll();
|
return readMapper->getAll();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,8 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
namespace DataStorage
|
namespace DataStorage::Database
|
||||||
{
|
{
|
||||||
namespace Database
|
|
||||||
{
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
MAPPER_DEFAULT = 0,
|
MAPPER_DEFAULT = 0,
|
||||||
MAPPER_GET = 1,
|
MAPPER_GET = 1,
|
||||||
|
|
@ -216,7 +214,6 @@ namespace DataStorage
|
||||||
free(data->BELONGS_TO);
|
free(data->BELONGS_TO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -12,14 +12,13 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "../Connection/ConnectionAbstract.h"
|
#include "../Connection/ConnectionAbstract.h"
|
||||||
#include "DataMapperTypes.h"
|
#include "DataMapperTypes.h"
|
||||||
|
|
||||||
namespace DataStorage
|
namespace DataStorage::Database
|
||||||
{
|
{
|
||||||
namespace Database
|
|
||||||
{
|
|
||||||
struct MapperAbstract {
|
struct MapperAbstract {
|
||||||
const DataStorage::Database::MapperData *mapper = NULL;
|
const DataStorage::Database::MapperData *mapper = NULL;
|
||||||
|
|
||||||
|
|
@ -101,7 +100,6 @@ namespace DataStorage
|
||||||
|
|
||||||
virtual void *execute(void *options = NULL);
|
virtual void *execute(void *options = NULL);
|
||||||
};
|
};
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,8 @@
|
||||||
#include "DataMapperFactory.h"
|
#include "DataMapperFactory.h"
|
||||||
#include "MapperAbstract.h"
|
#include "MapperAbstract.h"
|
||||||
|
|
||||||
namespace DataStorage
|
namespace DataStorage::Database
|
||||||
{
|
{
|
||||||
namespace Database
|
|
||||||
{
|
|
||||||
struct ReadMapper : MapperAbstract {
|
struct ReadMapper : MapperAbstract {
|
||||||
ReadMapper *get()
|
ReadMapper *get()
|
||||||
{
|
{
|
||||||
|
|
@ -64,7 +62,6 @@ namespace DataStorage
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,8 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
namespace DataStorage
|
namespace DataStorage::Database
|
||||||
{
|
{
|
||||||
namespace Database
|
|
||||||
{
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *name;
|
char *name;
|
||||||
char *type;
|
char *type;
|
||||||
|
|
@ -56,7 +54,6 @@ namespace DataStorage
|
||||||
field->foreignKey = NULL;
|
field->foreignKey = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -15,10 +15,8 @@
|
||||||
|
|
||||||
#include "DbField.h"
|
#include "DbField.h"
|
||||||
|
|
||||||
namespace DataStorage
|
namespace DataStorage::Database
|
||||||
{
|
{
|
||||||
namespace Database
|
|
||||||
{
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *name;
|
char *name;
|
||||||
DbField *fields;
|
DbField *fields;
|
||||||
|
|
@ -41,7 +39,6 @@ namespace DataStorage
|
||||||
schema->fields = NULL;
|
schema->fields = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -2,6 +2,8 @@
|
||||||
#define HASH_MD5_H
|
#define HASH_MD5_H
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
// https://www.rfc-editor.org/rfc/rfc1321
|
// https://www.rfc-editor.org/rfc/rfc1321
|
||||||
|
|
||||||
|
|
@ -37,7 +39,7 @@ namespace Hash {
|
||||||
uint32_t a, b, c, d;
|
uint32_t a, b, c, d;
|
||||||
uint32_t aa, bb, cc, dd;
|
uint32_t aa, bb, cc, dd;
|
||||||
|
|
||||||
ptr = data;
|
ptr = (const unsigned char *) data;
|
||||||
|
|
||||||
a = ctx->a;
|
a = ctx->a;
|
||||||
b = ctx->b;
|
b = ctx->b;
|
||||||
|
|
|
||||||
|
|
@ -116,6 +116,7 @@
|
||||||
#define HASH_MEOW_H
|
#define HASH_MEOW_H
|
||||||
|
|
||||||
// #include <immintrin.h>
|
// #include <immintrin.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#if !defined(meow_u8)
|
#if !defined(meow_u8)
|
||||||
#define MEOW_HASH_VERSION 5
|
#define MEOW_HASH_VERSION 5
|
||||||
|
|
@ -199,10 +200,8 @@
|
||||||
pxor(r2, r3)
|
pxor(r2, r3)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Hash
|
namespace Hash::Meow
|
||||||
{
|
{
|
||||||
namespace Meow
|
|
||||||
{
|
|
||||||
#if MEOW_DUMP
|
#if MEOW_DUMP
|
||||||
struct meow_dump
|
struct meow_dump
|
||||||
{
|
{
|
||||||
|
|
@ -739,7 +738,6 @@ namespace Hash
|
||||||
|
|
||||||
return (const char *) str;
|
return (const char *) str;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef INSTRUCTION_REORDER_BARRIER
|
#undef INSTRUCTION_REORDER_BARRIER
|
||||||
|
|
|
||||||
|
|
@ -200,7 +200,7 @@ void sha_256_write(struct Sha_256 *sha_256, const void *data, size_t len)
|
||||||
{
|
{
|
||||||
sha_256->total_len += len;
|
sha_256->total_len += len;
|
||||||
|
|
||||||
const uint8_t *p = data;
|
const uint8_t *p = (uint8_t *) data;
|
||||||
|
|
||||||
while (len > 0) {
|
while (len > 0) {
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,8 @@
|
||||||
#include <opencv2/opencv.hpp>
|
#include <opencv2/opencv.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace Image
|
namespace Image::BillDetection
|
||||||
{
|
{
|
||||||
namespace BillDetection
|
|
||||||
{
|
|
||||||
cv::Mat highlightBill(cv::Mat in)
|
cv::Mat highlightBill(cv::Mat in)
|
||||||
{
|
{
|
||||||
cv::Mat gray;
|
cv::Mat gray;
|
||||||
|
|
@ -75,7 +73,6 @@ namespace Image
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -13,10 +13,8 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
namespace Image
|
namespace Image::ImageUtils
|
||||||
{
|
{
|
||||||
namespace ImageUtils
|
|
||||||
{
|
|
||||||
inline
|
inline
|
||||||
float lightnessFromRgb(int r, int g, int b)
|
float lightnessFromRgb(int r, int g, int b)
|
||||||
{
|
{
|
||||||
|
|
@ -33,17 +31,6 @@ namespace Image
|
||||||
|
|
||||||
return lStar / 100.0;
|
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
|
#endif
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
#include "ImageUtils.h"
|
#include "ImageUtils.h"
|
||||||
#include "../Utils/MathUtils.h"
|
#include "../Utils/MathUtils.h"
|
||||||
|
|
||||||
namespace Image
|
namespace Image::Kernel
|
||||||
{
|
{
|
||||||
const float KERNEL_RIDGE_1[3][3] = {
|
const float KERNEL_RIDGE_1[3][3] = {
|
||||||
{0.0, -1.0, 0.0},
|
{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},
|
{-1.0 / 256.0, -4.0 / 256.0, -6.0 / 256.0, -4.0 / 256.0, -1.0 / 256.0},
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace Kernel
|
|
||||||
{
|
|
||||||
inline
|
inline
|
||||||
cv::Mat convolve(cv::Mat in, const float kernel[][3])
|
cv::Mat convolve(cv::Mat in, const float kernel[][3])
|
||||||
{
|
{
|
||||||
|
|
@ -75,7 +73,6 @@ namespace Image
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -16,10 +16,8 @@
|
||||||
|
|
||||||
#include "../Utils/MathUtils.h"
|
#include "../Utils/MathUtils.h"
|
||||||
|
|
||||||
namespace Image
|
namespace Image::Skew
|
||||||
{
|
{
|
||||||
namespace Skew
|
|
||||||
{
|
|
||||||
cv::Mat deskewHoughLines(cv::Mat in, int maxDegree = 45)
|
cv::Mat deskewHoughLines(cv::Mat in, int maxDegree = 45)
|
||||||
{
|
{
|
||||||
cv::Size dim = in.size();
|
cv::Size dim = in.size();
|
||||||
|
|
@ -87,7 +85,6 @@ namespace Image
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -16,10 +16,8 @@
|
||||||
#include "ImageUtils.h"
|
#include "ImageUtils.h"
|
||||||
#include "../Utils/MathUtils.h"
|
#include "../Utils/MathUtils.h"
|
||||||
|
|
||||||
namespace Image
|
namespace Image::Thresholding
|
||||||
{
|
{
|
||||||
namespace Thresholding
|
|
||||||
{
|
|
||||||
cv::Mat integralThresholding(cv::Mat in)
|
cv::Mat integralThresholding(cv::Mat in)
|
||||||
{
|
{
|
||||||
cv::Size dim = in.size();
|
cv::Size dim = in.size();
|
||||||
|
|
@ -75,7 +73,6 @@ namespace Image
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -16,10 +16,8 @@
|
||||||
|
|
||||||
#include "../Hash/MeowHash.h"
|
#include "../Hash/MeowHash.h"
|
||||||
|
|
||||||
namespace Stdlib
|
namespace Stdlib::HashTable
|
||||||
{
|
{
|
||||||
namespace HashTable
|
|
||||||
{
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char *key;
|
const char *key;
|
||||||
void *value;
|
void *value;
|
||||||
|
|
@ -215,7 +213,6 @@ namespace Stdlib
|
||||||
|
|
||||||
free(table->entries);
|
free(table->entries);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -48,9 +48,7 @@ namespace Utils
|
||||||
|
|
||||||
if (pos != NULL) {
|
if (pos != NULL) {
|
||||||
memcpy(dir, arg, (pos - arg) * sizeof(char));
|
memcpy(dir, arg, (pos - arg) * sizeof(char));
|
||||||
|
|
||||||
chdir(dir);
|
chdir(dir);
|
||||||
|
|
||||||
free(dir);
|
free(dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,8 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
namespace Utils
|
namespace Utils::ArraySort
|
||||||
{
|
{
|
||||||
namespace ArraySort
|
|
||||||
{
|
|
||||||
inline
|
inline
|
||||||
void reverse_int(int64_t *arr, size_t size)
|
void reverse_int(int64_t *arr, size_t size)
|
||||||
{
|
{
|
||||||
|
|
@ -56,7 +54,6 @@ namespace Utils
|
||||||
arr[high] = tmp;
|
arr[high] = tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -16,10 +16,8 @@
|
||||||
|
|
||||||
#include "StringUtils.h"
|
#include "StringUtils.h"
|
||||||
|
|
||||||
namespace Utils
|
namespace Utils::ArrayUtils
|
||||||
{
|
{
|
||||||
namespace ArrayUtils
|
|
||||||
{
|
|
||||||
inline
|
inline
|
||||||
char* get_arg(const char *id, char **argv, size_t size)
|
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) {
|
for (size_t i = 0; i < size1; ++i) {
|
||||||
merged[i] = (char*) malloc((strlen(arr1[i]) + 1) * sizeof(char));
|
merged[i] = (char*) malloc((strlen(array1[i]) + 1) * sizeof(char));
|
||||||
strcpy(merged[i], arr1[i]);
|
strcpy(merged[i], array1[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < size2; ++i) {
|
for (size_t i = 0; i < size2; ++i) {
|
||||||
merged[i] = (char*) malloc((strlen(arr2[i]) + 1) * sizeof(char));
|
merged[i] = (char*) malloc((strlen(array2[i]) + 1) * sizeof(char));
|
||||||
strcpy(merged[i], arr2[i]);
|
strcpy(merged[i], array2[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return merged;
|
return merged;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#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,10 +23,8 @@
|
||||||
|
|
||||||
#include "OSWrapper.h"
|
#include "OSWrapper.h"
|
||||||
|
|
||||||
namespace Utils
|
namespace Utils::FileUtils
|
||||||
{
|
{
|
||||||
namespace FileUtils
|
|
||||||
{
|
|
||||||
inline
|
inline
|
||||||
bool file_exists (const char *filename)
|
bool file_exists (const char *filename)
|
||||||
{
|
{
|
||||||
|
|
@ -128,7 +126,6 @@ namespace Utils
|
||||||
|
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -14,12 +14,8 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
namespace Utils
|
namespace Utils::Rng::StringUtils
|
||||||
{
|
{
|
||||||
namespace Rng
|
|
||||||
{
|
|
||||||
namespace StringUtils
|
|
||||||
{
|
|
||||||
inline
|
inline
|
||||||
char* generate_string(
|
char* generate_string(
|
||||||
size_t min = 10, size_t max = 10,
|
size_t min = 10, size_t max = 10,
|
||||||
|
|
@ -38,6 +34,6 @@ namespace Utils
|
||||||
|
|
||||||
return randomString;
|
return randomString;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -17,10 +17,8 @@
|
||||||
#include "MathUtils.h"
|
#include "MathUtils.h"
|
||||||
#include "ArraySort.h"
|
#include "ArraySort.h"
|
||||||
|
|
||||||
namespace Utils
|
namespace Utils::StringUtils
|
||||||
{
|
{
|
||||||
namespace StringUtils
|
|
||||||
{
|
|
||||||
inline
|
inline
|
||||||
char *search_replace(const char *haystack, const char *needle, const char *replace)
|
char *search_replace(const char *haystack, const char *needle, const char *replace)
|
||||||
{
|
{
|
||||||
|
|
@ -97,6 +95,7 @@ namespace Utils
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
char *strsep(char **sp, char *sep)
|
char *strsep(char **sp, char *sep)
|
||||||
{
|
{
|
||||||
char *p, *s;
|
char *p, *s;
|
||||||
|
|
@ -117,6 +116,8 @@ namespace Utils
|
||||||
return(s);
|
return(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @todo Implement delim as const char* (also allow \0 length)
|
||||||
|
inline
|
||||||
int str_split(char **list, char *str, const char delim)
|
int str_split(char **list, char *str, const char delim)
|
||||||
{
|
{
|
||||||
size_t splits = str_count(str, (char *) &delim) + 1;
|
size_t splits = str_count(str, (char *) &delim) + 1;
|
||||||
|
|
@ -135,16 +136,47 @@ namespace Utils
|
||||||
return i;
|
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 {
|
typedef struct {
|
||||||
char **values;
|
char **values;
|
||||||
int *masks;
|
int64_t *masks;
|
||||||
int size;
|
size_t size;
|
||||||
} text_diff;
|
} text_diff;
|
||||||
|
|
||||||
text_diff computeLCSDiff(char **from, int fromSize, char **to, int toSize)
|
text_diff computeLCSDiff(char **from, int fromSize, char **to, int toSize)
|
||||||
{
|
{
|
||||||
char **diffValues = (char **) malloc(fromSize * toSize * sizeof(char *));
|
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));
|
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;
|
i = fromSize;
|
||||||
j = toSize;
|
j = toSize;
|
||||||
|
|
@ -254,7 +286,7 @@ namespace Utils
|
||||||
}
|
}
|
||||||
diffValues = diffValuesT;
|
diffValues = diffValuesT;
|
||||||
|
|
||||||
int *diffMasksT = (int *) realloc(diffMasks, diffIndex * sizeof(int));
|
int64_t *diffMasksT = (int64_t *) realloc(diffMasks, diffIndex * sizeof(int64_t));
|
||||||
if (!diffMasksT) {
|
if (!diffMasksT) {
|
||||||
free(diffMasks);
|
free(diffMasks);
|
||||||
}
|
}
|
||||||
|
|
@ -271,7 +303,6 @@ namespace Utils
|
||||||
|
|
||||||
return text_diff{diffValues, diffMasks, diffIndex};
|
return text_diff{diffValues, diffMasks, diffIndex};
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -23,10 +23,8 @@
|
||||||
|
|
||||||
#include "FileUtils.h"
|
#include "FileUtils.h"
|
||||||
|
|
||||||
namespace Utils
|
namespace Utils::WebUtils
|
||||||
{
|
{
|
||||||
namespace WebUtils
|
|
||||||
{
|
|
||||||
static bool CURL_SETUP = false;
|
static bool CURL_SETUP = false;
|
||||||
|
|
||||||
inline
|
inline
|
||||||
|
|
@ -293,7 +291,6 @@ namespace Utils
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Loading…
Reference in New Issue
Block a user