mirror of
https://github.com/Karaka-Management/cOMS.git
synced 2026-02-10 23:58:39 +00:00
continue datamapper implementation
This commit is contained in:
parent
593fbc9f89
commit
bc465ff0a8
29
Application/ApplicationAbstract.h
Normal file
29
Application/ApplicationAbstract.h
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
/**
|
||||||
|
* Karaka
|
||||||
|
*
|
||||||
|
* @package Utils
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link https://jingga.app
|
||||||
|
*/
|
||||||
|
#ifndef APPLICATION_ABSTRACT_H
|
||||||
|
#define APPLICATION_ABSTRACT_H
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "../DataStorage/Database/Connection/ConnectionAbstract.h"
|
||||||
|
#include "../Utils/Parser/Json.h"
|
||||||
|
#include "../Threads/Thread.h"
|
||||||
|
|
||||||
|
namespace Application
|
||||||
|
{
|
||||||
|
typedef struct {
|
||||||
|
DataStorage::Database::ConnectionAbstract *db;
|
||||||
|
nlohmann::json config;
|
||||||
|
Threads::ThreadPool *pool;
|
||||||
|
} ApplicationAbstract;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
59
DataStorage/Database/Mapper/DataMapperFactory.h
Normal file
59
DataStorage/Database/Mapper/DataMapperFactory.h
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
/**
|
||||||
|
* Karaka
|
||||||
|
*
|
||||||
|
* @package Models
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link https://jingga.app
|
||||||
|
*/
|
||||||
|
#ifndef DATASTORAGE_DATBASE_MAPPER_FACTORY_H
|
||||||
|
#define DATASTORAGE_DATBASE_MAPPER_FACTORY_H
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "../Connection/ConnectionAbstract.h"
|
||||||
|
#include "ReadMapper.h"
|
||||||
|
#include "MapperAbstract.h"
|
||||||
|
|
||||||
|
namespace DataStorage
|
||||||
|
{
|
||||||
|
namespace Database
|
||||||
|
{
|
||||||
|
static DataStorage::Database::ConnectionAbstract *db;
|
||||||
|
static char *dateTimeFormat = (char *) "Y-m-d H:i:s";
|
||||||
|
|
||||||
|
struct DataMapperFactory {
|
||||||
|
static ReadMapper *reader(const DataStorage::Database::MapperData *mapper, ConnectionAbstract *db = NULL)
|
||||||
|
{
|
||||||
|
ReadMapper *readMapper = (ReadMapper *) malloc(sizeof(ReadMapper));
|
||||||
|
readMapper->mapper = mapper;
|
||||||
|
readMapper->db = db == NULL ? DataStorage::Database::db : db;
|
||||||
|
|
||||||
|
return readMapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ReadMapper *get(const DataStorage::Database::MapperData *mapper, ConnectionAbstract *db = NULL)
|
||||||
|
{
|
||||||
|
ReadMapper *readMapper = (ReadMapper *) malloc(sizeof(ReadMapper));
|
||||||
|
readMapper->mapper = mapper;
|
||||||
|
readMapper->db = db == NULL ? DataStorage::Database::db : db;
|
||||||
|
|
||||||
|
return readMapper->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
static ReadMapper *getAll(const DataStorage::Database::MapperData *mapper, ConnectionAbstract *db = NULL)
|
||||||
|
{
|
||||||
|
ReadMapper *readMapper = (ReadMapper *) malloc(sizeof(ReadMapper));
|
||||||
|
readMapper->mapper = mapper;
|
||||||
|
readMapper->db = db == NULL ? DataStorage::Database::db : db;
|
||||||
|
|
||||||
|
return readMapper->getAll();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
193
DataStorage/Database/Mapper/DataMapperTypes.h
Normal file
193
DataStorage/Database/Mapper/DataMapperTypes.h
Normal file
|
|
@ -0,0 +1,193 @@
|
||||||
|
/**
|
||||||
|
* Karaka
|
||||||
|
*
|
||||||
|
* @package Models
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link https://jingga.app
|
||||||
|
*/
|
||||||
|
#ifndef DATASTORAGE_DATBASE_MAPPER_TYPES_H
|
||||||
|
#define DATASTORAGE_DATBASE_MAPPER_TYPES_H
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
namespace DataStorage
|
||||||
|
{
|
||||||
|
namespace Database
|
||||||
|
{
|
||||||
|
typedef enum {
|
||||||
|
FIELD_TYPE_INT = 1,
|
||||||
|
FIELD_TYPE_FLOAT = 2,
|
||||||
|
FIELD_TYPE_STRING = 3,
|
||||||
|
FIELD_TYPE_BOOL = 4
|
||||||
|
} FieldType;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const char *name = NULL;
|
||||||
|
size_t size = 0;
|
||||||
|
} ModelStructure;
|
||||||
|
|
||||||
|
void free_ModelStructure(ModelStructure *data)
|
||||||
|
{
|
||||||
|
if (data->name != NULL) {
|
||||||
|
free((void *) data->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const char *name = NULL;
|
||||||
|
int type = FieldType::FIELD_TYPE_INT;
|
||||||
|
const char *internal = NULL;
|
||||||
|
bool readonly = false;
|
||||||
|
bool autocomplete = false;
|
||||||
|
} DataMapperColumn;
|
||||||
|
|
||||||
|
void free_DataMapperColumn(DataMapperColumn *data)
|
||||||
|
{
|
||||||
|
if (data->name != NULL) {
|
||||||
|
free((void *) data->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data->internal != NULL) {
|
||||||
|
free((void *) data->internal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char *member = NULL;
|
||||||
|
char *mapper = NULL;
|
||||||
|
char *external = NULL;
|
||||||
|
char *table = NULL;
|
||||||
|
char *self = NULL;
|
||||||
|
char *column = NULL;
|
||||||
|
bool conditional = false;
|
||||||
|
char *by = NULL;
|
||||||
|
} TableRelation;
|
||||||
|
|
||||||
|
void free_TableRelation(TableRelation *data)
|
||||||
|
{
|
||||||
|
if (data->member != NULL) {
|
||||||
|
free(data->member);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data->mapper != NULL) {
|
||||||
|
free(data->mapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data->external != NULL) {
|
||||||
|
free(data->external);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data->table != NULL) {
|
||||||
|
free(data->table);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data->self != NULL) {
|
||||||
|
free(data->self);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data->column != NULL) {
|
||||||
|
free(data->column);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data->self != NULL) {
|
||||||
|
free(data->self);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data->by != NULL) {
|
||||||
|
free(data->by);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const char *TABLE = NULL;
|
||||||
|
const char *PRIMARYFIELD = NULL;
|
||||||
|
const char *CREATED_AT = NULL;
|
||||||
|
const char *PARENT = NULL;
|
||||||
|
void *MODEL = NULL;
|
||||||
|
|
||||||
|
int MEMBER_COUNT = 0;
|
||||||
|
DataStorage::Database::ModelStructure *MODEL_STRUCTURE = NULL;
|
||||||
|
|
||||||
|
int COLUMN_COUNT = 0;
|
||||||
|
DataStorage::Database::DataMapperColumn *COLUMNS = NULL;
|
||||||
|
|
||||||
|
int OWNS_ONE_COUNT = 0;
|
||||||
|
DataStorage::Database::TableRelation *OWNS_ONE = NULL;
|
||||||
|
|
||||||
|
int HAS_MANY_COUNT = 0;
|
||||||
|
DataStorage::Database::TableRelation *HAS_MANY = NULL;
|
||||||
|
|
||||||
|
int BELONGS_TO_COUNT = 0;
|
||||||
|
DataStorage::Database::TableRelation *BELONGS_TO = NULL;
|
||||||
|
} MapperData;
|
||||||
|
|
||||||
|
void free_MapperData(DataStorage::Database::MapperData *data)
|
||||||
|
{
|
||||||
|
if (data->TABLE != NULL) {
|
||||||
|
free((void *) data->TABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data->PRIMARYFIELD != NULL) {
|
||||||
|
free((void *) data->PRIMARYFIELD);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data->CREATED_AT != NULL) {
|
||||||
|
free((void *) data->CREATED_AT);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data->PARENT != NULL) {
|
||||||
|
free((void *) data->PARENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data->MODEL != NULL) {
|
||||||
|
free(data->MODEL);
|
||||||
|
}
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
if (data->MODEL_STRUCTURE != NULL) {
|
||||||
|
for (i = 0; i < data->MEMBER_COUNT; ++i) {
|
||||||
|
free_ModelStructure(&data->MODEL_STRUCTURE[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(data->MODEL_STRUCTURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data->COLUMNS != NULL) {
|
||||||
|
for (i = 0; data->COLUMN_COUNT; ++i) {
|
||||||
|
free_DataMapperColumn(&data->COLUMNS[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(data->COLUMNS);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data->OWNS_ONE != NULL) {
|
||||||
|
for (i = 0; data->OWNS_ONE_COUNT; ++i) {
|
||||||
|
free_TableRelation(&data->OWNS_ONE[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(data->OWNS_ONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data->HAS_MANY != NULL) {
|
||||||
|
for (i = 0; data->HAS_MANY_COUNT; ++i) {
|
||||||
|
free_TableRelation(&data->HAS_MANY[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(data->HAS_MANY);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data->BELONGS_TO != NULL) {
|
||||||
|
for (i = 0; data->BELONGS_TO_COUNT; ++i) {
|
||||||
|
free_TableRelation(&data->BELONGS_TO[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(data->BELONGS_TO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
93
DataStorage/Database/Mapper/MapperAbstract.h
Normal file
93
DataStorage/Database/Mapper/MapperAbstract.h
Normal file
|
|
@ -0,0 +1,93 @@
|
||||||
|
/**
|
||||||
|
* Karaka
|
||||||
|
*
|
||||||
|
* @package Models
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link https://jingga.app
|
||||||
|
*/
|
||||||
|
#ifndef DATASTORAGE_DATBASE_MAPPER_ABSTRACT_H
|
||||||
|
#define DATASTORAGE_DATBASE_MAPPER_ABSTRACT_H
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "../Connection/ConnectionAbstract.h"
|
||||||
|
#include "DataMapperTypes.h"
|
||||||
|
|
||||||
|
namespace DataStorage
|
||||||
|
{
|
||||||
|
namespace Database
|
||||||
|
{
|
||||||
|
struct MapperAbstract {
|
||||||
|
const DataStorage::Database::MapperData *mapper = NULL;
|
||||||
|
|
||||||
|
const DataStorage::Database::ConnectionAbstract *db = NULL;
|
||||||
|
|
||||||
|
int MEMBERS = 0;
|
||||||
|
|
||||||
|
int COLUMN_COUNT = 0;
|
||||||
|
|
||||||
|
DataStorage::Database::ModelStructure *MODEL_STRUCTURE = NULL;
|
||||||
|
|
||||||
|
char *PRIMARYFIELD = NULL;
|
||||||
|
|
||||||
|
bool AUTOINCREMENT = true;
|
||||||
|
|
||||||
|
char *CREATE_AT = NULL;
|
||||||
|
|
||||||
|
char *TABLE = NULL;
|
||||||
|
|
||||||
|
char *PARENT = NULL;
|
||||||
|
|
||||||
|
char *MODEL = NULL;
|
||||||
|
|
||||||
|
DataStorage::Database::DataMapperColumn *COLUMNS = NULL;
|
||||||
|
|
||||||
|
DataStorage::Database::TableRelation *HAS_MANY = NULL;
|
||||||
|
|
||||||
|
DataStorage::Database::TableRelation *OWNS_ONE = NULL;
|
||||||
|
|
||||||
|
DataStorage::Database::TableRelation *BELONGS_TO = NULL;
|
||||||
|
|
||||||
|
void *address(uintptr_t objPos, char *name)
|
||||||
|
{
|
||||||
|
uintptr_t pos = objPos;
|
||||||
|
for (int i = 0; i < this->MEMBERS; ++i) {
|
||||||
|
if (strcmp(this->MODEL_STRUCTURE[i].name, name) == 0) {
|
||||||
|
return (void *) pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
pos += this->MODEL_STRUCTURE[i].size;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
DataMapperColumn *findByColumnName(char *column)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < this->COLUMN_COUNT; ++i) {
|
||||||
|
if (strcmp(this->COLUMNS[i].name, column) == 0) {
|
||||||
|
return &this->COLUMNS[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
DataMapperColumn *findByMemberName(char *member)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < this->COLUMN_COUNT; ++i) {
|
||||||
|
if (strcmp(this->COLUMNS[i].internal, member) == 0) {
|
||||||
|
return &this->COLUMNS[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
48
DataStorage/Database/Mapper/ReadMapper.h
Normal file
48
DataStorage/Database/Mapper/ReadMapper.h
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
/**
|
||||||
|
* Karaka
|
||||||
|
*
|
||||||
|
* @package Models
|
||||||
|
* @copyright Dennis Eichhorn
|
||||||
|
* @license OMS License 1.0
|
||||||
|
* @version 1.0.0
|
||||||
|
* @link https://jingga.app
|
||||||
|
*/
|
||||||
|
#ifndef DATASTORAGE_DATBASE_MAPPER_READ_H
|
||||||
|
#define DATASTORAGE_DATBASE_MAPPER_READ_H
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "../Connection/ConnectionAbstract.h"
|
||||||
|
#include "DataMapperFactory.h"
|
||||||
|
#include "MapperAbstract.h"
|
||||||
|
|
||||||
|
namespace DataStorage
|
||||||
|
{
|
||||||
|
namespace Database
|
||||||
|
{
|
||||||
|
struct ReadMapper : MapperAbstract {
|
||||||
|
ReadMapper *get()
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReadMapper *getAll()
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReadMapper *where(char *where, void *data)
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *execute()
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -6,30 +6,6 @@
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
/*
|
|
||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2013-2022 Niels Lohmann
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/****************************************************************************\
|
/****************************************************************************\
|
||||||
* Note on documentation: The source files contain links to the online *
|
* Note on documentation: The source files contain links to the online *
|
||||||
* documentation of the public API at https://json.nlohmann.me. This URL *
|
* documentation of the public API at https://json.nlohmann.me. This URL *
|
||||||
|
|
@ -64,6 +40,8 @@ SOFTWARE.
|
||||||
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
// #include <nlohmann/detail/abi_macros.hpp>
|
// #include <nlohmann/detail/abi_macros.hpp>
|
||||||
|
|
@ -2793,8 +2771,7 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||||
// it allows using the detected idiom to retrieve the return type
|
// it allows using the detected idiom to retrieve the return type
|
||||||
// of such an expression
|
// of such an expression
|
||||||
#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \
|
#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \
|
||||||
namespace detail
|
namespace detail { \
|
||||||
{ \
|
|
||||||
using std::std_name; \
|
using std::std_name; \
|
||||||
\
|
\
|
||||||
template<typename... T> \
|
template<typename... T> \
|
||||||
|
|
@ -4192,28 +4169,28 @@ inline std::size_t concat_length()
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
inline std::size_t concat_length(const char* cstr, Args&& ... rest);
|
inline std::size_t concat_length(const char* cstr, const Args& ... rest);
|
||||||
|
|
||||||
template<typename StringType, typename... Args>
|
template<typename StringType, typename... Args>
|
||||||
inline std::size_t concat_length(const StringType& str, Args&& ... rest);
|
inline std::size_t concat_length(const StringType& str, const Args& ... rest);
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
inline std::size_t concat_length(const char /*c*/, Args&& ... rest)
|
inline std::size_t concat_length(const char /*c*/, const Args& ... rest)
|
||||||
{
|
{
|
||||||
return 1 + concat_length(std::forward<Args>(rest)...);
|
return 1 + concat_length(rest...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
inline std::size_t concat_length(const char* cstr, Args&& ... rest)
|
inline std::size_t concat_length(const char* cstr, const Args& ... rest)
|
||||||
{
|
{
|
||||||
// cppcheck-suppress ignoredReturnValue
|
// cppcheck-suppress ignoredReturnValue
|
||||||
return ::strlen(cstr) + concat_length(std::forward<Args>(rest)...);
|
return ::strlen(cstr) + concat_length(rest...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename StringType, typename... Args>
|
template<typename StringType, typename... Args>
|
||||||
inline std::size_t concat_length(const StringType& str, Args&& ... rest)
|
inline std::size_t concat_length(const StringType& str, const Args& ... rest)
|
||||||
{
|
{
|
||||||
return str.size() + concat_length(std::forward<Args>(rest)...);
|
return str.size() + concat_length(rest...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename OutStringType>
|
template<typename OutStringType>
|
||||||
|
|
@ -4304,7 +4281,7 @@ template<typename OutStringType = std::string, typename... Args>
|
||||||
inline OutStringType concat(Args && ... args)
|
inline OutStringType concat(Args && ... args)
|
||||||
{
|
{
|
||||||
OutStringType str;
|
OutStringType str;
|
||||||
str.reserve(concat_length(std::forward<Args>(args)...));
|
str.reserve(concat_length(args...));
|
||||||
concat_into(str, std::forward<Args>(args)...);
|
concat_into(str, std::forward<Args>(args)...);
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
@ -11254,7 +11231,7 @@ class binary_reader
|
||||||
}
|
}
|
||||||
if (is_ndarray) // ndarray dimensional vector can only contain integers, and can not embed another array
|
if (is_ndarray) // ndarray dimensional vector can only contain integers, and can not embed another array
|
||||||
{
|
{
|
||||||
return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, exception_message(input_format, "ndarray dimentional vector is not allowed", "size"), nullptr));
|
return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, exception_message(input_format, "ndarray dimensional vector is not allowed", "size"), nullptr));
|
||||||
}
|
}
|
||||||
std::vector<size_t> dim;
|
std::vector<size_t> dim;
|
||||||
if (JSON_HEDLEY_UNLIKELY(!get_ubjson_ndarray_size(dim)))
|
if (JSON_HEDLEY_UNLIKELY(!get_ubjson_ndarray_size(dim)))
|
||||||
|
|
@ -18872,7 +18849,7 @@ class serializer
|
||||||
: (0xFFu >> type) & (byte);
|
: (0xFFu >> type) & (byte);
|
||||||
|
|
||||||
const std::size_t index = 256u + static_cast<size_t>(state) * 16u + static_cast<size_t>(type);
|
const std::size_t index = 256u + static_cast<size_t>(state) * 16u + static_cast<size_t>(type);
|
||||||
JSON_ASSERT(index < 400);
|
JSON_ASSERT(index < utf8d.size());
|
||||||
state = utf8d[index];
|
state = utf8d[index];
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,7 @@ namespace Utils
|
||||||
char *token;
|
char *token;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
while ((token = strsep(&str, &delim)) != NULL) {
|
while ((token = strsep(&str, (char *) &delim)) != NULL) {
|
||||||
list[i] = (char *) malloc(strlen(token + 1) * sizeof(char));
|
list[i] = (char *) malloc(strlen(token + 1) * sizeof(char));
|
||||||
memcpy(list[i], token, (strlen(token) + 1) * sizeof(char));
|
memcpy(list[i], token, (strlen(token) + 1) * sizeof(char));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user