// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include #include #include namespace zen { /// Render a UE structured-log template (as produced by UE_LOGFMT) against a /// fields bag, writing the result into a caller-provided builder. Grammar: /// /// format := (text | escape | placeholder)* /// escape := '{{' | '}}' (non-localized, default) /// | '`{' | '`}' | '``' (localized, $locformat) /// placeholder := '{' field_path '}' /// field_path := name ('.' name | '[' digits ']')* /// name := [A-Za-z0-9] [A-Za-z0-9_]* (leading '_' reserved) /// /// There are NO inline format specs — `{Name:spec}` is not part of the /// grammar. Formatting control lives on the value side via nested /// objects carrying `$text` / `$format` / `$locformat` (see the value- /// rendering rules in logtemplate.cpp). /// /// Missing paths render as empty (UE asserts these at emit time, so in /// practice they don't occur; the empty-render is defensive). Unknown /// primitive CbField types render as empty. /// /// Typical use: pass an `ExtendableStringBuilder<256>` so typical messages /// render on the stack with no heap allocation. The builder is appended to, /// not cleared, so callers can compose multiple writes if they want. /// /// @param Template The format string. /// @param Fields The top-level fields bag referenced by placeholders. /// @param Out Builder to append the rendered text to. /// @param Localized True for $locformat templates (backtick escapes); /// false (default) for the top-level `format` field. void RenderLogTemplate(std::string_view Template, CbObjectView Fields, StringBuilderBase& Out, bool Localized = false); } // namespace zen