summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorJan de Visser <jan@de-visser.net>2021-11-02 16:34:05 -0400
committerAndreas Kling <kling@serenityos.org>2021-11-10 14:47:49 +0100
commitc2c47fb9bba7e2383e0bd3dfabe8ec29126b93fb (patch)
treed23125ed27dcb04721514bdb68f984ad4229c81b /Userland
parentf3a9d61891204779a6e051213a3cb5bb3e1293f7 (diff)
downloadserenity-c2c47fb9bba7e2383e0bd3dfabe8ec29126b93fb.zip
LibSQL: Add the 'extend' operation to the Tuple class
Tuple::extend is similar to the Vector method of the same name; it concatenates a second Tuple to the current one.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibSQL/Tuple.cpp9
-rw-r--r--Userland/Libraries/LibSQL/Tuple.h1
2 files changed, 10 insertions, 0 deletions
diff --git a/Userland/Libraries/LibSQL/Tuple.cpp b/Userland/Libraries/LibSQL/Tuple.cpp
index 8e64b9478c..a25a057cbb 100644
--- a/Userland/Libraries/LibSQL/Tuple.cpp
+++ b/Userland/Libraries/LibSQL/Tuple.cpp
@@ -132,6 +132,15 @@ Tuple& Tuple::operator+=(Value const& value)
return *this;
}
+void Tuple::extend(Tuple const& other)
+{
+ VERIFY((descriptor()->size() == size()) || (descriptor()->size() >= size() + other.size()));
+ if (descriptor()->size() == size()) {
+ descriptor()->extend(other.descriptor());
+ }
+ m_data.extend(other.m_data);
+}
+
bool Tuple::is_compatible(Tuple const& other) const
{
if ((m_descriptor->size() == 0) && (other.m_descriptor->size() == 0)) {
diff --git a/Userland/Libraries/LibSQL/Tuple.h b/Userland/Libraries/LibSQL/Tuple.h
index 9ae1530b2e..8bab7a5023 100644
--- a/Userland/Libraries/LibSQL/Tuple.h
+++ b/Userland/Libraries/LibSQL/Tuple.h
@@ -55,6 +55,7 @@ public:
Value& operator[](String const& name);
void append(Value const&);
Tuple& operator+=(Value const&);
+ void extend(Tuple const&);
[[nodiscard]] bool is_compatible(Tuple const&) const;
[[nodiscard]] u32 pointer() const { return m_pointer; }