~aleteoryx/muditaos

ref: 9fdb29846302f88321c23518a163e2c7a389d9e1 muditaos/module-db/Interface/NotesRecord.hpp -rw-r--r-- 1.5 KiB
9fdb2984 — Roman Kubiak [EGD-4557] implement usb-deinit (#1101) 5 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include "Record.hpp"
#include <stdint.h>
#include "../Databases/NotesDB.hpp"
#include "utf8/UTF8.hpp"
#include "../Common/Common.hpp"

struct NotesRecord
{
    uint32_t ID;
    uint32_t date;
    UTF8 snippet;
    UTF8 path;
};

enum class NotesRecordField
{
    Data,
    Snippet,
    Path
};

/*
 *
 */
class NotesRecordInterface : public RecordInterface<NotesRecord, NotesRecordField>
{
  public:
    NotesRecordInterface(NotesDB *notesDb);
    virtual ~NotesRecordInterface();

    bool Add(const NotesRecord &rec) override final;
    bool RemoveByID(uint32_t id) override final;
    bool RemoveByField(NotesRecordField field, const char *str) override final;
    bool Update(const NotesRecord &rec) override final;
    NotesRecord GetByID(uint32_t id) override final;

    uint32_t GetCount() override final;

    std::unique_ptr<std::vector<NotesRecord>> GetLimitOffset(uint32_t offset, uint32_t limit) override final;

    std::unique_ptr<std::vector<NotesRecord>> GetLimitOffsetByField(uint32_t offset,
                                                                    uint32_t limit,
                                                                    NotesRecordField field,
                                                                    const char *str) override final;

  private:
    const uint32_t snippetLength = 60;
    NotesDB *notesDB;
};