00001
00002
00003
00004
00005
00006
00007 #ifndef __cmt_awk_h__
00008 #define __cmt_awk_h__
00009
00010 #include "cmt_std.h"
00011 #include "cmt_string.h"
00012 #include "cmt_regexp.h"
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 class Awk
00060 {
00061 public:
00062 typedef enum {ok, stopped, failed} condition;
00063 Awk ();
00064 virtual ~Awk ();
00065 condition run (const cmt_string& text, const cmt_string& pattern = "");
00066 condition run (const cmt_string& text, const cmt_regexp& expression);
00067 void stop ();
00068 void abort ();
00069 void allow_continuation ();
00070 condition get_last_condition () const;
00071
00072 virtual void begin ();
00073 virtual void filter (const cmt_string& line);
00074 virtual void end ();
00075
00076 void inc_line_number ();
00077
00078 protected:
00079 int m_line_number;
00080 condition m_condition;
00081 bool m_continuation_allowed;
00082 };
00083
00084 class FAwk : public Awk
00085 {
00086 public:
00087 condition run (const cmt_string& file_name, const cmt_string& pattern = "");
00088 condition run (const cmt_string& text, const cmt_regexp& expression);
00089 protected:
00090 cmt_string m_dir_name;
00091 cmt_string m_file_name;
00092 };
00093
00094 class PAwk : public Awk
00095 {
00096 public:
00097 condition run (const cmt_string& command, const cmt_string& pattern = "");
00098 condition run (const cmt_string& text, const cmt_regexp& expression);
00099 };
00100
00105 class PathScanner
00106 {
00107 public:
00108 class actor
00109 {
00110 public:
00111 virtual void run (const cmt_string& package,
00112 const cmt_string& version,
00113 const cmt_string& path)
00114 {
00115 }
00116 };
00117
00118 PathScanner ();
00119 bool scan_path (const cmt_string& path, actor& a);
00120 bool scan_package (const cmt_string& path, const cmt_string& package);
00121
00122 private:
00123 void scan_path (const cmt_string& path, int level, actor& a);
00124
00125 bool _running;
00126 int _level;
00127 };
00128
00129
00130 #endif