Porytiles
Loading...
Searching...
No Matches
porytiles::IncbinDeclaration Class Reference

Represents a parsed INCBIN array declaration from C source code. More...

#include <incbin_declaration.hpp>

Public Member Functions

 IncbinDeclaration (std::string variable_name, std::string macro_name, std::string path, SourcePosition position)
 Constructs an IncbinDeclaration with a single path.
 
 IncbinDeclaration (std::string variable_name, std::string macro_name, std::vector< std::string > paths, SourcePosition position)
 Constructs an IncbinDeclaration with multiple paths.
 
const std::string & variable_name () const
 Returns the variable name.
 
const std::string & macro_name () const
 Returns the INCBIN macro name.
 
const std::vector< std::string > & paths () const
 Returns all paths from the INCBIN macro(s).
 
const SourcePositionposition () const
 Returns the source position of the variable name.
 
bool is_multi_path () const
 Checks if this declaration has multiple paths.
 

Detailed Description

Represents a parsed INCBIN array declaration from C source code.

IncbinDeclaration captures array declarations that use INCBIN macros to include binary data:

// Single path:
const u32 gTilesetTiles_General[] = INCBIN_U32("data/tilesets/primary/general/tiles.4bpp");
// Multiple paths (palette arrays):
const u16 gTilesetPalettes_General[][16] = {
INCBIN_U16("data/tilesets/primary/general/palettes/00.gbapal"),
INCBIN_U16("data/tilesets/primary/general/palettes/01.gbapal"),
...
};
Invariant
variable_name_ is never empty
macro_name_ is never empty
paths_ contains at least one path
position_ contains valid 1-based line and column numbers

Definition at line 32 of file incbin_declaration.hpp.

Constructor & Destructor Documentation

◆ IncbinDeclaration() [1/2]

porytiles::IncbinDeclaration::IncbinDeclaration ( std::string  variable_name,
std::string  macro_name,
std::string  path,
SourcePosition  position 
)
inline

Constructs an IncbinDeclaration with a single path.

Parameters
variable_nameThe variable name (e.g., "gTilesetTiles_General")
macro_nameThe INCBIN macro name (e.g., "INCBIN_U32")
pathThe path inside the INCBIN macro
positionThe source position of the variable name

Definition at line 42 of file incbin_declaration.hpp.

◆ IncbinDeclaration() [2/2]

porytiles::IncbinDeclaration::IncbinDeclaration ( std::string  variable_name,
std::string  macro_name,
std::vector< std::string >  paths,
SourcePosition  position 
)
inline

Constructs an IncbinDeclaration with multiple paths.

Used for multi-dimensional arrays like palette declarations where multiple INCBIN calls are used in a single initializer.

Parameters
variable_nameThe variable name (e.g., "gTilesetPalettes_General")
macro_nameThe INCBIN macro name (e.g., "INCBIN_U16")
pathsThe paths from each INCBIN macro call
positionThe source position of the variable name

Definition at line 60 of file incbin_declaration.hpp.

Member Function Documentation

◆ is_multi_path()

bool porytiles::IncbinDeclaration::is_multi_path ( ) const
inline

Checks if this declaration has multiple paths.

Returns
True if there are multiple INCBIN paths (palette-style declaration)

Definition at line 112 of file incbin_declaration.hpp.

◆ macro_name()

const std::string & porytiles::IncbinDeclaration::macro_name ( ) const
inline

Returns the INCBIN macro name.

Returns
A const reference to the macro name (e.g., "INCBIN_U32", "INCBIN_U16")

Definition at line 82 of file incbin_declaration.hpp.

◆ paths()

const std::vector< std::string > & porytiles::IncbinDeclaration::paths ( ) const
inline

Returns all paths from the INCBIN macro(s).

Returns
A const reference to the vector of paths

Definition at line 92 of file incbin_declaration.hpp.

◆ position()

const SourcePosition & porytiles::IncbinDeclaration::position ( ) const
inline

Returns the source position of the variable name.

Returns
A const reference to the source position

Definition at line 102 of file incbin_declaration.hpp.

◆ variable_name()

const std::string & porytiles::IncbinDeclaration::variable_name ( ) const
inline

Returns the variable name.

Returns
A const reference to the variable name (e.g., "gTilesetTiles_General")

Definition at line 72 of file incbin_declaration.hpp.


The documentation for this class was generated from the following file: