summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/Bkmks.h
blob: b38184a1d3fdf8ad1be8e2975e7a9d1548de0a51 (plain)
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
#ifndef __Bkmks_h
#define __Bkmks_h

#include "config.h"
#include <stdio.h>

template<class T>
class CList;

class Bkmk
{
    friend class BkmkFile;
    tchar* m_name;
    tchar* m_anno;
    unsigned int m_position;
 public:
    Bkmk() : m_name(NULL), m_anno(NULL), m_position(0) {};
    Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p);
    Bkmk(const Bkmk& rhs) : m_name(NULL), m_anno(NULL)
	{
	    *this = rhs;
	}
    ~Bkmk();
    unsigned int value() const { return m_position; }
    tchar *name() const { return m_name; }
    tchar *anno() const { return m_anno; }
    bool operator<(const Bkmk& rhs) { return (m_position < rhs.m_position); }
    Bkmk& operator=(const Bkmk& rhs);
    bool operator==(const Bkmk& rhs);
    void setAnno(tchar* t);
};

class BkmkFile
{
    FILE* f;
    bool wt;
    bool isUpgraded;
    static const unsigned long magic;
 private:
    Bkmk* read();
    Bkmk* read03();
    CList<Bkmk>* readall03();
    CList<Bkmk>* readall04();
    void write(tchar* nm, tchar* an, const unsigned int& pos);
    void write(const Bkmk& b);
 public:
    bool upgraded() { return isUpgraded; }
    BkmkFile(const char *fnm, bool w = false);
    ~BkmkFile();
    void write(CList<Bkmk>& bl);
    CList<Bkmk>* readall();
};
#endif