d782d463cb
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
43 lines
1.7 KiB
C++
43 lines
1.7 KiB
C++
// TQL — Table Query Language emit/apply. Round-trip entre State y Lua text.
|
|
// Ver docs/TQL.md.
|
|
#pragma once
|
|
|
|
#include "data_table_logic.h"
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace tql {
|
|
|
|
// Serializa el estado actual a un Lua chunk completo:
|
|
// return { version, display, stages, columns, visualization_settings }
|
|
//
|
|
// `headers` y `types` describen las cols originales (size = orig_cols).
|
|
// Las derived cols se anaden automaticamente desde state.derived.
|
|
std::string emit(const data_table::State& state,
|
|
const std::vector<std::string>& headers,
|
|
const std::vector<data_table::ColumnType>& types);
|
|
|
|
// Parsea un Lua chunk TQL y rellena State. Mutates:
|
|
// - stages (clears + reconstruye desde stages[] del TQL; stage 0 = Raw con
|
|
// filters/expressions/sort; stages 1+ con filter/breakout/aggregation/sort)
|
|
// - col_visible / col_order (desde columns[])
|
|
// - color_rules (desde columns[].color_rules)
|
|
// - stages[0].derived[].type (desde columns[].type para nombres derived)
|
|
//
|
|
// `cells/rows/orig_cols` necesarios para sample auto-detect de tipos en
|
|
// expressions (cuando la entry columns omite el type explicito).
|
|
bool apply(const std::string& lua_text,
|
|
data_table::State& state,
|
|
const std::vector<std::string>& headers,
|
|
const std::vector<data_table::ColumnType>& types,
|
|
const char* const* cells, int rows, int orig_cols,
|
|
std::string* err);
|
|
|
|
// Helpers expuestos para tests.
|
|
std::string lua_string_literal(const std::string& s);
|
|
std::string color_to_hex(unsigned int c);
|
|
unsigned int hex_to_color(const std::string& s);
|
|
data_table::ColumnType column_type_from_string(const std::string& s);
|
|
|
|
} // namespace tql
|