/home/matthew/data/programming/current/libircpp/parser.h

00001 /* 
00002  * libircpp++ parser.h
00003  */
00004 #ifndef __PARSER_H__
00005 #define __PARSER_H__
00006 
00007 #include <string>
00008 #include <boost/signal.hpp>
00009 #include "entity.h"
00010 #include "user.h"
00011 #include "channel.h"
00012 #include "message.h"
00013 
00014 /* Note about sig_message:
00015  *
00016  * The slot group ordering on sig_message is critical to the integrity of the various
00017  * user and channel lists. The ordering should be as follows:
00018  *
00019  * (first)
00020  * 20 - mainuserlist::pre_names_slot
00021  * 30 - channeluserlist::pre_message_slot (pre_names & pre_leave signals)
00022  * 40 - session::message_sorter (emits user-facing signals)
00023  * 50 - channellist::post_leave_slot
00024  * 60 - channeluserlist::post_leave_slot
00025  * 70 - mainuserlist::post_quit_slot
00026  * (last)
00027  */ 
00028 
00029 namespace ircpp {
00030 
00031         class session;
00032         class message;
00033 
00034         class parser 
00035         {
00036                 /* Interface functions */
00037                 public:
00038                         /* Constructors and destructors */
00039                         explicit parser(session& parent);
00040                         ~parser();
00041 
00042                         /* Data functions */
00043                         bool supply_buffer(const std::string &data);
00044 
00045                         /* Signals */
00046                         boost::signal1<void, message&> sig_message; /* Main message signal - emitted for every message parsed */
00047                         boost::signal1<void, message&> sig_singlemode; /* A "fake" mode message emitted for each mode letter received */
00048                         boost::signal1<void, const std::string&> sig_parseerror; /* Emitted upon parse error. Contains offending string */
00049 
00050                         /* Internal signals - used for updating objects */
00051                         boost::signal2<void, const std::string&, const std::string&> sig_pre_join; /* emitted just before a user joins a channel */
00052                         boost::signal1<void, message&> sig_pre_names; /* emitted just before a names-reply message is emitted */
00053                         boost::signal1<void, const message&> sig_update_data; /* emitted when various data available for storage e.g. whois replies */
00054 
00055                 /* Private functions */
00056                 private:
00057                         void parse_lines();
00058                         void parse_params(message& msg, const size_t params_pos);
00059                         void parse_modes(const message& msg);
00060                         void process_message(const std::string& line);
00061                         void get_next_word(std::istringstream& stream, std::string& into);
00062                         user* get_user(const std::string& nick, bool add = false);
00063                         channel* get_channel(const std::string& name);
00064                         entity* fill(const std::string& name);
00065 
00066 
00067 
00068                 /* Private data */
00069                 private:
00070                         session& s;
00071                         std::string buffer;
00072         };
00073 
00074 } /* namespace ircpp */
00075 
00076 #endif /* __PARSER_H__ */

Generated on Sat Oct 13 23:35:40 2007 for libircpp by  doxygen 1.5.3