Spicy
Public Member Functions | Protected Member Functions | List of all members
hilti::CxxCode Class Reference

#include <jit.h>

Public Member Functions

 CxxCode (const hilti::rt::filesystem::path &path)
 
 CxxCode (const std::string &id, std::istream &code)
 
 CxxCode (const detail::cxx::Unit &u)
 
bool save (const hilti::rt::filesystem::path &p) const
 
bool save (std::ostream &out) const
 
auto code () const
 
auto isLoaded () const
 
const std::string & id () const
 
std::size_t hash () const
 

Protected Member Functions

bool load (const hilti::rt::filesystem::path &path)
 
bool load (const std::string &id, std::istream &in)
 

Detailed Description

Container for C++ code compiled from a HILTI source file

Constructor & Destructor Documentation

◆ CxxCode() [1/3]

hilti::CxxCode::CxxCode ( const hilti::rt::filesystem::path &  path)
inline

Reads C++ code from a file.

Parameters
pathfile to read

◆ CxxCode() [2/3]

hilti::CxxCode::CxxCode ( const std::string &  id,
std::istream &  code 
)
inline

Reads C++ code from an input stream.

Parameters
idname to associate with the input for logging and error messages.
codestream to read from

◆ CxxCode() [3/3]

CxxCode::CxxCode ( const detail::cxx::Unit u)
explicit

Initializes code instance from in-memory compiler output. For internal use.

Parameters
uunit to initialize code instance from

Member Function Documentation

◆ code()

auto hilti::CxxCode::code ( ) const
inline

Returns C++ code as a string.

◆ hash()

std::size_t hilti::CxxCode::hash ( ) const
inline

Obtain hash for this code.

◆ id()

const std::string& hilti::CxxCode::id ( ) const
inline

Returns a name associated with the instance's C++ code. If the code has been read from a file, that's the path; otherwise the ID specified when initialized.

◆ isLoaded()

auto hilti::CxxCode::isLoaded ( ) const
inline

Returns true if this instance has been initialized with any C++ code.

◆ load() [1/2]

bool CxxCode::load ( const hilti::rt::filesystem::path &  path)
protected

Loads C++ code from a file.

Parameters
pathfile to read from
Returns
true if successful

◆ load() [2/2]

bool CxxCode::load ( const std::string &  id,
std::istream &  in 
)
protected

Loads C++ code from an input stream.

Parameters
idname to associate with the input for logging and error messages.
pathstream to read from
Returns
true if successful

◆ save() [1/2]

bool CxxCode::save ( const hilti::rt::filesystem::path &  p) const

Saves C++ code into a file.

Parameters
pfile to write to
Returns
true if successful

◆ save() [2/2]

bool CxxCode::save ( std::ostream &  out) const

Writes C++ code into an output stream.

Parameters
outstream to write to
Returns
true if successful

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