From eeb36655aab87609c72bfd308808a13a6f5cabf1 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 25 Jan 2026 10:03:41 -0500 Subject: [PATCH] xo-object2: + DString.from_str() --- include/xo/object2/DString.hpp | 6 ++++++ src/object2/DString.cpp | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/include/xo/object2/DString.hpp b/include/xo/object2/DString.hpp index eea8ea5..a6cedb0 100644 --- a/include/xo/object2/DString.hpp +++ b/include/xo/object2/DString.hpp @@ -78,6 +78,12 @@ namespace xo { static DString * from_view(obj mm, std::string_view sv); + /** create string containing a copy @p str. + * Use memory from allocator @p mm. + **/ + static DString * from_str(obj mm, + const std::string & str); + /** create string containing a copy of @p sv. * Use memory from allocator @p mm via sub_alloc. * (load-bearing for StringTable) diff --git a/src/object2/DString.cpp b/src/object2/DString.cpp index ee9885b..69baa5d 100644 --- a/src/object2/DString.cpp +++ b/src/object2/DString.cpp @@ -91,6 +91,15 @@ namespace xo { return _from_view_aux(mm, sv, false /*!suballoc_flag*/); } + DString * + DString::from_str(obj mm, + const std::string & str) + { + return _from_view_aux(mm, + std::string_view(str), + false /*!suballoc_flag*/); + } + DString * DString::from_view_suballoc(obj mm, std::string_view sv)