Skip to content

Commit 64ec8b6

Browse files
authored
docs: sync README with build system
1 parent cfb9202 commit 64ec8b6

File tree

3 files changed

+101
-19
lines changed

3 files changed

+101
-19
lines changed

README-RU.md

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,26 +44,31 @@
4444
## 🔧 Установка и сборка
4545

4646
1. Скопируйте папку `include/` в проект или подключите репозиторий как submodule.
47-
2. Убедитесь, что `libmdbx` доступна системе (можно собрать автоматически при `BUILD_DEPS=ON`).
47+
2. Убедитесь, что `libmdbx` доступна системе (установите `MDBXC_DEPS_MODE=BUNDLED` для автоматической сборки).
4848
3. Проверьте поддержку стандарта C++11 и выше.
4949

5050
### Сборка через CMake
5151

5252
```bash
5353
cmake -S . -B build \
54-
-DBUILD_DEPS=ON \
55-
-DBUILD_STATIC_LIB=ON \
56-
-DBUILD_TESTS=ON \
57-
-DBUILD_EXAMPLES=ON
54+
-DMDBXC_DEPS_MODE=BUNDLED \
55+
-DMDBXC_BUILD_STATIC_LIB=ON \
56+
-DMDBXC_BUILD_TESTS=ON \
57+
-DMDBXC_BUILD_EXAMPLES=ON \
58+
-DMDBXC_USE_ASAN=ON \
59+
-DCMAKE_CXX_STANDARD=17
5860
cmake --build build
61+
ctest --test-dir build --output-on-failure
5962
```
6063

6164

62-
Для Windows доступны `.bat`‑скрипты с аналогичными параметрами (`build-17-examples.bat`, `build-mingw-17-tests.bat` и др.).
65+
Для Windows доступны `.bat`‑скрипты с аналогичными параметрами (`build-mingw-17-examples.bat`, `build-mingw-17-tests.bat`, `build-mingw-11-tests.bat`).
6366

6467
---
6568

66-
## 🚀 Пример использования
69+
## 🚀 Примеры использования
70+
71+
### Базовая таблица ключ-значение
6772

6873
```cpp
6974
#include <mdbx_containers/KeyValueTable.hpp>
@@ -78,11 +83,9 @@ int main() {
7883
auto conn = mdbxc::Connection::create(config);
7984
mdbxc::KeyValueTable<int, std::string> table(conn, "my_map");
8085

81-
// Запись
8286
table.insert_or_assign(1, "Hello");
8387
table.insert_or_assign(2, "World");
8488

85-
// Чтение
8689
std::map<int, std::string> result;
8790
table.load(result);
8891

@@ -93,6 +96,43 @@ int main() {
9396
}
9497
```
9598

99+
### Ручное управление транзакцией
100+
101+
```cpp
102+
mdbxc::Config config;
103+
config.pathname = "txn.mdbx";
104+
auto conn = mdbxc::Connection::create(config);
105+
mdbxc::KeyValueTable<int, std::string> table(conn, "demo");
106+
107+
conn->begin(mdbxc::TransactionMode::WRITABLE);
108+
table.insert_or_assign(10, "ten");
109+
conn->commit();
110+
```
111+
112+
### Пользовательская структура
113+
114+
```cpp
115+
struct MyData {
116+
int id;
117+
double value;
118+
119+
std::vector<uint8_t> to_bytes() const {
120+
std::vector<uint8_t> bytes(sizeof(MyData));
121+
std::memcpy(bytes.data(), this, sizeof(MyData));
122+
return bytes;
123+
}
124+
125+
static MyData from_bytes(const void* data, size_t size) {
126+
MyData out{};
127+
std::memcpy(&out, data, sizeof(MyData));
128+
return out;
129+
}
130+
};
131+
132+
mdbxc::KeyValueTable<int, MyData> table(conn, "my_data");
133+
table.insert_or_assign(42, MyData{42, 3.14});
134+
```
135+
96136
📘 Документация
97137
- Подробные примеры см. в папке examples/.
98138
- API и архитектура описаны в Wiki (если есть).

