Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-cpplib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-cpplib
Merge requests
!10
API: remove UniqueResult, lower-case at, size for ResultSet
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
API: remove UniqueResult, lower-case at, size for ResultSet
f-remove-unique-result
into
f-extended-c
Overview
0
Commits
4
Pipelines
3
Changes
5
Merged
Florian Spreckelsen
requested to merge
f-remove-unique-result
into
f-extended-c
3 years ago
Overview
0
Commits
4
Pipelines
3
Changes
5
Expand
0
0
Merge request reports
Compare
f-extended-c
version 2
f77226eb
3 years ago
version 1
f38dbd12
3 years ago
f-extended-c (base)
and
latest version
latest version
5135df76
4 commits,
3 years ago
version 2
f77226eb
3 commits,
3 years ago
version 1
f38dbd12
1 commit,
3 years ago
5 files
+
81
−
136
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
5
Search (e.g. *.vue) (Ctrl+P)
include/caosdb/transaction.h
+
8
−
35
Options
@@ -34,7 +34,6 @@
#include
<iterator>
// IWYU pragma: no_include <ext/alloc_traits.h>
#include
<memory>
// for shared_ptr, unique_ptr
#include
<stdexcept>
#include
<string>
// for string
#include
<vector>
// for vector
@@ -179,8 +178,9 @@ class ResultSet {
public:
virtual
~
ResultSet
()
=
default
;
[[
nodiscard
]]
virtual
auto
Size
()
const
noexcept
->
int
=
0
;
[[
nodiscard
]]
virtual
auto
At
(
const
int
index
)
const
->
const
Entity
&
=
0
;
[[
nodiscard
]]
virtual
auto
size
()
const
noexcept
->
int
=
0
;
[[
nodiscard
]]
virtual
auto
at
(
const
int
index
)
const
->
const
Entity
&
=
0
;
[[
nodiscard
]]
virtual
auto
mutable_at
(
int
index
)
const
->
Entity
*
=
0
;
auto
begin
()
const
->
iterator
;
auto
end
()
const
->
iterator
;
@@ -201,49 +201,22 @@ private:
/**
* Container with results of a transaction.
*
* In contrast to UniqueResult, this one can also hold multiple entities or zero
* entities.
*/
class
MultiResultSet
:
public
ResultSet
{
public:
~
MultiResultSet
()
=
default
;
explicit
MultiResultSet
(
std
::
vector
<
std
::
unique_ptr
<
Entity
>>
result_set
);
[[
nodiscard
]]
inline
auto
S
ize
()
const
noexcept
->
int
override
{
[[
nodiscard
]]
inline
auto
s
ize
()
const
noexcept
->
int
override
{
return
this
->
entities
.
size
();
}
[[
nodiscard
]]
inline
auto
A
t
(
const
int
index
)
const
[[
nodiscard
]]
inline
auto
a
t
(
const
int
index
)
const
->
const
Entity
&
override
{
return
*
(
this
->
entities
.
at
(
index
));
}
std
::
vector
<
std
::
unique_ptr
<
Entity
>>
entities
;
};
/**
* Container with the single result of a transaction.
*
* In contrast to MultiResultSet, this one guarantees to hold exactly one
* entity.
*/
class
UniqueResult
:
public
ResultSet
{
public:
~
UniqueResult
()
=
default
;
explicit
inline
UniqueResult
(
ProtoEntity
*
protoEntity
)
:
entity
(
new
Entity
(
protoEntity
)){};
explicit
inline
UniqueResult
(
IdResponse
*
idResponse
)
:
entity
(
new
Entity
(
idResponse
)){};
[[
nodiscard
]]
auto
GetEntity
()
const
->
const
Entity
&
;
[[
nodiscard
]]
inline
auto
Size
()
const
noexcept
->
int
override
{
return
1
;
}
[[
nodiscard
]]
inline
auto
At
(
const
int
index
)
const
->
const
Entity
&
override
{
if
(
index
!=
0
)
{
throw
std
::
out_of_range
(
"Index out of range. Length is 1."
);
}
return
*
(
this
->
entity
);
[[
nodiscard
]]
inline
auto
mutable_at
(
int
index
)
const
->
Entity
*
override
{
return
this
->
entities
.
at
(
index
).
get
();
}
private
:
std
::
unique_ptr
<
Entity
>
entity
;
std
::
vector
<
std
::
unique_ptr
<
Entity
>>
entities
;
};
/**
Loading