00001 #ifndef BOOKMARK_TREE_CLASS
00002 #define BOOKMARK_TREE_CLASS
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <basis/istring.h>
00023 #include <data_struct/amorph.h>
00024 #include <nodes/symbol_tree.h>
00025
00026
00027 class inner_mark_tree;
00028 class link_record;
00029 class listo_links;
00030 class symbol_int;
00031 class string_table;
00032
00034
00035 class bookmark_tree
00036 {
00037 public:
00038 bookmark_tree();
00039 virtual ~bookmark_tree();
00040 IMPLEMENT_CLASS_NAME("bookmark_tree");
00041
00042 int read_csv_file(const istring &input_filename);
00043
00044
00045 static void break_name(const istring &to_break, istring &name,
00046 istring &nick);
00047
00048
00049 static bool magic_category_comparison(const istring &a, const istring &b);
00050
00051
00052
00053 inner_mark_tree *process_category(const string_array &items);
00054
00055 void process_link(const string_array &items);
00056
00057 void process_comment(const istring ¤t_line_in);
00058
00059 inner_mark_tree *find_parent(const istring &parent_name);
00060
00061
00062
00063
00064
00065 inner_mark_tree &access_root();
00066
00067 int link_count() const { return _link_count; }
00068
00069 int category_count() const { return _category_count; }
00070
00071
00072 int _line_number;
00073
00074 private:
00075 inner_mark_tree *_mark_tree;
00076 int _link_count;
00077 int _category_count;
00078 inner_mark_tree *_last_parent;
00079 inner_mark_tree *_last_node;
00080 symbol_int *_links_seen;
00081 string_table *_category_names;
00082 };
00083
00085
00086 class link_record
00087 {
00088 public:
00089 istring _description;
00090 istring _url;
00091 int _uid;
00092
00093 link_record(const istring &description, const istring &url, int uid)
00094 : _description(description), _url(url), _uid(uid) {}
00095 };
00096
00098
00099 class listo_links : public amorph<link_record>
00100 {
00101 public:
00102 listo_links();
00103
00104 void add(link_record *new_rec, bool sort = true);
00105
00106 private:
00107 int _next_index;
00108 };
00109
00111
00112 class inner_mark_tree : public nodes::symbol_tree
00113 {
00114 public:
00115 listo_links _links;
00116 int _uid;
00117
00118 inner_mark_tree(const istring &node_name, int uid, int max_bits = 2)
00119 : nodes::symbol_tree(node_name, max_bits), _uid(uid) {}
00120
00121 };
00122
00124
00125 #endif
00126