C++ API Reference
The NeuG C++ API provides high-performance, low-level access to graph database functionality. Designed for performance-critical applications, embedded systems, and advanced graph algorithms.
Overview
The C++ API offers powerful capabilities for:
- Database Management: Open, configure, and manage NeuG database instances
- Query Execution: Execute Cypher queries with parameterized inputs
- Result Processing: Iterate over query results with type-safe access
Core Classes
- NeugDB - The main entry point for database operations
- Connection - Execute Cypher queries against the database
- QueryResult - Container for query results with iterator access
- NeugDBService - HTTP service for high-throughput scenarios
Quick Start
Include Headers
#include <neug/main/neug_db.h>
#include <neug/main/connection.h>Basic Usage
#include <neug/main/neug_db.h>
#include <iostream>
int main() {
// Create and open database
neug::NeugDB db;
db.Open("/path/to/graph", 4); // 4 threads
// Create connection and execute query
auto conn = db.Connect();
auto result = conn->Query("MATCH (n:Person) RETURN n.name LIMIT 10", "read");
// Process results
if (result.has_value()) {
for (auto& record : result.value()) {
std::cout << record.ToString() << std::endl;
}
}
// Close database
db.Close();
return 0;
}Error Handling
auto result = conn->Query("INVALID QUERY", "read");
if (!result.has_value()) {
std::cerr << "Query failed: " << result.error().message() << std::endl;
}Thread Safety
NeugDB: Thread-safe for all operationsConnection: NOT thread-safe; use one connection per threadQueryResult: Thread-safe (read-only after creation)