|
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 40 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 47 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 57 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 66 of file define_statement.hpp.
|
inline |
Checks if this define has an integer value.
Definition at line 98 of file define_statement.hpp.
|
inline |
Checks if this define has a string value.
Definition at line 106 of file define_statement.hpp.
|
inline |
Returns the integer value.
Definition at line 123 of file define_statement.hpp.
|
inline |
Checks if this define has no value (flag-like).
Definition at line 114 of file define_statement.hpp.
|
inline |
Returns the macro name.
Definition at line 74 of file define_statement.hpp.
|
inline |
Returns the source position of the #define.
Definition at line 90 of file define_statement.hpp.
|
inline |
Returns the string value.
Definition at line 133 of file define_statement.hpp.
|
inline |
Returns the value variant.
Definition at line 82 of file define_statement.hpp.