namespace
SFormatUtility methods for formatting strings using SystemVerilog formatting styles.
Classes
- struct FormatOptions
- A collection of options that can be applied to the SFormat string formatting functions.
Functions
-
auto parse(std::
string_view formatString, function_ ref<void(std:: 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, std:: optional<char> specifier)> onError) -> bool - Parse the given formatString and call the provided callbacks for each parsed portion.
-
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, const Type& type, char specifier, const FormatOptions& options, bool isStringLiteral) - Format the given arg into a string and append it to result according to the provided options.
Function documentation
bool slang:: ast:: SFormat:: parse(std:: string_view formatString,
function_ ref<void(std:: 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, std:: optional<char> specifier)> onError)
#include <slang/ast/SFormat.h>
Parse the given formatString and call the provided callbacks for each parsed portion.
Parameters | |
---|---|
formatString | Specified by the SystemVerilog LRM – see that for a complete reference. |
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. |
void slang:: ast:: SFormat:: formatInt(std:: string& result,
const SVInt& value,
LiteralBase base,
const FormatOptions& options)
#include <slang/ast/SFormat.h>
Format the given value into a string and append it to result according to the provided options.
void slang:: ast:: SFormat:: formatArg(std:: string& result,
const ConstantValue& arg,
const Type& type,
char specifier,
const FormatOptions& options,
bool isStringLiteral)
#include <slang/ast/SFormat.h>
Format the given arg into a string and append it to result according to the provided options.