Учимся пользоваться odb в нашем меленьком проекте

This commit was merged in pull request #3.
This commit is contained in:
2025-03-09 10:26:52 +05:00
parent 4fbe63701f
commit d47988adda
16 changed files with 932 additions and 32 deletions

46
src/book_s.h Normal file
View File

@@ -0,0 +1,46 @@
// file : hello/person.hxx
// copyright : not copyrighted - public domain
#ifndef BOOK_S_H
#define BOOK_S_H
#include <memory>
#include <string>
#include <odb/core.hxx>
#include "author_s.h"
#pragma db object
class Book_S
{
public:
Book_S() = default;
Book_S(const std::string& name,
const std::shared_ptr<Author_S>& author,
const int year)
{
m_author = author;
m_name = name;
m_year = year;
};
unsigned long long id() const { return m_id; }
std::shared_ptr<Author_S> author() const { return m_author; }
std::string name() const { return m_name; }
int year() const { return m_year; }
private:
friend class odb::access;
private:
#pragma db id auto
unsigned long long m_id;
std::shared_ptr<Author_S> m_author;
std::string m_name;
int m_year;
};
#endif // BOOK_S_H