Skip to content
Snippets Groups Projects

ENH: Add retrieval and queries to Extern C interface

Merged Florian Spreckelsen requested to merge f-extended-c into f-files
6 files
+ 41
41
Compare changes
  • Side-by-side
  • Inline
Files
6
+ 13
13
@@ -43,11 +43,11 @@
#include <google/protobuf/message.h> // for RepeatedPtrField
#include <google/protobuf/util/json_util.h> // for MessageToJson...
#include <iosfwd> // for streamsize
#include <iterator> // for iterator, output_iterato...
#include <map> // for map
#include <random> // for mt19937, rand...
#include <stdexcept> // for out_of_range
#include <string> // for string, basic...
#include <iterator> // for iterator, output_iterato...
#include <map> // for map
#include <random> // for mt19937, rand...
#include <stdexcept> // for out_of_range
#include <string> // for string, basic...
namespace caosdb::entity {
using boost::filesystem::exists;
@@ -58,10 +58,10 @@ using ProtoProperty = caosdb::entity::v1alpha1::Property;
using ProtoEntity = caosdb::entity::v1alpha1::Entity;
using ProtoFileDescriptor = caosdb::entity::v1alpha1::FileDescriptor;
using ProtoMessage = caosdb::entity::v1alpha1::Message;
using ::google::protobuf::RepeatedPtrField;
using caosdb::StatusCode;
using caosdb::entity::v1alpha1::EntityResponse;
using caosdb::entity::v1alpha1::FileTransmissionId;
using ::google::protobuf::RepeatedPtrField;
using google::protobuf::RepeatedPtrField;
static const std::string logger_name = "caosdb::entity";
@@ -84,11 +84,11 @@ public:
/**
* Return the current size of the container.
*/
[[nodiscard]] inline auto Size() const -> int { return wrapped->size(); }
[[nodiscard]] inline auto size() const -> int { return wrapped->size(); }
/**
* Return a const reference to the element at the given index.
*/
[[nodiscard]] inline auto At(int index) const -> const T & {
[[nodiscard]] inline auto at(int index) const -> const T & {
return *mutable_at(index);
}
@@ -96,8 +96,8 @@ public:
* Return a mutable pointer to the element at the given index.
*/
[[nodiscard]] inline auto mutable_at(int index) const -> T * {
if (index >= Size() || index < 0) {
throw std::out_of_range("Container has size " + std::to_string(Size()));
if (index >= size() || index < 0) {
throw std::out_of_range("Container has size " + std::to_string(size()));
}
if (cache.count(index) == 0) {
cache.emplace(index, T(&(wrapped->at(index))));
@@ -157,7 +157,7 @@ protected:
// shift all indices in the cache above index (such that the values do not
// get deleted/copied because this could destroy pointers (c-interface).
for (int i = index + 1; i < Size(); i++) {
for (int i = index + 1; i < size(); i++) {
if (cache.count(i) > 0) {
auto handle = cache.extract(i);
handle.key()--;
@@ -225,7 +225,7 @@ auto RepeatedPtrFieldWrapper<T, P>::begin()
template <typename T, typename P>
auto RepeatedPtrFieldWrapper<T, P>::end()
-> RepeatedPtrFieldWrapper<T, P>::iterator {
return RepeatedPtrFieldWrapper<T, P>::iterator(this, Size());
return RepeatedPtrFieldWrapper<T, P>::iterator(this, size());
}
template <typename T, typename P>
@@ -237,7 +237,7 @@ auto RepeatedPtrFieldWrapper<T, P>::begin() const
template <typename T, typename P>
auto RepeatedPtrFieldWrapper<T, P>::end() const
-> const RepeatedPtrFieldWrapper<T, P>::iterator {
return RepeatedPtrFieldWrapper<T, P>::iterator(this, Size());
return RepeatedPtrFieldWrapper<T, P>::iterator(this, size());
}
/**
Loading