qbraid_algorithms.qtran.IncludeBuilder

class qbraid_algorithms.qtran.IncludeBuilder

Builder for generating OpenQASM include files.

Creates include files that can be imported by other OpenQASM programs. These files typically contain gate definitions, constants, and reusable subroutines but do not include qubit declarations or main program logic.

Include files are useful for:

  • Sharing gate definitions across multiple circuits

  • Creating domain-specific gate libraries

  • Modular quantum program development

  • Standardizing common quantum operations

__init__()

Initialize the base file builder with empty data structures.

Sets up the foundational components needed for code generation:

  • Empty import list for library dependencies

  • Empty gate definitions dictionary for custom gates

  • Empty gate references list for scope validation

  • Empty program string for accumulating generated code

  • Zero scope level for proper indentation tracking

Methods

__init__()

Initialize the base file builder with empty data structures.

build()

Generate the include file content.

import_library(lib_class[, annotated])

Import and initialize a quantum gate library.

program_append(line)

Append a line of code to the program with proper indentation.