cpp-common/bt2: rename `common-iter.hpp` to `common-iterator.hpp`
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 27 Oct 2023 18:52:32 +0000 (14:52 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Thu, 14 Dec 2023 15:57:04 +0000 (10:57 -0500)
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I4816ab3ecf2b19423f8ab0a92924e62c438df4f9
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11164
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
src/Makefile.am
src/cpp-common/bt2/common-iter.hpp [deleted file]
src/cpp-common/bt2/common-iterator.hpp [new file with mode: 0644]
src/cpp-common/bt2/field-class.hpp
src/cpp-common/bt2/field-path.hpp
src/cpp-common/bt2/integer-range-set.hpp
src/cpp-common/bt2/value.hpp

index 1f90d14bcaf4f4f0e01b7825358d8790f7930299..5e2ac10a7badf4bb34d6188bd130ba2418eacf4e 100644 (file)
@@ -15,7 +15,7 @@ noinst_HEADERS = \
        cpp-common/bt2/borrowed-object.hpp \
        cpp-common/bt2/clock-class.hpp \
        cpp-common/bt2/clock-snapshot.hpp \
-       cpp-common/bt2/common-iter.hpp \
+       cpp-common/bt2/common-iterator.hpp \
        cpp-common/bt2/exc.hpp \
        cpp-common/bt2/field-class.hpp \
        cpp-common/bt2/field.hpp \
diff --git a/src/cpp-common/bt2/common-iter.hpp b/src/cpp-common/bt2/common-iter.hpp
deleted file mode 100644 (file)
index 8488884..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (c) 2022 Francis Deslauriers <francis.deslauriers@efficios.com>
- *
- * SPDX-License-Identifier: MIT
- */
-
-#ifndef BABELTRACE_CPP_COMMON_BT2_COMMON_ITER_HPP
-#define BABELTRACE_CPP_COMMON_BT2_COMMON_ITER_HPP
-
-#include <cstdint>
-#include <iterator>
-
-#include "cpp-common/optional.hpp"
-
-namespace bt2 {
-
-template <typename ContainerT, typename ElemT>
-class CommonIterator
-{
-    friend ContainerT;
-
-public:
-    using difference_type = std::ptrdiff_t;
-    using value_type = ElemT;
-    using pointer = value_type *;
-    using reference = value_type&;
-    using iterator_category = std::input_iterator_tag;
-
-private:
-    explicit CommonIterator(const ContainerT container, const uint64_t idx) :
-        _mContainer {container}, _mIdx {idx}
-    {
-        this->_updateCurrentValue();
-    }
-
-public:
-    CommonIterator(const CommonIterator&) = default;
-    CommonIterator(CommonIterator&&) = default;
-    CommonIterator& operator=(const CommonIterator&) = default;
-    CommonIterator& operator=(CommonIterator&&) = default;
-
-    CommonIterator& operator++() noexcept
-    {
-        ++_mIdx;
-        this->_updateCurrentValue();
-        return *this;
-    }
-
-    CommonIterator operator++(int) noexcept
-    {
-        const auto tmp = *this;
-
-        ++(*this);
-        return tmp;
-    }
-
-    bool operator==(const CommonIterator& other) const noexcept
-    {
-        return _mIdx == other._mIdx;
-    }
-
-    bool operator!=(const CommonIterator& other) const noexcept
-    {
-        return !(*this == other);
-    }
-
-    reference operator*() noexcept
-    {
-        return *_mCurrVal;
-    }
-
-    pointer operator->() noexcept
-    {
-        return &(*_mCurrVal);
-    }
-
-private:
-    void _updateCurrentValue() noexcept
-    {
-        if (_mIdx < _mContainer.size()) {
-            _mCurrVal = _mContainer[_mIdx];
-        } else {
-            _mCurrVal = nonstd::nullopt;
-        }
-    }
-
-    nonstd::optional<value_type> _mCurrVal;
-    ContainerT _mContainer;
-    uint64_t _mIdx;
-};
-
-} /* namespace bt2 */
-
-#endif /* BABELTRACE_CPP_COMMON_BT2_COMMON_ITER_HPP */
diff --git a/src/cpp-common/bt2/common-iterator.hpp b/src/cpp-common/bt2/common-iterator.hpp
new file mode 100644 (file)
index 0000000..e878b1b
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2022 Francis Deslauriers <francis.deslauriers@efficios.com>
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#ifndef BABELTRACE_CPP_COMMON_BT2_COMMON_ITERATOR_HPP
+#define BABELTRACE_CPP_COMMON_BT2_COMMON_ITERATOR_HPP
+
+#include <cstdint>
+#include <iterator>
+
+#include "cpp-common/optional.hpp"
+
+namespace bt2 {
+
+template <typename ContainerT, typename ElemT>
+class CommonIterator
+{
+    friend ContainerT;
+
+public:
+    using difference_type = std::ptrdiff_t;
+    using value_type = ElemT;
+    using pointer = value_type *;
+    using reference = value_type&;
+    using iterator_category = std::input_iterator_tag;
+
+private:
+    explicit CommonIterator(const ContainerT container, const uint64_t idx) :
+        _mContainer {container}, _mIdx {idx}
+    {
+        this->_updateCurrentValue();
+    }
+
+public:
+    CommonIterator(const CommonIterator&) = default;
+    CommonIterator(CommonIterator&&) = default;
+    CommonIterator& operator=(const CommonIterator&) = default;
+    CommonIterator& operator=(CommonIterator&&) = default;
+
+    CommonIterator& operator++() noexcept
+    {
+        ++_mIdx;
+        this->_updateCurrentValue();
+        return *this;
+    }
+
+    CommonIterator operator++(int) noexcept
+    {
+        const auto tmp = *this;
+
+        ++(*this);
+        return tmp;
+    }
+
+    bool operator==(const CommonIterator& other) const noexcept
+    {
+        return _mIdx == other._mIdx;
+    }
+
+    bool operator!=(const CommonIterator& other) const noexcept
+    {
+        return !(*this == other);
+    }
+
+    reference operator*() noexcept
+    {
+        return *_mCurrVal;
+    }
+
+    pointer operator->() noexcept
+    {
+        return &(*_mCurrVal);
+    }
+
+private:
+    void _updateCurrentValue() noexcept
+    {
+        if (_mIdx < _mContainer.size()) {
+            _mCurrVal = _mContainer[_mIdx];
+        } else {
+            _mCurrVal = nonstd::nullopt;
+        }
+    }
+
+    nonstd::optional<value_type> _mCurrVal;
+    ContainerT _mContainer;
+    uint64_t _mIdx;
+};
+
+} /* namespace bt2 */
+
+#endif /* BABELTRACE_CPP_COMMON_BT2_COMMON_ITERATOR_HPP */
index 168af69c6f4601e0b79774986936b53535e857ae..0999b135a6be31c72011909c7b8b5db42bbe80f5 100644 (file)
@@ -17,7 +17,7 @@
 #include "cpp-common/string_view.hpp"
 
 #include "borrowed-object.hpp"
-#include "common-iter.hpp"
+#include "common-iterator.hpp"
 #include "exc.hpp"
 #include "field-path.hpp"
 #include "integer-range-set.hpp"
index 97c1addd97e2a2a95d30169a5353a81afffec621..ef5ff0902b108cf6931b89bc6c120412fd1ba483 100644 (file)
@@ -14,7 +14,7 @@
 #include "common/assert.h"
 
 #include "borrowed-object.hpp"
-#include "common-iter.hpp"
+#include "common-iterator.hpp"
 #include "shared-object.hpp"
 
 namespace bt2 {
index b090a330b5ef143f82c4a29936ff5699fb9346c5..d58b93cb7dfb6c9f496493bcbef4ab087bd51f89 100644 (file)
@@ -13,7 +13,7 @@
 #include <babeltrace2/babeltrace.h>
 
 #include "borrowed-object.hpp"
-#include "common-iter.hpp"
+#include "common-iterator.hpp"
 #include "exc.hpp"
 #include "integer-range.hpp"
 #include "internal/utils.hpp"
index 7596694c9630de1d84e13e7e8112270ba095374a..1aa413184c737478e08b9e1959bb85e6517a68f7 100644 (file)
@@ -19,7 +19,7 @@
 #include "cpp-common/string_view.hpp"
 
 #include "borrowed-object.hpp"
-#include "common-iter.hpp"
+#include "common-iterator.hpp"
 #include "exc.hpp"
 #include "internal/utils.hpp"
 #include "shared-object.hpp"
This page took 0.028573 seconds and 4 git commands to generate.