This repository was archived by the owner on Oct 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathEntry.h
More file actions
75 lines (55 loc) · 1.67 KB
/
Entry.h
File metadata and controls
75 lines (55 loc) · 1.67 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//
// Created by noom on 10/29/15.
//
#ifndef ZIPPICVIEW_ENTRY_H
#define ZIPPICVIEW_ENTRY_H
#include <algorithm>
#include <iostream>
#include <vector>
#include <wx/image.h>
#include <wx/stream.h>
#include <wx/string.h>
#include <wx/treebase.h>
class Entry;
typedef std::vector<Entry *>::const_iterator EntryIter;
class Entry {
public:
wxString Name() { return name; }
bool IsDirectory() { return dir; }
wxImage CreateImage();
void WriteStream(wxOutputStream &output);
EntryIter FirstChild() { return children.begin(); }
EntryIter EndChild() { return children.end(); }
EntryIter begin() { return FirstChild(); }
EntryIter end() { return EndChild(); }
virtual ~Entry();
void PrintChildren(const int &level = 0);
size_t Count() { return children.size(); }
Entry *Child(const size_t &i) { return children[i]; };
Entry *operator[](const size_t &i) { return Child(i); };
virtual bool IsRoot() const = 0;
Entry *Parent() { return parent; }
private:
std::vector<Entry *> children;
wxString name;
bool dir;
Entry *parent = nullptr;
protected:
void SetParent(Entry *parent) { this->parent = parent; }
void AddChild(Entry *entry) {
children.push_back(entry);
entry->SetParent(this);
}
void SetName(const wxString &_name) { name = _name; }
void SetIsDirectory(const bool &_dir) { dir = _dir; }
void SortChildren();
virtual wxInputStream *GetInputStream() = 0;
};
class EntryItemData : public wxTreeItemData {
private:
Entry *entry;
public:
EntryItemData(Entry *e) : wxTreeItemData(), entry(e){};
Entry *Get() { return entry; }
};
#endif // ZIPPICVIEW_ENTRY_H