GumboStringPiece(3)

πŸ“¦
version 0.12.1 Β· 4 versions
, in fedora 43

πŸ’– GumboStringPiece πŸ’–

okay bestie, so GumboStringPiece is a whole struct, and she is the moment. it's giving "a string or a little piece of a string" and honestly? iconic. this is the Gumbo manual, page 3, and we're about to get into it. πŸ¦‹


✨ SYNOPSIS ✨

#include <gumbo.h>

πŸŽ€ Data Fields

  • const char * data
  • size_t length

🌸 Detailed Description 🌸

so here's the vibe: GumboStringPiece is a struct that represents a string, or literally just part of a string. bestie, that's it. that's the whole assignment. πŸ’…

strings inside the parser don't get their own lil cozy memory home β€” nope. they're represented by a char* and a length, where the char* points into an existing data buffer that some other code owns (usually the original input, like, not even ours). so it's borrowing, not owning. rent-free behavior, honestly.

GumboStringPieces are assumed (by convention) to be immutable, because they may share data. so like… do not touch. do not edit. hands off the merchandise. πŸ™ˆ

if you actually need to construct a string (like, build one from scratch, main character energy), use GumboStringBuffer instead. that's what she's for.

also, huge heads up: clients should assume it is not NUL-terminated. so you can't just vibe-check it with strlen and hope for the best. always use explicit lengths when you're manipulating them. always. no cap. πŸ”₯


πŸ’œ Field Documentation πŸ’œ

const char* GumboStringPiece::data

a pointer to the beginning of the string. it's NULL iff length == 0. so if the length is zero, the pointer is null, and if the pointer is null, the length is zero. they're matching. they're soulmates. they're fr fr linked. ✨

size_t GumboStringPiece::length

the length of the string fragment, in bytes. and yes, it may be zero β€” zero is a totally valid length, don't be weird about it. πŸ’–


πŸ‘‘ Author πŸ‘‘

Generated automatically by Doxygen for Gumbo from the source code. so nobody hand-wrote this, it just appeared, like magic, like a fairy godmother but for documentation. 🧚


that's the whole page, bestie!! go forth and use explicit lengths, stay immutable, and don't ever assume a NUL terminator is coming to save you. slay. 🫢

Version 0.12.1 β€” Fri Sep 19 2025 00:00:00 β€” Gumbo, page 3. mwah, bye!! πŸ’…πŸ’–πŸŒˆ

πŸ“¦ where this page comes from