> ## Documentation Index
> Fetch the complete documentation index at: https://knowledge.cloudquant.com/llms.txt
> Use this file to discover all available pages before exploring further.

# C++ SDK Getting Started

> Installation guide and prerequisites for using the CloudQuant Data Liberator C++ API.

# C++ SDK getting started

The CloudQuant Data Liberator C++ SDK uses Apache Arrow for high-performance data streaming with a generator-based iteration pattern.

## Required security files

Place the following files from your Downloads ZIP in your working directory:

* **`liberator.json`** — Contains your Username and Token
* **`liberator.pfx`** — Security certificate (only required for releases prior to 2.0)

<Note>
  As of release version 2.0, `liberator.pfx` is no longer required. If you are on a release prior to 2.0, you must also include `liberator.pfx` in your working directory.
</Note>

## Type reference

The SDK uses `std::variant` types for flexible argument and return handling:

```cpp theme={null}
using Arg = std::variant<std::monostate,
                         bool,
                         int64_t,
                         double,
                         std::string,
                         std::vector<std::string>,
                         std::ostream*>;

using Func = std::function<std::variant<std::monostate,
                 std::shared_ptr<rapidjson::Document>,
                 std::shared_ptr<arrow::RecordBatch>>()>;

using Result = std::variant<std::shared_ptr<rapidjson::Document>, Func>;
```

## Quick start

### Query with get\_table

The simplest approach converts results directly into an Arrow Table:

```cpp theme={null}
Liberator liberator;

auto table = liberator.get_table(liberator.query({
    {"symbols", std::vector<std::string>{"AAPL", "GOOGL"}},
    {"name", "daily_bars"s},
}));

(void)arrow::PrettyPrint(*table, arrow::PrettyPrintOptions(0, 1), &std::cout);
```

### Query with generator pattern

For streaming or large results, use the generator pattern to iterate through record batches:

```cpp theme={null}
Liberator liberator;
Liberator::Result ptr;

ptr = liberator.query({
    {"symbols", std::vector<std::string>{"AAPL", "GOOGL"}},
    {"name", "daily_bars"s}
});

auto generator = *std::get_if<Liberator::Func>(&ptr);

for (auto res = generator(); res.index(); res = generator())
{
    auto batch = *std::get_if<2>(&res);
    (void)arrow::PrettyPrint(*batch, arrow::PrettyPrintOptions(0, 1),
        &std::cout);
}
```
