xo-object2 xo-gc xo-facet: codegen updates + IGCObject_DString

This commit is contained in:
Roland Conybeare 2026-01-14 14:37:44 -05:00
commit ecfd3e4e6f
19 changed files with 280 additions and 68 deletions

View file

@ -6,7 +6,9 @@
#pragma once
#include <xo/alloc2/Allocator.hpp>
#include <xo/gc/Collector.hpp>
#include <xo/facet/obj.hpp>
#include <xo/indentlog/print/ppindentinfo.hpp>
#include <string_view>
#include <cstdint>
@ -38,11 +40,22 @@ namespace xo {
using const_iterator = const char *;
/** xo allocator **/
using AAllocator = xo::mm::AAllocator;
/** garbage collector **/
using ACollector = xo::mm::ACollector;
/** ppindentinfo for APrintable **/
using ppindentinfo = xo::print::ppindentinfo;
///@}
/** @defgroup dstring-ctors constructors **/
///@{
/** default ctor **/
DString() = default;
/** not simply copyable, because of flexible array.
* Need allocator
**/
DString(const DString &) = delete;
/** create empty string with space for @cap chars
* (including null terminator).
* Use memory from allocator @p mm
@ -56,6 +69,17 @@ namespace xo {
static DString * from_cstr(obj<AAllocator> mm,
const char * cstr);
/** clone existing string **/
static DString * clone(obj<AAllocator> mm,
const DString * src);
#ifdef NOT_YET
/** **/
static DString * concat(obj<AAllocator> mm,
DString * s1,
DString * s2);
#endif
///@}
/** @defgroup dstring-access access methods **/
///@{
@ -141,6 +165,24 @@ namespace xo {
operator const char * () const noexcept { return &(chars_[0]); }
///@}
/** @defgroup dstring-printable-methods printable facet methods **/
///@{
bool pretty(const ppindentinfo & ppii) const;
///@}
/** @defgroup dstring-gcobject-methods gcobject facet methods **/
///@{
size_type shallow_size() const noexcept;
/** clone string, using memory from allocator @p mm **/
DString * shallow_copy(obj<AAllocator> mm) const noexcept;
/** fixup child pointers (trivial for DString, no children) **/
size_type forward_children(obj<ACollector> gc) noexcept;
///@}
private:
/** @defgroup dstring-instance-variables instance variables **/