slang/text/SFormat.h file

SystemVerilog string formatting routines.

Contents

Namespaces

namespace slang
Root namespace.

Classes

struct slang::SFormat::FormatOptions
A collection of options that can be applied to the SFormat string formatting functions.

Functions

auto parse(string_view formatString, function_ref<void(string_view text)> onText, function_ref<void(char specifier, size_t offset, size_t len, const FormatOptions&options)> onArg, function_ref<void(DiagCode code, size_t offset, size_t len, optional<char> specifier)> onError) -> bool
void formatInt(std::string& result, const SVInt& value, LiteralBase base, const FormatOptions& options)
void formatArg(std::string& result, const ConstantValue& arg, char specifier, const FormatOptions& options)

Function documentation

bool parse(string_view formatString, function_ref<void(string_view text)> onText, function_ref<void(char specifier, size_t offset, size_t len, const FormatOptions&options)> onArg, function_ref<void(DiagCode code, size_t offset, size_t len, optional<char> specifier)> onError)

Parameters
formatString
onText will be invoked for each constant / non-formatted portion of the format string.
onArg will be invoked for each format specifier in the format string, with various options parsed and provided as arguments.
onError will be invoked for any errors in the format string, with a diagnostic code describing the problem and the location in the string where the error occurred.
Returns true if parsing was successful, and false if an error occurred.

Parse the given formatString and call the provided callbacks for each parsed portion. The formatString is specified by the SystemVerilog LRM – see that for a complete reference.

void formatInt(std::string& result, const SVInt& value, LiteralBase base, const FormatOptions& options)

Format the given value into a string and append it to result according to the provided options

void formatArg(std::string& result, const ConstantValue& arg, char specifier, const FormatOptions& options)

Format the given arg into a string and append it to result according to the provided options