cpp-common/bt2c: add `CStringView::startsWith`
[babeltrace.git] / src / cpp-common / bt2c / c-string-view.hpp
index 3dca0299da4babf6495d26b88905126feb7104ab..0437cd65c4d87458ebe8eca1029d74e728201649 100644 (file)
@@ -176,6 +176,13 @@ public:
         return _mStr[i];
     }
 
+    bool startsWith(const bt2c::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;
 };
This page took 0.023005 seconds and 4 git commands to generate.