Rix Facade
The Rix facade is the unified public API for Rix packages.
It gives Vix.cpp applications one clean entry point:
#include <rix.hpp>Then you use the global rix object:
rix.auth
rix.csv
rix.debug
rix.pdfThe facade is the recommended style for public Rix examples.
What the facade solves
Each Rix package can be used independently.
That is useful when a project only needs one package.
But applications often use several userland libraries together.
The facade gives them one clean object-style API:
#include <rix.hpp>
int main()
{
rix.debug.print("Hello from Rix");
auto auth = rix.auth.memory();
auto table = rix.csv.parse("name,lang\nAda,C++\n");
auto doc = rix.pdf.document();
return 0;
}The model is simple:
rix.<package>Examples:
rix.auth
rix.csv
rix.debug
rix.pdfInstall the facade
For a project, install the facade package:
vix add rix/rix
vix installIf the project uses vix.app, declare the dependency in deps:
deps = [
"rix/rix",
]deps is for packages from the Vix Registry.
Do not put Rix packages in packages.
Single-file usage
For quick experiments, you can write one file and run it with Vix.
Create a small folder:
mkdir -p ~/rix-facade-example
cd ~/rix-facade-exampleCreate a file:
touch main.cppAdd:
#include <rix.hpp>
int main()
{
rix.debug.print("Hello from the Rix facade");
auto auth = rix.auth.memory();
auto table = rix.csv.parse(
"name,language\n"
"Ada,C++\n");
rix.debug.print("rows:", table.size());
return 0;
}Run it:
vix run main.cppIf Rix is not available yet, install the facade globally:
vix install -g rix/rixThen run again:
vix run main.cppGlobal installation is useful for quick local experiments.
For real projects, prefer project dependencies with vix add, vix install, and deps in vix.app.
Project usage
Inside a Vix project, use project dependencies:
vix add rix/rix
vix installThen declare it in vix.app:
deps = [
"rix/rix",
]A small vix.app can look like this:
name = "hello-rix"
type = "executable"
standard = "c++20"
output_dir = "bin"
sources = [
"src/main.cpp",
]
include_dirs = [
"include",
"src",
]
deps = [
"rix/rix",
]
packages = [
"vix",
]
links = [
"vix::vix",
]Then use the facade in C++:
#include <rix.hpp>
int main()
{
rix.debug.print("Hello from Rix");
auto auth = rix.auth.memory();
return 0;
}Build and run:
vix build
vix runPackage model
A Rix package follows a stable model:
Package : rix/name
Header : <rix/name.hpp>
Namespace: rixlib::name
Facade : rix.nameFor Auth:
Package : rix/auth
Header : <rix/auth.hpp>
Namespace: rixlib::auth
Facade : rix.authFor CSV:
Package : rix/csv
Header : <rix/csv.hpp>
Namespace: rixlib::csv
Facade : rix.csvFor Debug:
Package : rix/debug
Header : <rix/debug.hpp>
Namespace: rixlib::debug
Facade : rix.debugFor PDF:
Package : rix/pdf
Header : <rix/pdf.hpp>
Namespace: rixlib::pdf
Facade : rix.pdfFor the unified facade:
Package : rix/rix
Header : <rix.hpp>
Facade : rixCurrent facade modules
The facade can mount the current Rix packages:
rix.auth
rix.csv
rix.debug
rix.pdfAuth
Auth is available through:
rix.authCommon APIs:
rix.auth.memory()
rix.auth.database(db)
rix.auth.password.hash(...)
rix.auth.password.verify(...)
rix.auth.config.development()
rix.auth.config.production()
rix.auth.error.to_string(...)Example:
auto auth = rix.auth.memory();
auto registered = auth.register_user({
"ada@example.com",
"correct-password"});CSV
CSV is available through:
rix.csvCommon APIs:
rix.csv.parse(...)
rix.csv.write(...)
rix.csv.write_row(...)
rix.csv.write_to(...)
rix.csv.load(...)
rix.csv.save(...)
rix.csv.version()Example:
auto table = rix.csv.parse(
"name,language\n"
"Ada,C++\n");
auto output = rix.csv.write(table);Debug
Debug is available through:
rix.debugCommon APIs:
rix.debug.print(...)
rix.debug.eprint(...)
rix.debug.dprint(...)
rix.debug.sprint(...)
rix.debug.format(...)
rix.debug.inspect(...)Example:
rix.debug.print("Hello", "Rix");
auto text = rix.debug.format("Package: {}", "rix/rix");
rix.debug.inspect(text);For application logging, prefer the Vix logging system.
Use rix.debug for lightweight debug output, formatting, printing, and inspection.
PDF
PDF is available through:
rix.pdfCommon APIs:
rix.pdf.document()
rix.pdf.write(...)
rix.pdf.save(...)
rix.pdf.make_text(...)
rix.pdf.image.load_jpeg(...)
rix.pdf.error.to_string(...)Example:
auto doc = rix.pdf.document();
auto &page = doc.add_page();
page.text(
page.x_left(),
page.y_top(),
"Hello from rix.pdf"
);
auto saved = rix.pdf.save(doc, "hello.pdf");Facade and lower-level APIs
The facade is the public application API:
rix.auth.memory()
rix.csv.parse(...)
rix.debug.print(...)
rix.pdf.document()The lower-level namespaces are still available:
rixlib::auth
rixlib::csv
rixlib::debug
rixlib::pdfUse lower-level APIs when you need advanced control, direct package usage, custom integrations, or implementation-level access.
For normal documentation and application examples, prefer:
#include <rix.hpp>and:
rix.<package>Feature macros
By default, including rix.hpp enables the available facade modules.
#include <rix.hpp>For lighter builds, define only the modules you want before including rix.hpp.
Auth only:
#define RIX_ENABLE_AUTH
#include <rix.hpp>Auth and Debug:
#define RIX_ENABLE_AUTH
#define RIX_ENABLE_DEBUG
#include <rix.hpp>CSV only:
#define RIX_ENABLE_CSV
#include <rix.hpp>PDF only:
#define RIX_ENABLE_PDF
#include <rix.hpp>Feature macros must be defined before including rix.hpp.
Correct:
#define RIX_ENABLE_AUTH
#include <rix.hpp>Wrong:
#include <rix.hpp>
#define RIX_ENABLE_AUTHWhen to use the facade
Use the facade when:
- you want the public Rix style
- you want one clean include
- you want one object-style API
- you are writing application code
- you are following the Rix documentation
- your project uses several Rix packages together
Example:
#include <rix.hpp>
int main()
{
auto auth = rix.auth.memory();
rix.debug.print("auth ready");
return 0;
}When to use an independent package
Use an independent package when:
- you only need one package
- you do not want the full facade
- you are writing lower-level integration code
- you want direct package-level control
- your library should depend on a smaller package
Example:
#include <rix/auth.hpp>The facade remains the recommended path for public examples.
What you should remember
Use the facade with:
#include <rix.hpp>Install it with:
vix add rix/rix
vix installDeclare it in vix.app:
deps = [
"rix/rix",
]Use packages through:
rix.auth
rix.csv
rix.debug
rix.pdfUse rixlib::... only when you need lower-level or advanced access.
Next step
Learn how to enable only selected facade modules.
Next: Feature Macros