.gitignore: add some missing files
[babeltrace.git] / src / cpp-common / bt2c / c-string-view.hpp
index b1a7b6e76d4037fb2976f1248a1a26d4278d822c..52eacacae1ca9d28381e4ccf10f2d783ff678d78 100644 (file)
@@ -176,6 +176,13 @@ public:
         return _mStr[i];
     }
 
+    bool startsWith(const CStringView prefix) const noexcept
+    {
+        BT_ASSERT_DBG(_mStr);
+        BT_ASSERT_DBG(prefix);
+        return std::strncmp(_mStr, prefix, prefix.len()) == 0;
+    }
+
 private:
     const char *_mStr = nullptr;
 };
@@ -240,7 +247,10 @@ bool operator==(LhsT&& lhs, RhsT&& rhs) noexcept
  *
  * Both `lhs` and `rhs` must not have an underlying `nullptr` raw data.
  */
-template <typename LhsT, typename RhsT>
+template <
+    typename LhsT, typename RhsT,
+    typename = typename std::enable_if<internal::ComparableWithCStringView<LhsT>::value>::type,
+    typename = typename std::enable_if<internal::ComparableWithCStringView<RhsT>::value>::type>
 bool operator!=(LhsT&& lhs, RhsT&& rhs) noexcept
 {
     return !(std::forward<LhsT>(lhs) == std::forward<RhsT>(rhs));
@@ -248,4 +258,12 @@ bool operator!=(LhsT&& lhs, RhsT&& rhs) noexcept
 
 } /* namespace bt2c */
 
+/*
+ * Appends `rhs` to `lhs`.
+ */
+inline void operator+=(std::string& lhs, bt2c::CStringView rhs)
+{
+    lhs += rhs.data();
+}
+
 #endif /* BABELTRACE_CPP_COMMON_BT2C_C_STRING_VIEW_HPP */
This page took 0.023633 seconds and 4 git commands to generate.