Skip to content

Commit

Permalink
Merge pull request #28 from jespa007/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
jespa007 authored Aug 30, 2023
2 parents 0b71cdc + efaba73 commit 4205b1b
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 27 deletions.
18 changes: 18 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@


----------------------------
Date: 02/08/2023
Version: 2.3.3

- [x] deserialize_exception : Save line and description

----------------------------
Date: 02/08/2023
Version: 2.3.2

- [x] Change ArrayJsonVarNumber to ArrayNumberJsonVar

----------------------------
Date: 6/07/2023
Version: 2.3.1

- [x] Fix include directory for linux

----------------------------
Date: 8/06/2023
Version: 2.3.0
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ else()
message("-- Memmanager: -fsanitize NOT supported")
endif()
else()
message("-- Memmanager: OFF ($ENV{EIPM_DEVELOP_LIBS_CPP}/memmgr not exist)")
message("-- Memmanager: OFF (${PROJECT_SOURCE_DIR}/../../memmgr not exist)")
endif()
endif()

Expand Down
23 changes: 17 additions & 6 deletions src/deserialize_exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,38 @@ namespace zetjsoncpp {

class deserialize_exception: public std::exception
{
std::string error_description;

std::string description;
int line;
std::string file;
char what_msg[4096];
public:

deserialize_exception(const char * _file, int _line, const std::string & _error_description){
deserialize_exception(const char * _file, int _line, const std::string & _description){

memset(what_msg,0,sizeof(what_msg));
error_description=_error_description;
description=_description;
line = _line;

if(_file != NULL && *_file != 0){
sprintf(what_msg,"[file:%s line:%i] %s",_file, _line, (char *)error_description.c_str());
file=_file;
sprintf(what_msg,"[file:%s line:%i] %s",_file, _line, (char *)description.c_str());
}else{
sprintf(what_msg,"[line:%i] %s",_line,(char *)error_description.c_str());
sprintf(what_msg,"[line:%i] %s",_line,(char *)description.c_str());
}
}

virtual const char* what() const throw()
{
return (const char *)what_msg;
}

int getLine(){
return line;
}

const std::string & getDescription(){
return description;
}
};
}

12 changes: 6 additions & 6 deletions src/jsonvar/ArrayNumberJsonVar.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ namespace zetjsoncpp{

// ARRAY FLOAT
template<char... _T_NAME>
class ArrayJsonVarNumber : public NamedJsonVar<_T_NAME...>, public ArrayJsonVar<NumberJsonVar<>> {
class ArrayNumberJsonVar : public NamedJsonVar<_T_NAME...>, public ArrayJsonVar<NumberJsonVar<>> {

public:
//_T_NAME name;
ArrayJsonVarNumber() {
ArrayNumberJsonVar() {
init();
}

ArrayJsonVarNumber(const std::vector<float> & _vec_numbers) {
ArrayNumberJsonVar(const std::vector<float> & _vec_numbers) {
init();
copy(_vec_numbers);
}


ArrayJsonVarNumber<> & operator=(const std::vector<float> & _vec_numbers){
ArrayNumberJsonVar<> & operator=(const std::vector<float> & _vec_numbers){
copy(_vec_numbers);
return *this;
}
Expand Down Expand Up @@ -50,7 +50,7 @@ namespace zetjsoncpp{
return shortBuf;
}

virtual ~ArrayJsonVarNumber() {
virtual ~ArrayNumberJsonVar() {
}

private:
Expand All @@ -63,7 +63,7 @@ namespace zetjsoncpp{

void init(){
this->__zj_type__ = JsonVarType::JSON_VAR_TYPE_VECTOR_OF_NUMBERS;
this->__zj_size_data__ = sizeof(ArrayJsonVarNumber<_T_NAME...>);
this->__zj_size_data__ = sizeof(ArrayNumberJsonVar<_T_NAME...>);
}
};
}
2 changes: 1 addition & 1 deletion src/jsonvar/JsonVar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace zetjsoncpp {

case JSON_VAR_TYPE_VECTOR_OF_BOOLEANS: return "ArrayBooleanJsonVar";
//case ARRAY_INT32_TYPE: return "ARRAY INT32 TYPE";
case JSON_VAR_TYPE_VECTOR_OF_NUMBERS: return "ArrayJsonVarNumber";
case JSON_VAR_TYPE_VECTOR_OF_NUMBERS: return "ArrayNumberJsonVar";
case JSON_VAR_TYPE_VECTOR_OF_STRINGS: return "ArrayStringJsonVar";
case JSON_VAR_TYPE_VECTOR_OF_OBJECTS: return "ArrayObjectJsonVar";

Expand Down
4 changes: 2 additions & 2 deletions src/jsonvar/JsonVar.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
#define ZJ_CAST_JSON_VAR_NUMBER (zetjsoncpp::NumberJsonVar<> *)
#define ZJ_CAST_JSON_VAR_OBJECT (zetjsoncpp::ObjectJsonVar<> *)
#define ZJ_CAST_JSON_VAR_VECTOR_OF_BOOLEANS (zetjsoncpp::ArrayBooleanJsonVar<> *)
#define ZJ_CAST_JSON_VAR_VECTOR_OF_NUMBERS (zetjsoncpp::ArrayJsonVarNumber<> *)
#define ZJ_CAST_JSON_VAR_VECTOR_OF_NUMBERS (zetjsoncpp::ArrayNumberJsonVar<> *)
#define ZJ_CAST_JSON_VAR_VECTOR_OF_STRINGS (zetjsoncpp::ArrayStringJsonVar<> *)
#define ZJ_CAST_JSON_VAR_VECTOR_OF_OBJECTS (zetjsoncpp::ArrayObjectJsonVar<> *)
#define ZJ_CAST_JSON_VAR_MAP_OF_BOOLEANS (zetjsoncpp::MapBooleanJsonVar<> *)
Expand All @@ -86,7 +86,7 @@
#define ZJ_VAR_OBJECT(type,name) zetjsoncpp::ObjectJsonVar<type,ZJ_CONST_CHAR(#name)> name

#define ZJ_VAR_VECTOR_BOOLEAN(name) zetjsoncpp::ArrayBooleanJsonVar<ZJ_CONST_CHAR(#name)> name
#define ZJ_VAR_VECTOR_NUMBER(name) zetjsoncpp::ArrayJsonVarNumber<ZJ_CONST_CHAR(#name)> name
#define ZJ_VAR_VECTOR_NUMBER(name) zetjsoncpp::ArrayNumberJsonVar<ZJ_CONST_CHAR(#name)> name
#define ZJ_VAR_VECTOR_STRING(name) zetjsoncpp::ArrayStringJsonVar<ZJ_CONST_CHAR(#name)> name
#define ZJ_VAR_VECTOR_OBJECT(type,name) zetjsoncpp::ArrayObjectJsonVar<type,ZJ_CONST_CHAR(#name)> name

Expand Down
2 changes: 1 addition & 1 deletion src/jsonvar/MapNumberJsonVar.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace zetjsoncpp{
}


ArrayJsonVarNumber<> & operator=(const std::map<std::string,float> & _map_numbers){
ArrayNumberJsonVar<> & operator=(const std::map<std::string,float> & _map_numbers){
copy(_map_numbers);
return *this;
}
Expand Down
8 changes: 4 additions & 4 deletions src/zetjsoncpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

#define ZETJSONCPP_VERSION_MAJOR 2
#define ZETJSONCPP_VERSION_MINOR 3
#define ZETJSONCPP_VERSION_PATCH 0
#define ZETJSONCPP_VERSION_PATCH 3

#ifdef __MEMMANAGER__
#include "memmgr.h"
Expand All @@ -36,9 +36,9 @@
#define ZJ_UNUSUED_PARAM(x) ((void)(x))
#define ZJ_UNUSUED_2PARAMS(x1,x2) ((void)(x1),(void)(x2))

#include "utils\file_utils.h"
#include "utils\path_utils.h"
#include "utils\string_utils.h"
#include "utils/file_utils.h"
#include "utils/path_utils.h"
#include "utils/string_utils.h"
#include "deserialize_exception.h"
#include "jsonvar/JsonVar.h"

Expand Down
4 changes: 2 additions & 2 deletions src/zetjsoncpp_serializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,9 @@ namespace zetjsoncpp{
);
break;
case JSON_VAR_TYPE_VECTOR_OF_NUMBERS:
serialize_json_var_vector<ArrayJsonVarNumber<>>(
serialize_json_var_vector<ArrayNumberJsonVar<>>(
_str_result
,(ArrayJsonVarNumber<> *)_json_var
,(ArrayNumberJsonVar<> *)_json_var
,_ident
,_minimized
,_discard_non_serialized
Expand Down
2 changes: 1 addition & 1 deletion test/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ int main(int argc, char *argv[]){

std::cout << std::endl << "3. Testing json vector primitives..."<< std::endl<< std::endl;

auto v1=zetjsoncpp::deserialize<zetjsoncpp::ArrayJsonVarNumber<>>("[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]");
auto v1=zetjsoncpp::deserialize<zetjsoncpp::ArrayNumberJsonVar<>>("[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]");
std::cout <<"v1="<< zetjsoncpp::serialize(v1)<< std::endl;

auto v2=zetjsoncpp::deserialize<zetjsoncpp::ArrayStringJsonVar<>>("[\"string_1\",\"string_2\",\"string_3\",\"string_5\"]");
Expand Down
2 changes: 1 addition & 1 deletion test/test_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ typedef struct{
channels;

// Vector of numbers data
zetjsoncpp::ArrayJsonVarNumber<ZJ_CONST_CHAR("data")>
zetjsoncpp::ArrayNumberJsonVar<ZJ_CONST_CHAR("data")>
data;
}Interpolation;

Expand Down
4 changes: 2 additions & 2 deletions test/test_number.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ void test_json_var_number(){
,{"id_3",2.5}
};

zetjsoncpp::ArrayJsonVarNumber<> jvn1=v1;
zetjsoncpp::ArrayJsonVarNumber<> jvn2=v2;
zetjsoncpp::ArrayNumberJsonVar<> jvn1=v1;
zetjsoncpp::ArrayNumberJsonVar<> jvn2=v2;
zetjsoncpp::MapNumberJsonVar<> jmn1=m1;
size_t len=v1.size();

Expand Down

0 comments on commit 4205b1b

Please sign in to comment.