|
Porytiles
|
Represents a parsed #define preprocessor statement. More...
#include <define_statement.hpp>
Public Member Functions | |
| 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. | |
| DefineStatement (std::string name, SourcePosition position) | |
| Constructs a DefineStatement with no value (flag-like define). | |
| const std::string & | name () const |
| Returns the macro name. | |
| const DefineValue & | value () const |
| Returns the value variant. | |
| const SourcePosition & | position () const |
| Returns the source position of the #define. | |
| 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. | |
| bool | is_flag () const |
| Checks if this define has no value (flag-like). | |
| std::int64_t | int_value () const |
| Returns the integer value. | |
| const std::string & | string_value () const |
| Returns the string value. | |
Represents a parsed #define preprocessor statement.
DefineStatement captures the name and value of a C preprocessor #define directive. For simple numeric defines like #define FOO 123 or #define BAR (1 << 4), the value is evaluated and stored as an integer. For string defines like #define MSG "hello", the string value is stored. For flag-like defines with no value like #define DEBUG, the value is std::monostate.
The original source position is preserved for error reporting.
Example defines this class can represent:
Definition at line 43 of file define_statement.hpp.
|
inline |
Constructs a DefineStatement with an integer value.
| name | The macro name |
| value | The integer value |
| position | The source position of the #define |
Definition at line 52 of file define_statement.hpp.
|
inline |
Constructs a DefineStatement with a string value.
| name | The macro name |
| value | The string value |
| position | The source position of the #define |
Definition at line 64 of file define_statement.hpp.
|
inline |
Constructs a DefineStatement with no value (flag-like define).
| name | The macro name |
| position | The source position of the #define |
Definition at line 75 of file define_statement.hpp.
|
inline |
Checks if this define has an integer value.
Definition at line 115 of file define_statement.hpp.
|
inline |
Checks if this define has a string value.
Definition at line 125 of file define_statement.hpp.
|
inline |
Returns the integer value.
Definition at line 146 of file define_statement.hpp.
|
inline |
Checks if this define has no value (flag-like).
Definition at line 135 of file define_statement.hpp.
|
inline |
Returns the macro name.
Definition at line 85 of file define_statement.hpp.
|
inline |
Returns the source position of the #define.
Definition at line 105 of file define_statement.hpp.
|
inline |
Returns the string value.
Definition at line 158 of file define_statement.hpp.
|
inline |
Returns the value variant.
Definition at line 95 of file define_statement.hpp.