21using DefineValue = std::variant<std::int64_t, std::string, std::monostate>;
76 : name_{std::move(
name)}, value_{std::monostate{}}, position_{
position}
85 [[nodiscard]]
const std::string &
name()
const
117 return std::holds_alternative<std::int64_t>(value_);
127 return std::holds_alternative<std::string>(value_);
137 return std::holds_alternative<std::monostate>(value_);
149 return std::get<std::int64_t>(value_);
161 return std::get<std::string>(value_);
Represents a parsed #define preprocessor statement.
const std::string & string_value() const
Returns the string value.
DefineStatement(std::string name, SourcePosition position)
Constructs a DefineStatement with no value (flag-like define).
bool is_flag() const
Checks if this define has no value (flag-like).
const std::string & name() const
Returns the macro name.
bool has_int_value() const
Checks if this define has an integer value.
bool has_string_value() const
Checks if this define has a string value.
const SourcePosition & position() const
Returns the source position of the #define.
DefineStatement(std::string name, std::int64_t value, SourcePosition position)
Constructs a DefineStatement with an integer value.
DefineStatement(std::string name, std::string value, SourcePosition position)
Constructs a DefineStatement with a string value.
std::int64_t int_value() const
Returns the integer value.
const DefineValue & value() const
Returns the value variant.
void assert_or_panic(bool condition, const StringViewSourceLoc &s)
Conditionally panics if the given condition is false.
std::variant< std::int64_t, std::string, std::monostate > DefineValue
Represents the value of a #define statement.
Represents a position within source content.