30 #include <boost/algorithm/string.hpp> 31 #include <boost/unordered_set.hpp> 41 std::string& outstring)
43 std::vector<std::string> vec;
44 boost::unordered_set<std::string>
set;
45 boost::split(vec, instring,
46 boost::is_any_of(
"\t "),
47 boost::token_compress_on);
49 std::reverse(vec.begin(), vec.end());
50 std::vector<std::string> vec_out;
51 for(std::vector<std::string>::const_iterator it = vec.begin();
55 if(
set.find(*it) ==
set.end())
57 vec_out.push_back(*it);
62 std::reverse(vec_out.begin(), vec_out.end());
63 for(std::vector<std::string>::const_iterator it = vec_out.begin();
67 if(it == vec_out.begin())
68 outstring.append(*it);
70 outstring.append(std::string(
" ") + *it);
76 const std::string& token,
79 std::string& outstring)
81 std::string intermediate;
82 std::vector<std::string> result_vec;
83 boost::split(result_vec, instring,
84 boost::is_any_of(
"\t "),
85 boost::token_compress_on);
86 for(std::vector<std::string>::const_iterator it = result_vec.begin();
87 it != result_vec.end();
91 if(it->size() > token.size() && it->substr(0,token.size()) == token)
95 if(intermediate.size())
96 intermediate.append(
" ");
97 intermediate.append(it->substr(token.size()));
101 else if((*it) == token)
103 std::vector<std::string>::const_iterator iit = it;
104 if(++iit != result_vec.end())
106 if(it->size() >= token.size() && it->substr(0,token.size()) == token)
114 if(intermediate.size())
115 intermediate.append(
" ");
116 intermediate.append((*iit));
123 else if(it->size() > 2 &&
125 it->substr(it->size()-2) ==
".a")
129 if(intermediate.size())
130 intermediate.append(
" ");
131 intermediate.append((*it));
136 if(intermediate.size())
137 intermediate.append(
" ");
138 intermediate.append((*it));
144 outstring = intermediate;
void parse_compiler_flags(const std::string &instring, const std::string &token, bool select, bool last, std::string &outstring)
void deduplicate_tokens(const std::string &instring, bool last, std::string &outstring)