Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
Loading items

Target

Select target project
  • caosdb/src/caosdb-cpplib
1 result
Select Git revision
Loading items
Show changes
Commits on Source (5)
......@@ -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
......
......@@ -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
......@@ -50,7 +50,7 @@ as compiler. We use [cmake](https://cmake.org/download/) as build tool.
### Creating a Local Conan Package ##
Building and installing libcaosdb with Conan is just a single command: `make conan-install`
Building and installing libcaosdb with Conan is just a single command: `make conan`
For MacOS, you probably should adjust the option as mentioned above.
......
......@@ -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;
......
......@@ -366,8 +366,8 @@ public:
[[nodiscard]] inline auto GetResultSet() const noexcept -> const ResultSet & {
if (!this->result_set) {
this->result_set = std::make_unique<MultiResultSet>(
std::move(std::vector<std::unique_ptr<Entity>>()));
this->result_set =
std::make_unique<MultiResultSet>(std::move(std::vector<std::unique_ptr<Entity>>()));
}
return *(this->result_set.get());
}
......
......@@ -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,12 +458,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 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,
const int length);
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);
int caosdb_entity_property_set_boolean_list_value(caosdb_entity_property *property,
......
Subproject commit 6f81c44a02b9258293bfb83b4de7831ef8d7c4e9
Subproject commit 1857e2fe407810baf18641429f54e5eee7b71e6a
......@@ -23,7 +23,9 @@
#include "caosdb/data_type.h" // for DataType
#include "caosdb/entity/v1alpha1/main.pb.h" // for Messages
#include "caosdb/exceptions.h"
#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
......@@ -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) {
......
......@@ -640,7 +640,9 @@ 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 +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,
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 +896,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 +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,
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 +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 long value),
const int32_t value),
{
auto *wrapped_entity =
static_cast<caosdb::entity::Entity *>(entity->wrapped_entity);
......@@ -1077,11 +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 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 +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 long value),
const int32_t value),
{
auto *wrapped_property =
static_cast<caosdb::entity::Property *>(property->wrapped_property);
......@@ -1263,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 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]);
}
......