00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "lib/cmdline.hpp"
00026 #include "lib/util.hpp"
00027 #include "include/nobugcfg.h"
00028
00029 #include <boost/regex.hpp>
00030 #include <boost/algorithm/string/split.hpp>
00031 #include <boost/algorithm/string/join.hpp>
00032 #include <boost/algorithm/string/classification.hpp>
00033
00034 using boost::algorithm::split;
00035 using boost::algorithm::join;
00036 using boost::algorithm::is_any_of;
00037 using boost::algorithm::token_compress_on;
00038 using boost::regex;
00039 using boost::smatch;
00040 using boost::regex_search;
00041
00042 using boost::regex;
00043 using boost::smatch;
00044 using boost::regex_search;
00045
00046
00047
00048 #include <iostream>
00049
00050 namespace util
00051 {
00052
00055 Cmdline::Cmdline (int argc, const char** argv)
00056 : vector<string> (noneg(argc-1))
00057 {
00058 for (int i=1; i<argc; ++i)
00059 {
00060 ASSERT (argv[i]);
00061 (*this)[i-1] = argv[i];
00062 }
00063 }
00064
00065
00069 Cmdline::Cmdline (const string cmdline)
00070 {
00071 regex tokendef("[^ \r\n\t]+");
00072 smatch match;
00073 string::const_iterator it = cmdline.begin();
00074 string::const_iterator end = cmdline.end();
00075
00076 while (regex_search(it, end, match, tokendef))
00077 {
00078 string ss(match[0]);
00079 this->push_back(ss);
00080 it = match[0].second;
00081 }
00082
00083 }
00084
00085
00087 Cmdline::operator string () const
00088 {
00089 return join(*this," ");
00090 }
00091
00092
00093
00094 }