From 78c17d041469803589f4b0b07fb0f1477425c8da Mon Sep 17 00:00:00 2001 From: Timm Fitschen <t.fitschen@indiscale.com> Date: Tue, 31 Aug 2021 17:40:28 +0200 Subject: [PATCH] WIP: return to int64 for integer values --- include/caosdb/entity.h | 8 ++++---- include/caosdb/value.h | 1 - include/ccaosdb.h | 18 +++++++++--------- src/caosdb/entity.cpp | 8 ++++---- src/ccaosdb.cpp | 20 ++++++++++---------- test/test_value.cpp | 4 ++-- 6 files changed, 29 insertions(+), 30 deletions(-) diff --git a/include/caosdb/entity.h b/include/caosdb/entity.h index 3a8f1f9..831200c 100644 --- a/include/caosdb/entity.h +++ b/include/caosdb/entity.h @@ -516,10 +516,10 @@ public: auto SetValue(const double value) -> StatusCode; auto SetValue(const std::vector<std::string> &values) -> StatusCode; auto SetValue(const std::vector<char *> &values) -> StatusCode; - auto SetValue(const std::vector<int32_t> &values) -> StatusCode; + auto SetValue(const std::vector<int64_t> &values) -> StatusCode; auto SetValue(const std::vector<double> &values) -> StatusCode; auto SetValue(const std::vector<bool> &values) -> StatusCode; - auto SetValue(const int32_t value) -> StatusCode; + auto SetValue(const int64_t value) -> StatusCode; auto SetValue(const bool value) -> StatusCode; /** @@ -670,10 +670,10 @@ public: auto SetValue(const double value) -> StatusCode; auto SetValue(const std::vector<std::string> &values) -> StatusCode; auto SetValue(const std::vector<char *> &values) -> StatusCode; - auto SetValue(const std::vector<int32_t> &values) -> StatusCode; + auto SetValue(const std::vector<int64_t> &values) -> StatusCode; auto SetValue(const std::vector<double> &values) -> StatusCode; auto SetValue(const std::vector<bool> &values) -> StatusCode; - auto SetValue(const int32_t value) -> StatusCode; + auto SetValue(const int64_t value) -> StatusCode; auto SetValue(const bool value) -> StatusCode; auto SetUnit(const std::string &unit) -> void; diff --git a/include/caosdb/value.h b/include/caosdb/value.h index 2ec817e..30ee2b1 100644 --- a/include/caosdb/value.h +++ b/include/caosdb/value.h @@ -110,7 +110,6 @@ public: explicit inline Value(int64_t value) : ProtoMessageWrapper<ProtoValue>() { this->wrapped->mutable_scalar_value()->set_integer_value(value); } - explicit inline Value(int value) : Value((int64_t)value) {} explicit inline Value(bool value) : ProtoMessageWrapper<ProtoValue>() { this->wrapped->mutable_scalar_value()->set_boolean_value(value); } diff --git a/include/ccaosdb.h b/include/ccaosdb.h index 38b5d5e..a601895 100644 --- a/include/ccaosdb.h +++ b/include/ccaosdb.h @@ -20,7 +20,7 @@ * */ -#include <cstdint> // for uint32_t +#include <cstdint> // for int64_t #ifdef __cplusplus extern "C" { @@ -347,11 +347,11 @@ int caosdb_entity_entity_get_datatype(caosdb_entity_entity *entity, char **name, bool *is_list); int caosdb_entity_entity_get_unit(caosdb_entity_entity *entity, char **out); -int caosdb_entity_entity_get_int_value(caosdb_entity_entity *entity, int32_t *out); +int caosdb_entity_entity_get_int_value(caosdb_entity_entity *entity, int64_t *out); int caosdb_entity_entity_get_double_value(caosdb_entity_entity *entity, double *out); int caosdb_entity_entity_get_boolean_value(caosdb_entity_entity *entity, bool *out); int caosdb_entity_entity_get_string_value(caosdb_entity_entity *entity, char **out); -int caosdb_entity_entity_get_int_list_value_at(caosdb_entity_entity *entity, int32_t *out, +int caosdb_entity_entity_get_int_list_value_at(caosdb_entity_entity *entity, int64_t *out, const int index); int caosdb_entity_entity_get_double_list_value_at(caosdb_entity_entity *entity, double *out, const int index); @@ -389,11 +389,11 @@ int caosdb_entity_property_get_datatype(caosdb_entity_property *property, char * bool *is_list); int caosdb_entity_property_get_unit(caosdb_entity_property *property, char **out); -int caosdb_entity_property_get_int_value(caosdb_entity_property *property, int32_t *out); +int caosdb_entity_property_get_int_value(caosdb_entity_property *property, int64_t *out); int caosdb_entity_property_get_double_value(caosdb_entity_property *property, double *out); int caosdb_entity_property_get_boolean_value(caosdb_entity_property *property, bool *out); int caosdb_entity_property_get_string_value(caosdb_entity_property *property, char **out); -int caosdb_entity_property_get_int_list_value_at(caosdb_entity_property *property, int32_t *out, +int caosdb_entity_property_get_int_list_value_at(caosdb_entity_property *property, int64_t *out, const int index); int caosdb_entity_property_get_double_list_value_at(caosdb_entity_property *property, double *out, const int index); @@ -431,11 +431,11 @@ int caosdb_entity_entity_set_datatype(caosdb_entity_entity *entity, const char * const bool is_ref, const bool is_list); int caosdb_entity_entity_set_unit(caosdb_entity_entity *entity, const char *unit); // TODO(fspreck) replace by more specific setters -int caosdb_entity_entity_set_int_value(caosdb_entity_entity *entity, const int32_t value); +int caosdb_entity_entity_set_int_value(caosdb_entity_entity *entity, const int64_t value); int caosdb_entity_entity_set_double_value(caosdb_entity_entity *entity, const double value); int caosdb_entity_entity_set_boolean_value(caosdb_entity_entity *entity, const bool value); int caosdb_entity_entity_set_string_value(caosdb_entity_entity *entity, const char *value); -int caosdb_entity_entity_set_int_list_value(caosdb_entity_entity *entity, const int32_t *value, +int caosdb_entity_entity_set_int_list_value(caosdb_entity_entity *entity, const int64_t *value, const int length); int caosdb_entity_entity_set_double_list_value(caosdb_entity_entity *entity, const double *value, const int length); @@ -460,12 +460,12 @@ int caosdb_entity_property_set_datatype(caosdb_entity_property *property, const int caosdb_entity_property_set_importance(caosdb_entity_property *property, const char *importance); int caosdb_entity_property_set_unit(caosdb_entity_property *property, const char *unit); -int caosdb_entity_property_set_int_value(caosdb_entity_property *property, const int32_t value); +int caosdb_entity_property_set_int_value(caosdb_entity_property *property, const int64_t value); int caosdb_entity_property_set_double_value(caosdb_entity_property *property, const double value); int caosdb_entity_property_set_boolean_value(caosdb_entity_property *property, const bool value); int caosdb_entity_property_set_string_value(caosdb_entity_property *property, const char *value); int caosdb_entity_property_set_int_list_value(caosdb_entity_property *property, - const int32_t *value, const int length); + const int64_t *value, const int length); int caosdb_entity_property_set_double_list_value(caosdb_entity_property *property, const double *value, const int length); int caosdb_entity_property_set_boolean_list_value(caosdb_entity_property *property, diff --git a/src/caosdb/entity.cpp b/src/caosdb/entity.cpp index 18c9cb5..55c5936 100644 --- a/src/caosdb/entity.cpp +++ b/src/caosdb/entity.cpp @@ -124,7 +124,7 @@ auto Property::SetValue(const std::vector<char *> &values) -> StatusCode { return SetValue(Value(values)); } -auto Property::SetValue(const std::vector<int32_t> &values) -> StatusCode { +auto Property::SetValue(const std::vector<int64_t> &values) -> StatusCode { return SetValue(Value(values)); } @@ -136,7 +136,7 @@ auto Property::SetValue(const std::vector<bool> &values) -> StatusCode { return SetValue(Value(values)); } -auto Property::SetValue(const int32_t value) -> StatusCode { return SetValue(Value(value)); } +auto Property::SetValue(const int64_t value) -> StatusCode { return SetValue(Value(value)); } auto Property::SetValue(const bool value) -> StatusCode { return SetValue(Value(value)); } @@ -222,7 +222,7 @@ auto Entity::SetValue(const std::vector<char *> &values) -> StatusCode { return SetValue(Value(values)); } -auto Entity::SetValue(const std::vector<int32_t> &values) -> StatusCode { +auto Entity::SetValue(const std::vector<int64_t> &values) -> StatusCode { return SetValue(Value(values)); } @@ -234,7 +234,7 @@ auto Entity::SetValue(const std::vector<bool> &values) -> StatusCode { return SetValue(Value(values)); } -auto Entity::SetValue(const int32_t value) -> StatusCode { return SetValue(Value(value)); } +auto Entity::SetValue(const int64_t value) -> StatusCode { return SetValue(Value(value)); } auto Entity::SetValue(const bool value) -> StatusCode { return SetValue(Value(value)); } diff --git a/src/ccaosdb.cpp b/src/ccaosdb.cpp index b4c7ea1..8145d92 100644 --- a/src/ccaosdb.cpp +++ b/src/ccaosdb.cpp @@ -641,7 +641,7 @@ ERROR_RETURN_CODE(GENERIC_ERROR, }) ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_entity_entity_get_int_value(caosdb_entity_entity *entity, - int32_t *out), + int64_t *out), { auto *wrapped_entity = WRAPPED_ENTITY_CAST(entity); *out = wrapped_entity->GetValue().AsInteger(); @@ -667,7 +667,7 @@ CAOSDB_ENTITY_GET(string_value, GetValue().AsString()) ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_entity_entity_get_int_list_value_at(caosdb_entity_entity *entity, - int32_t *out, const int index), + int64_t *out, const int index), { auto *wrapped_entity = WRAPPED_ENTITY_CAST(entity); auto value_list = wrapped_entity->GetValue().AsList(); @@ -896,7 +896,7 @@ CAOSDB_PROPERTY_GET(unit, GetUnit()) ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_entity_property_get_int_value(caosdb_entity_property *property, - int32_t *out), + int64_t *out), { auto *wrapped_property = WRAPPED_PROPERTY_CAST(property); *out = wrapped_property->GetValue().AsInteger(); @@ -922,7 +922,7 @@ CAOSDB_PROPERTY_GET(string_value, GetValue().AsString()) ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_entity_property_get_int_list_value_at(caosdb_entity_property *property, - int32_t *out, const int index), + int64_t *out, const int index), { auto *wrapped_property = WRAPPED_PROPERTY_CAST(property); auto value_list = wrapped_property->GetValue().AsList(); @@ -1039,7 +1039,7 @@ CAOSDB_ENTITY_SET(unit, unit, wrapped_entity->SetUnit(std::string(unit));) ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_entity_entity_set_int_value(caosdb_entity_entity *entity, - const int32_t value), + const int64_t value), { auto *wrapped_entity = static_cast<caosdb::entity::Entity *>(entity->wrapped_entity); @@ -1079,12 +1079,12 @@ ERROR_RETURN_CODE(GENERIC_ERROR, ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_entity_entity_set_int_list_value(caosdb_entity_entity *entity, - const int32_t *value, + const int64_t *value, const int length), { auto *wrapped_entity = static_cast<caosdb::entity::Entity *>(entity->wrapped_entity); - std::vector<int32_t> value_list; + std::vector<int64_t> value_list; for (int i = 0; i < length; i++) { value_list.push_back(value[i]); } @@ -1226,7 +1226,7 @@ CAOSDB_PROPERTY_SET(unit, unit, wrapped_property->SetUnit(std::string(unit));) ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_entity_property_set_int_value(caosdb_entity_property *property, - const int32_t value), + const int64_t value), { auto *wrapped_property = static_cast<caosdb::entity::Property *>(property->wrapped_property); @@ -1266,12 +1266,12 @@ ERROR_RETURN_CODE(GENERIC_ERROR, ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_entity_property_set_int_list_value(caosdb_entity_property *property, - const int32_t *value, + const int64_t *value, const int length), { auto *wrapped_property = static_cast<caosdb::entity::Property *>(property->wrapped_property); - std::vector<int32_t> value_list; + std::vector<int64_t> value_list; for (int i = 0; i < length; i++) { value_list.push_back(value[i]); } diff --git a/test/test_value.cpp b/test/test_value.cpp index 74d30f0..855d010 100644 --- a/test/test_value.cpp +++ b/test/test_value.cpp @@ -68,7 +68,7 @@ TEST(test_value, test_string) { // Test inequality Value string1("1"); - Value int1(1); + Value int1(static_cast<int64_t>(1)); EXPECT_FALSE(string1 == int1); } @@ -93,7 +93,7 @@ TEST(test_value, test_double) { } TEST(test_value, test_integer) { - Value value(1337); + Value value(static_cast<int64_t>(1337)); EXPECT_FALSE(value.IsNull()); EXPECT_FALSE(value.IsString()); EXPECT_FALSE(value.IsDouble()); -- GitLab