* New upstream release.
[debian/mimetic.git] / examples / cmdline.h
1 #ifndef MM_CMDLINE_H_
2 #define MM_CMDLINE_H_
3 #include <string>
4 #include <vector>
5 #include <list>
6 #include <map>
7
8 enum {
9     p_none,
10     // match
11     p_attachment_filename, p_has_binary_attach, p_has_field,
12     p_field, p_ifield, p_std_field,
13     // options
14     p_match_shell, p_match_regex, 
15     p_perl_regex, p_case_insensitive, p_encoding,
16     p_invert_selection, p_recursive,
17     // actions
18     p_add_header, p_del_header, p_mod_header, 
19     p_add_part_header, p_del_part_header, p_mod_part_header, 
20     p_attach, p_detach, p_delete_part, p_delete_msg, p_print_part,
21     p_print_msg, p_pipe_to,
22     //others
23     p_in, p_out, p_help, p_version,
24     p_last_item
25 };
26
27 typedef std::pair<std::string, std::string> command_line_switch;
28 struct command_line
29 {
30     typedef std::string string;
31     typedef std::multimap<string,string>::iterator iterator;
32     typedef std::multimap<string,string>::const_iterator const_iterator;
33     command_line();
34     bool parse_cmd_line(int, char**);
35     bool is_set(const string&) const;
36     bool is_set(int) const;
37     string& operator[](const string&);
38     iterator begin(const string& s = "");
39     iterator end(const string& s = "");
40     const_iterator begin(const string& s = "") const;
41     const_iterator end(const string& s = "") const;
42 private:
43     void die_if_not_valid() const;
44     void add_switch(const string&, const string&);
45     std::multimap<string,string> m_map;
46     char m_is_opt_set[p_last_item];
47 };
48
49 #endif