OpenXLSX 1.12.1
Modern C++ Excel Library (Fork of OpenXLSX by Kenneth Troldal Balslev)
Loading...
Searching...
No Matches
XLFormulaEngine.hpp File Reference
#include <array>
#include <cstddef>
#include <cstdint>
#include <functional>
#include <memory>
#include <mutex>
#include <optional>
#include <string>
#include <string_view>
#include <unordered_map>
#include <vector>
#include <gsl/gsl>
#include "OpenXLSX-Exports.hpp"
#include "XLCellReference.hpp"
#include "XLCellValue.hpp"
#include "XLEvaluationContext.hpp"

Go to the source code of this file.

Data Structures

struct  OpenXLSX::XLToken
 A single lexical token from a formula string. More...
class  OpenXLSX::XLFormulaLexer
 Tokenises a raw Excel formula string (with or without leading '='). More...
struct  OpenXLSX::XLASTNode
 Polymorphic AST node. Uses a tagged-union approach with std::unique_ptr children. More...
struct  OpenXLSX::XLFormulaDiagnostic
class  OpenXLSX::XLFormulaDiagnosticReporter
class  OpenXLSX::XLFormulaParser
 Recursive-descent (Pratt) parser that converts a token stream into an AST. More...
class  OpenXLSX::XLEvalSession
 Per-evaluation session shared by the engine and session-aware functions. More...
struct  OpenXLSX::XLEvalSession::PackedCellKey
 64-bit coordinate encoding for fast, normalized circular dependency checking. More...
class  OpenXLSX::XLEvalCallGuard
 RAII guard that pairs XLEvalSession::enterCall / leaveCall. More...
class  OpenXLSX::XLEvalNodeGuard
 RAII guard that pairs XLEvalSession::enterNodeEval / leaveNodeEval. More...
class  OpenXLSX::XLEvalCellGuard
 RAII guard that tracks evaluating cell references for circular reference detection. More...
class  OpenXLSX::XLFormulaArg
 Lightweight formula evaluation engine. More...
class  OpenXLSX::XLFormulaArg::Iterator
struct  OpenXLSX::XLSpillResult
 Result of a checked spill attempt (dynamic-array #SPILL! support). More...
class  OpenXLSX::XLFormulaEngine

Namespaces

namespace  OpenXLSX

Typedefs

using OpenXLSX::XLCellResolver = std::function<XLCellValue(std::string_view ref)>
 Callback type: resolves a cell reference string to a cell value.
using OpenXLSX::XLNameResolver = std::function<std::optional<std::string>(std::string_view name)>
 Optional callback: resolve a defined name to a formula/reference string.
using OpenXLSX::XLSpillWriter = std::function<void(uint32_t row, uint16_t col, const XLCellValue& value)>
 Callback used by spillArray to write one spill cell (1-based Excel coordinates).
using OpenXLSX::XLSpillOccupancy = std::function<bool(uint32_t row, uint16_t col)>
 Callback: return true if (row,col) is occupied and must not be overwritten by a spill (except the formula anchor cell itself).

Enumerations

enum class  OpenXLSX::XLTokenKind : uint8_t {
  OpenXLSX::Number , OpenXLSX::String , OpenXLSX::Bool , OpenXLSX::CellRef ,
  OpenXLSX::Ident , OpenXLSX::Plus , OpenXLSX::Minus , OpenXLSX::Star ,
  OpenXLSX::Slash , OpenXLSX::Caret , OpenXLSX::Percent , OpenXLSX::Amp ,
  OpenXLSX::Eq , OpenXLSX::NEq , OpenXLSX::Lt , OpenXLSX::Le ,
  OpenXLSX::Gt , OpenXLSX::Ge , OpenXLSX::LParen , OpenXLSX::RParen ,
  OpenXLSX::Comma , OpenXLSX::Semicolon , OpenXLSX::Colon , OpenXLSX::LBrace ,
  OpenXLSX::RBrace , OpenXLSX::End , OpenXLSX::Error
}
 Kinds of tokens produced by the lexer. More...
enum class  OpenXLSX::XLNodeKind : uint8_t {
  OpenXLSX::Number , OpenXLSX::StringLit , OpenXLSX::BoolLit , OpenXLSX::CellRef ,
  OpenXLSX::Range , OpenXLSX::BinOp , OpenXLSX::UnaryOp , OpenXLSX::FuncCall ,
  OpenXLSX::ArrayLit , OpenXLSX::ErrorLit
}
 Kind discriminator for AST nodes. More...

Functions

OPENXLSX_EXPORT size_t OpenXLSX::spillArray (const XLFormulaArg &result, uint32_t topRow, uint16_t leftCol, const XLSpillWriter &write)
 Write a (possibly multi-cell) formula result into a rectangular spill range.
OPENXLSX_EXPORT bool OpenXLSX::spillRangeIsClear (const XLFormulaArg &result, uint32_t topRow, uint16_t leftCol, const XLSpillOccupancy &isOccupied, uint32_t anchorRow=0, uint16_t anchorCol=0)
 Check whether a spill rectangle is free of blocking occupants.
OPENXLSX_EXPORT XLSpillResult OpenXLSX::spillArrayChecked (const XLFormulaArg &result, uint32_t topRow, uint16_t leftCol, const XLSpillWriter &write, const XLSpillOccupancy &isOccupied, uint32_t anchorRow=0, uint16_t anchorCol=0)
 Spill with #SPILL! detection: writes only when the target range is clear.