diff --git a/CHANGELOG.md b/CHANGELOG.md index aa0ef42ba87dcf92bc82690d837609b5e4a12b67..279c052b6947e2b2e198f5cc8e6d2c3592e0b555 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +* Integer values are 32 bit now. + ### Deprecated ### Removed diff --git a/Makefile b/Makefile index e5d2bc3a6a0dcedeb2f0dd89018a9ef01a2fb4f6..84a07651b80dc6039b4ec8c534e730b84811fb3b 100644 --- a/Makefile +++ b/Makefile @@ -37,5 +37,11 @@ style: conan-install: conan install . -s "compiler.libcxx=libstdc++11" +.PHONY: conan-install + +conan-create: conan create . -s "compiler.libcxx=libstdc++11" -.PHONY: install +.PHONY: conan-create + +conan: conan-install conan-create +.PHONY: conan diff --git a/include/caosdb/entity.h b/include/caosdb/entity.h index 08a7be6b0f6f2b42752ff78f2a004e7196e9e757..f5b5a590306df4526d961f8c9a1aa52ba0066444 100644 --- a/include/caosdb/entity.h +++ b/include/caosdb/entity.h @@ -518,10 +518,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<int64_t> &values) -> StatusCode; + auto SetValue(const std::vector<int32_t> &values) -> StatusCode; auto SetValue(const std::vector<double> &values) -> StatusCode; auto SetValue(const std::vector<bool> &values) -> StatusCode; - auto SetValue(const int64_t value) -> StatusCode; + auto SetValue(const int32_t value) -> StatusCode; auto SetValue(const bool value) -> StatusCode; /** @@ -681,10 +681,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<int64_t> &values) -> StatusCode; + auto SetValue(const std::vector<int32_t> &values) -> StatusCode; auto SetValue(const std::vector<double> &values) -> StatusCode; auto SetValue(const std::vector<bool> &values) -> StatusCode; - auto SetValue(const int64_t value) -> StatusCode; + auto SetValue(const int32_t value) -> StatusCode; auto SetValue(const bool value) -> StatusCode; auto SetUnit(const std::string &unit) -> void; diff --git a/include/ccaosdb.h b/include/ccaosdb.h index e643e0d4fa048495036341ae18556ce8ebf557b7..c35cb6ab8b207b563944533d3b73cf9c04c71ec3 100644 --- a/include/ccaosdb.h +++ b/include/ccaosdb.h @@ -19,6 +19,9 @@ * <https://www.gnu.org/licenses/>. * */ + +#include <cstdint> // for uint32_t + #ifdef __cplusplus extern "C" { #endif @@ -342,11 +345,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, long *out); +int caosdb_entity_entity_get_int_value(caosdb_entity_entity *entity, int32_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, long *out, +int caosdb_entity_entity_get_int_list_value_at(caosdb_entity_entity *entity, int32_t *out, const int index); int caosdb_entity_entity_get_double_list_value_at(caosdb_entity_entity *entity, double *out, const int index); @@ -384,11 +387,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, long *out); +int caosdb_entity_property_get_int_value(caosdb_entity_property *property, int32_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, long *out, +int caosdb_entity_property_get_int_list_value_at(caosdb_entity_property *property, int32_t *out, const int index); int caosdb_entity_property_get_double_list_value_at(caosdb_entity_property *property, double *out, const int index); @@ -426,11 +429,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 long value); +int caosdb_entity_entity_set_int_value(caosdb_entity_entity *entity, const int32_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 long *value, +int caosdb_entity_entity_set_int_list_value(caosdb_entity_entity *entity, const int32_t *value, const int length); int caosdb_entity_entity_set_double_list_value(caosdb_entity_entity *entity, const double *value, const int length); @@ -455,11 +458,11 @@ 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 long value); +int caosdb_entity_property_set_int_value(caosdb_entity_property *property, const int32_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 long *value, +int caosdb_entity_property_set_int_list_value(caosdb_entity_property *property, const int32_t *value, const int length); int caosdb_entity_property_set_double_list_value(caosdb_entity_property *property, const double *value, const int length); diff --git a/proto b/proto index 6f81c44a02b9258293bfb83b4de7831ef8d7c4e9..1857e2fe407810baf18641429f54e5eee7b71e6a 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 6f81c44a02b9258293bfb83b4de7831ef8d7c4e9 +Subproject commit 1857e2fe407810baf18641429f54e5eee7b71e6a diff --git a/src/caosdb/entity.cpp b/src/caosdb/entity.cpp index 3e14a90f9e1ef3f3d53e5bf7141b2063a70c398e..7ab8b9adca21335e7d408b097e249c5826149f35 100644 --- a/src/caosdb/entity.cpp +++ b/src/caosdb/entity.cpp @@ -20,11 +20,13 @@ * */ #include "caosdb/entity.h" -#include "caosdb/data_type.h" // for DataType -#include "caosdb/entity/v1alpha1/main.pb.h" // for Messages +#include "caosdb/data_type.h" // for DataType +#include "caosdb/entity/v1alpha1/main.pb.h" // for Messages #include "caosdb/exceptions.h" -#include "caosdb/protobuf_helper.h" // for get_arena -#include "caosdb/value.h" // for Value +#include "caosdb/logging.h" // for CAOSDB_LOG_TRACE +#include "caosdb/protobuf_helper.h" // for get_arena +#include "caosdb/utility.h" +#include "caosdb/value.h" // for Value #include <boost/algorithm/string.hpp> #include <google/protobuf/arena.h> // for Arena #include <google/protobuf/generated_message_util.h> // for Arena::Create... @@ -130,7 +132,7 @@ auto Property::SetValue(const std::vector<char *> &values) -> StatusCode { return SetValue(Value(values)); } -auto Property::SetValue(const std::vector<int64_t> &values) -> StatusCode { +auto Property::SetValue(const std::vector<int32_t> &values) -> StatusCode { return SetValue(Value(values)); } @@ -142,7 +144,7 @@ auto Property::SetValue(const std::vector<bool> &values) -> StatusCode { return SetValue(Value(values)); } -auto Property::SetValue(const int64_t value) -> StatusCode { return SetValue(Value(value)); } +auto Property::SetValue(const int32_t value) -> StatusCode { return SetValue(Value(value)); } auto Property::SetValue(const bool value) -> StatusCode { return SetValue(Value(value)); } @@ -231,7 +233,7 @@ auto Entity::SetValue(const std::vector<char *> &values) -> StatusCode { return SetValue(Value(values)); } -auto Entity::SetValue(const std::vector<int64_t> &values) -> StatusCode { +auto Entity::SetValue(const std::vector<int32_t> &values) -> StatusCode { return SetValue(Value(values)); } @@ -243,7 +245,7 @@ auto Entity::SetValue(const std::vector<bool> &values) -> StatusCode { return SetValue(Value(values)); } -auto Entity::SetValue(const int64_t value) -> StatusCode { return SetValue(Value(value)); } +auto Entity::SetValue(const int32_t value) -> StatusCode { return SetValue(Value(value)); } auto Entity::SetValue(const bool value) -> StatusCode { return SetValue(Value(value)); } @@ -277,6 +279,7 @@ template <typename E> auto FixValueImpl(E *ent) -> void { // NOLINT const auto &dtype = ent->GetDataType(); const auto &value = ent->GetValue(); auto new_value = Value(); + CAOSDB_LOG_TRACE(logger_name) << "FixValueImpl()\n" << value.ToString(); if (value.IsNull() || !value.IsString()) { // Don't treat NULL and non-string values. return; } @@ -306,9 +309,9 @@ template <typename E> auto FixValueImpl(E *ent) -> void { // NOLINT } new_value = Value(data); } else if (atype == AtomicDataType::INTEGER) { - std::vector<int64_t> data; + std::vector<int32_t> data; for (auto &d : value.AsList()) { - data.push_back(std::stol(d.AsString())); + data.push_back(std::stoi(d.AsString())); } new_value = Value(data); } else if (atype == AtomicDataType::BOOLEAN) { @@ -340,8 +343,12 @@ template <typename E> auto FixValueImpl(E *ent) -> void { // NOLINT atype == AtomicDataType::DATETIME) { return; } + CAOSDB_LOG_TRACE(logger_name) << "AtomicDataType: " + << caosdb::utility::getEnumNameFromValue(atype); if (atype == AtomicDataType::DOUBLE) { - new_value = Value(std::stod(value.AsString())); + CAOSDB_LOG_TRACE(logger_name) << "double: " << value.AsString(); + new_value = Value(std::strtod(value.AsString().c_str(), nullptr)); + CAOSDB_LOG_TRACE(logger_name) << " -> " << new_value.AsDouble(); } else if (atype == AtomicDataType::INTEGER) { new_value = Value(std::stol(value.AsString())); } else if (atype == AtomicDataType::BOOLEAN) { diff --git a/src/caosdb/unary_rpc_handler.cpp b/src/caosdb/unary_rpc_handler.cpp index 14b2971d8b0e693d68f2e9cf35874ba4fd229e86..9a61a534ec30da943f7637d9995a2595acf96804 100644 --- a/src/caosdb/unary_rpc_handler.cpp +++ b/src/caosdb/unary_rpc_handler.cpp @@ -112,7 +112,7 @@ void UnaryRpcHandler::handleCallCompleteState() { switch (status_.error_code()) { case grpc::OK: - CAOSDB_LOG_INFO(logger_name) << "UnaryRpcHandler finished successfully."; + CAOSDB_LOG_TRACE(logger_name) << "UnaryRpcHandler finished successfully."; break; default: auto code(static_cast<StatusCode>(status_.error_code())); diff --git a/src/ccaosdb.cpp b/src/ccaosdb.cpp index bd2cbf662ee2fd88369f5d52ae08160ff9f175af..5e20bf76105ed530e75b8bd3b06943e6aea327f6 100644 --- a/src/ccaosdb.cpp +++ b/src/ccaosdb.cpp @@ -640,7 +640,7 @@ ERROR_RETURN_CODE(GENERIC_ERROR, return 0; }) ERROR_RETURN_CODE(GENERIC_ERROR, - int caosdb_entity_entity_get_int_value(caosdb_entity_entity *entity, long *out), { + int caosdb_entity_entity_get_int_value(caosdb_entity_entity *entity, int32_t *out), { auto *wrapped_entity = WRAPPED_ENTITY_CAST(entity); *out = wrapped_entity->GetValue().AsInteger(); return 0; @@ -665,7 +665,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, - long *out, const int index), + int32_t *out, const int index), { auto *wrapped_entity = WRAPPED_ENTITY_CAST(entity); auto value_list = wrapped_entity->GetValue().AsList(); @@ -894,7 +894,7 @@ CAOSDB_PROPERTY_GET(unit, GetUnit()) ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_entity_property_get_int_value(caosdb_entity_property *property, - long *out), + int32_t *out), { auto *wrapped_property = WRAPPED_PROPERTY_CAST(property); *out = wrapped_property->GetValue().AsInteger(); @@ -920,7 +920,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, - long *out, const int index), + int32_t *out, const int index), { auto *wrapped_property = WRAPPED_PROPERTY_CAST(property); auto value_list = wrapped_property->GetValue().AsList(); @@ -1037,7 +1037,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 long value), + const int32_t value), { auto *wrapped_entity = static_cast<caosdb::entity::Entity *>(entity->wrapped_entity); @@ -1077,11 +1077,11 @@ ERROR_RETURN_CODE(GENERIC_ERROR, ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_entity_entity_set_int_list_value(caosdb_entity_entity *entity, - const long *value, const int length), + const int32_t *value, const int length), { auto *wrapped_entity = static_cast<caosdb::entity::Entity *>(entity->wrapped_entity); - std::vector<long> value_list; + std::vector<int32_t> value_list; for (int i = 0; i < length; i++) { value_list.push_back(value[i]); } @@ -1223,7 +1223,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 long value), + const int32_t value), { auto *wrapped_property = static_cast<caosdb::entity::Property *>(property->wrapped_property); @@ -1263,12 +1263,12 @@ ERROR_RETURN_CODE(GENERIC_ERROR, ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_entity_property_set_int_list_value(caosdb_entity_property *property, - const long *value, + const int32_t *value, const int length), { auto *wrapped_property = static_cast<caosdb::entity::Property *>(property->wrapped_property); - std::vector<long> value_list; + std::vector<int32_t> value_list; for (int i = 0; i < length; i++) { value_list.push_back(value[i]); }