00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef PCAP_LIST_OF_TRACES_HXX_
00023 # define PCAP_LIST_OF_TRACES_HXX_
00024
00025 # include <boost/tokenizer.hpp>
00026 # include <boost/foreach.hpp>
00027
00028 # include "list_of_traces.hh"
00029
00030 namespace pcapxx
00031 {
00032
00033 template <class Desc, class Bottom>
00034 list_of_traces<Desc, Bottom>::list_of_traces(const std::string& trace_names,
00035 const std::string& separators)
00036 {
00037 typedef boost::char_separator<char> separator_type;
00038 typedef boost::tokenizer<separator_type> tokenizer_type;
00039 typedef std::vector<std::string> vector;
00040
00041 const separator_type sep (separators.c_str());
00042 const tokenizer_type tok (trace_names, sep);
00043 vector names;
00044
00045 BOOST_FOREACH(const std::string& t, tok)
00046 names.push_back(t);
00047
00048 switch (names.size())
00049 {
00050 case 0:
00051 name_ = "[]";
00052 break;
00053 case 1:
00054 name_ = names.front();
00055 break;
00056 default:
00057 {
00058 size_t len = 0;
00059 bool cont = true;
00060
00061 while (cont and len <= names.front().size())
00062 {
00063 const std::string ref = names.front().substr(0, ++len);
00064
00065 for (size_t i = 1; cont and i < names.size(); ++i)
00066 if (names[i].substr(0, len) != ref)
00067 cont = false;
00068 }
00069 name_ = '[' + names.front().substr(0, len - 1) + "*]";
00070 break;
00071 }
00072 }
00073
00074 BOOST_FOREACH(const std::string& s, names)
00075 push_back(Desc (s));
00076 }
00077
00078 template <class Desc, class Bottom>
00079 const std::string&
00080 list_of_traces<Desc, Bottom>::file_name() const
00081 {
00082 return name_;
00083 }
00084
00085 template <class Desc, class Bottom>
00086 void
00087 list_of_traces<Desc, Bottom>::expect(typename Desc::link_type l) const
00088 {
00089 for (size_t i = 0; i < this->size(); ++i)
00090 this->get(i).expect(l);
00091 }
00092
00093 }
00094
00095 #endif // ! PCAP_LIST_OF_TRACES_HXX_