本文整理汇总了C++中strings::end方法的典型用法代码示例。如果您正苦于以下问题:C++ strings::end方法的具体用法?C++ strings::end怎么用?C++ strings::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类strings
的用法示例。
在下文中一共展示了strings::end方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: join
const std::string
join (const strings& ss, const std::string& separator)
{
std::string s;
for (strings::const_iterator ssi = ss.begin ();
ssi != ss.end ();
++ssi)
{
s += *ssi;
if ((ssi + 1) != ss.end ())
s += separator;
}
return s;
}
示例2: unlines2
string unlines2(strings elems) {
stringstream ss;
std::for_each(elems.begin(), elems.end(), [&ss](const string& s) {
ss << s << std::endl;
});
return ss.str();
}
示例3: encount
std::map<std::string, int> encount(std::istream *in, const strings &searched)
{
std::map<std::string,int> result;
std::vector<s_info> watched;
// insert all string from searched with 0 frequency
for (s_citer iter = searched.begin(), end = searched.end(); iter != end; ++iter)
{
result[*iter] = 0;
if (iter->begin() != iter->end())
watched.push_back(s_info(&(*iter)));
}
char ch;
while (in->get(ch))
{
for (std::vector<s_info>::iterator iter = watched.begin(), end = watched.end(); iter != end; ++iter)
{
if (ch == iter->curr())
{
iter->current++;
if (iter->isEnd())
{
result[*(iter->pstr)]++;
iter->reset();
}
}
else iter->reset();
}
}
return result;
}
示例4: listOggfiles
void GUIPlayer::listOggfiles(const string& dirPath, strings& oggFiles)
{
DIR* dir;
if ((dir = opendir(dirPath.data())) == NULL)
{
return;
}
struct dirent* entry;
while ((entry = readdir(dir)) != NULL)
{
string name = entry->d_name;
if (StringHelper::endsWith(upperCase(name), ".OGG"))
{
name = "/" + name;
name = dirPath + name;
oggFiles.push_back(name);
}
}
// hack
// we hope startup.ogg to be the first.
reverse(oggFiles.begin(), oggFiles.end());
closedir(dir);
}
示例5: filedrop_attachments_impl
void engine::filedrop_attachments_impl(std::string server, const std::string& key,
const std::string& user, const std::string& subject,
const std::string& message, const strings& fs, report_level s)
{
curl_easy_setopt(m_curl, CURLOPT_URL, server.c_str());
curl_header_guard hg(m_curl);
std::string data = std::string(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\
<message>\
<api_key>") + key + std::string("</api_key>\
<from>") + user + std::string("</from>\
<subject>") + subject + std::string("</subject>\
<message>") + message + std::string("</message>\
<attachments type='array'>\
");
for (strings::const_iterator i = fs.begin(); i != fs.end(); ++i) {
data += " <attachment>";
data += *i;
data += "</attachment>\n";
}
data += " </attachments>\
</message>\n";
curl_easy_setopt(m_curl, CURLOPT_HTTPPOST, 0);
curl_easy_setopt(m_curl, CURLOPT_POSTFIELDS, data.c_str());
if (s >= NORMAL) {
io::mout << "Sending message to filedrop" << io::endl;
}
process_filedrop_responce(perform(), s);
}
示例6: selectFromMenu
int Twindow::selectFromMenu(const strings &items,int id,bool translate,int columnHeight)
{
Tstrptrs ptritems;
for (strings::const_iterator s=items.begin(); s!=items.end(); s++) {
ptritems.push_back(s->c_str());
}
ptritems.push_back(NULL);
return selectFromMenu(&ptritems[0],id,translate,columnHeight);
}
示例7: fixRelativePaths
static void fixRelativePaths(strings &dirs, const char_t *basepath)
{
for (strings::iterator d = dirs.begin(); d != dirs.end(); d++)
if (PathIsRelative(d->c_str())) {
char_t absdir[MAX_PATH];
_makepath_s(absdir, countof(absdir), NULL, basepath, d->c_str(), NULL);
char_t absdirC[MAX_PATH];
PathCanonicalize(absdirC, absdir);
*d = absdirC;
}
}
示例8: findPossibleSubtitles
void TsubtitlesFile::findPossibleSubtitles(const char_t *dir, strings &files)
{
char_t autosubmask[MAX_PATH];
_makepath_s(autosubmask, MAX_PATH, NULL, dir,/*name*/_l("*"), _l("*"));
strings files0;
findFiles(autosubmask, files0);
for (strings::iterator f = files0.begin(); f != files0.end(); f++)
if (extMatch(f->c_str())) {
files.push_back(*f);
}
std::sort(files.begin(), files.end(), ffstring_iless());
}
示例9: attach
void engine::attach(std::string server,
const std::string& key,
const strings& fs,
report_level s,
validate_cert v)
{
init_curl(key, s, v);
strings::const_iterator i = fs.begin();
for (; i != fs.end(); ++i) {
attach_impl(server, *i, s);
}
}
示例10: evSubscribe
void HttpInterface::evSubscribe(HttpRequest* req, strings& args)
{
// eventSubscriptions[conn] is an unordered set of strings
if (args.size() == 1)
eventSubscriptions[req].insert("*");
else
for (strings::iterator i = args.begin()+1; i != args.end(); ++i)
eventSubscriptions[req].insert(*i);
strings headers;
headers.push_back("Content-Type: text/event-stream");
headers.push_back("Cache-Control: no-cache");
headers.push_back("Connection: keep-alive");
addHeaders(req, headers);
appendResponse(req,200,true,"");
// connection must stay open!
}
示例11: send
std::string engine::send(std::string server,
const std::string& key,
const std::string& user,
const std::string& subject,
const std::string& message,
const strings& fs,
report_level s,
validate_cert v)
{
init_curl(key, s, v);
std::set<std::string> attachments;
strings::const_iterator i = fs.begin();
for (; i != fs.end(); ++i) {
std::string a = attach_impl(server, *i, s);
attachments.insert(a);
}
return send_attachments_impl(server, user, subject, message,
attachments, s);
}
示例12: findAnagrams
strings findAnagrams(const strings &words, const string &word) {
unordered_multimap<string, string> hashed;
string tmpWord;
for (auto iter = words.begin(); iter != words.end(); iter++) {
tmpWord = (*iter);
sort(tmpWord.begin(), tmpWord.end());
hashed.insert(make_pair(tmpWord, *iter));
}
tmpWord = word;
sort(tmpWord.begin(), tmpWord.end());
auto range = hashed.equal_range(tmpWord);
strings result;
while (range.first != range.second) {
result.push_back(range.first->second);
range.first++;
}
return result;
}
示例13: filedrop
void engine::filedrop(std::string server,
const std::string& user,
const std::string& subject,
const std::string& message,
const strings& fs,
report_level s,
validate_cert v)
{
std::string key = get_filedrop_api_key(server, s, v);
init_curl(key, s, v);
strings::const_iterator i = fs.begin();
strings rs;
std::string url = get_server_from_filedrop(server);
for (; i != fs.end(); ++i) {
std::string id = attach_impl(url, *i, s);
rs.insert(id);
}
curl_easy_setopt(m_curl, CURLOPT_USERPWD, "");
filedrop_attachments_impl(server, key, user, subject, message,
rs, s);
}
示例14: parse_json_form
// Utility: extract argument values from JSON request body
void HttpInterface::parse_json_form(std::string content, strings& values)
{
std::string buffer = content;
buffer.erase(std::remove_if(buffer.begin(), buffer.end(), ::isspace), buffer.end());
std::stringstream ss(buffer);
if (ss.get() == '[')
{
int i;
while (ss >> i)
{
// values.push_back(std::to_string(short(i)));
std::stringstream valss;
valss << short(i);
values.push_back(valss.str());
if (ss.peek() == ']')
break;
else if (ss.peek() == ',')
ss.ignore();
}
if (ss.get() != ']')
values.erase(values.begin(),values.end());
}
示例15: exists
std::pair<unsigned,unsigned> HttpInterface::sendGetVariables(const std::string nodeName, const strings& args)
{
unsigned nodePos, varPos;
for (strings::const_iterator it(args.begin()); it != args.end(); ++it)
{
// get node id, variable position and length
if (verbose)
cerr << "getVariables " << nodeName << " " << *it;
const bool exists(getNodeAndVarPos(nodeName, *it, nodePos, varPos));
if (!exists)
continue;
VariablesMap vm = allVariables[nodeName];
const unsigned length(vm[UTF8ToWString(*it)].second);
if (verbose)
cerr << " (" << nodePos << "," << varPos << "):" << length << "\n";
// send the message
GetVariables getVariables(nodePos, varPos, length);
getVariables.serialize(asebaStream);
}
asebaStream->flush();
return std::pair<unsigned,unsigned>(nodePos,varPos); // just last one
}