00001 #ifndef filelink_h
00002 #define filelink_h
00003
00004 #include "hook.h"
00005 #include "cppdir.h"
00006
00008
00009
00010 class FileLink : private HookTag
00011 {
00012 public:
00013 typedef CppDir::File::size_type size_type;
00014
00015 protected:
00016 std::string expr;
00017 std::string origdir;
00018 std::string publicdir;
00019 std::string title;
00020 bool size_info;
00021 size_type file_size;
00022 std::string file_name;
00023 bool date;
00024 std::string file_date;
00025 std::string format;
00026 std::string ignore;
00027 bool regex;
00028 bool basename;
00029
00030 typedef enum SortType
00031 {
00032 NUMERICAL,
00033 LEXICAL,
00034 DATE,
00035 NONE_TYPE
00036 };
00037
00038 typedef enum Sort
00039 {
00040 HIGHEST,
00041 LOWEST,
00042 NUMBER,
00043 NONE_SORT
00044 };
00045
00046 SortType sorttype;
00047 Sort sort;
00048 int sortnumber;
00049
00050 bool used_by_filelist;
00051
00052 std::string current_dir;
00053
00054 public:
00055 FileLink( Line& line, bool used_by_filelist = false );
00056
00057 bool operator!() const { return !is_valid_tag; }
00058
00060 void set_dir( std::string cd ) { current_dir = cd; }
00061
00064 std::string get_link()
00065 { return get_link( current_dir ); }
00066
00067 std::string get_link( std::string current_dir );
00068
00069 std::string get_expr() const { return expr; }
00070 std::string get_origdir() const { return origdir; }
00071 std::string get_publicdir() const { return publicdir; }
00072 std::string get_title() const { return title; }
00073 bool display_size() const { return size_info; }
00074 bool display_date() const { return date; }
00075
00076 std::string get_tag();
00077
00078 bool has_hook()
00079 { return HookTag::has_hook(); }
00080
00081 std::string get_hook()
00082 { return HookTag::get_hook(); }
00083
00084 protected:
00085
00086 std::string get_file( std::string current_dir );
00087
00089
00090 size_type get_file_size() const { return file_size; }
00091
00092 std::string get_file_name() const { return file_name; }
00093
00094 std::string get_file_date() const { return file_date; }
00095
00096 std::string get_tag_type() const { return Tag::get_tag_type(); }
00097
00098 bool get_option( std::string o, std::string& s ) { return Tag::get_option( o, s ); }
00099 bool get_option( std::string o ) { return Tag::get_option( o ); }
00100
00102 std::string get_basename( std::string title );
00103
00104 void delete_default_options();
00105
00106 protected:
00107
00108 bool match( std::string name ) { return match( expr, name ); }
00109 bool match( std::string expr, std::string name );
00110
00111 SortType get_sorttype( std::string s );
00112 Sort get_sort( std::string s );
00113 CppDir::File match( CppDir::Directory::file_list& fl );
00114
00115 bool get_warning() const
00116 { return !nowarning; }
00117
00118 std::string get_options()
00119 { return Tag::get_options(); }
00120 };
00121
00122 namespace FL
00123 {
00124 bool lexical_sort( CppDir::File& f1, CppDir::File& f2 );
00125 bool numerical_sort( CppDir::File& f1, CppDir::File& f2 );
00126 bool date_sort( CppDir::File& f1, CppDir::File& f2 );
00127 bool has_number( std::string s );
00128 bool extract_number( std::string s, std::string::size_type start, std::string& num );
00129 }
00130
00131 #endif