README.md

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,28 @@
3838
## Installation
3939

4040
1. Copy the `include/` directory into your project or add this repository as a submodule.
41-
2. Ensure `libmdbx` is available to your build system (it can be built automatically with `BUILD_DEPS=ON`).
41+
2. Ensure `libmdbx` is available to your build system (set `MDBXC_DEPS_MODE=BUNDLED` to build it automatically).
4242
3. Use a C++11 (or later) compiler.
4343

4444
### Build with CMake
4545

4646
```bash
4747
cmake -S . -B build \
48-
-DBUILD_DEPS=ON \
49-
-DBUILD_STATIC_LIB=ON \
50-
-DBUILD_TESTS=ON \
51-
-DBUILD_EXAMPLES=ON
48+
-DMDBXC_DEPS_MODE=BUNDLED \
49+
-DMDBXC_BUILD_STATIC_LIB=ON \
50+
-DMDBXC_BUILD_TESTS=ON \
51+
-DMDBXC_BUILD_EXAMPLES=ON \
52+
-DMDBXC_USE_ASAN=ON \
53+
-DCMAKE_CXX_STANDARD=17
5254
cmake --build build
55+
ctest --test-dir build --output-on-failure
5356
```
5457

55-
Windows users can run the provided `.bat` scripts such as `build-17-examples.bat` or `build-mingw-17-tests.bat`.
58+
Windows users can run the provided `.bat` scripts such as `build-mingw-17-examples.bat`, `build-mingw-17-tests.bat`, or `build-mingw-11-tests.bat`.
5659

57-
## Example
60+
## Usage Examples
61+
62+
### Basic key-value table
5863

5964
```cpp
6065
#include <mdbx_containers/KeyValueTable.hpp>
@@ -69,11 +74,9 @@ int main() {
6974
auto conn = mdbxc::Connection::create(config);
7075
mdbxc::KeyValueTable<int, std::string> table(conn, "my_map");
7176

72-
// Write
7377
table.insert_or_assign(1, "Hello");
7478
table.insert_or_assign(2, "World");
7579

76-
// Read
7780
std::map<int, std::string> result;
7881
table.load(result);
7982

@@ -84,6 +87,43 @@ int main() {
8487
}
8588
```
8689

90+
### Manual transaction
91+
92+
```cpp
93+
mdbxc::Config config;
94+
config.pathname = "txn.mdbx";
95+
auto conn = mdbxc::Connection::create(config);
96+
mdbxc::KeyValueTable<int, std::string> table(conn, "demo");
97+
98+
conn->begin(mdbxc::TransactionMode::WRITABLE);
99+
table.insert_or_assign(10, "ten");
100+
conn->commit();
101+
```
102+
103+
### Custom struct serialization
104+
105+
```cpp
106+
struct MyData {
107+
int id;
108+
double value;
109+
110+
std::vector<uint8_t> to_bytes() const {
111+
std::vector<uint8_t> bytes(sizeof(MyData));
112+
std::memcpy(bytes.data(), this, sizeof(MyData));
113+
return bytes;
114+
}
115+
116+
static MyData from_bytes(const void* data, size_t size) {
117+
MyData out{};
118+
std::memcpy(&out, data, sizeof(MyData));
119+
return out;
120+
}
121+
};
122+
123+
mdbxc::KeyValueTable<int, MyData> table(conn, "my_data");
124+
table.insert_or_assign(42, MyData{42, 3.14});
125+
```
126+
87127
## Documentation
88128

89129
- See the `examples/` directory for more examples.

docs/mainpage.dox

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ b.insert_or_assign("a", "b");
6161
\section build_sec Building
6262
Use CMake or simply include the headers and link with libmdbx.
6363
```bash
64-
cmake -S . -B build -DBUILD_DEPS=ON -DBUILD_STATIC_LIB=ON
64+
cmake -S . -B build \
65+
-DMDBXC_DEPS_MODE=BUNDLED \
66+
-DMDBXC_BUILD_STATIC_LIB=ON
6567
cmake --build build
6668
```
6769

0 commit comments

Comments
 (0)