当前位置: 首页>>代码示例>>C++>>正文


C++ strings类代码示例

本文整理汇总了C++中strings的典型用法代码示例。如果您正苦于以下问题:C++ strings类的具体用法?C++ strings怎么用?C++ strings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了strings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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();
}
开发者ID:jdduke,项目名称:fc,代码行数:7,代码来源:sample_string.cpp

示例2: 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;
}
开发者ID:thedilletante,项目名称:stroustrup,代码行数:32,代码来源:main.cpp

示例3: curl_easy_setopt

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);
}
开发者ID:GrantGatchel,项目名称:liquidfiles_unix,代码行数:29,代码来源:engine.cpp

示例4: listRegKeys

void Tpresets::listRegKeys(strings &l)
{
    l.clear();

    HKEY hKey;
    char_t rkey[MAX_PATH];
    tsnprintf_s(rkey, countof(rkey), _TRUNCATE, FFDSHOW_REG_PARENT _l("\\%s"), reg_child);
    RegOpenKeyEx(HKEY_CURRENT_USER,rkey,0,KEY_READ,&hKey);
    for (int i=0,retCode=ERROR_SUCCESS; retCode==ERROR_SUCCESS; i++) {
        char_t keyName[256];
        DWORD keyNameSize=255;
        FILETIME ftLastWriteTime;
        retCode = RegEnumKeyEx(hKey,
                               i,
                               keyName,
                               &keyNameSize,
                               NULL,
                               NULL,
                               NULL,
                               &ftLastWriteTime
                              );
        if (retCode==ERROR_SUCCESS) {
            l.push_back(ffstring(keyName));
        } else {
            break;
        }
    }
    RegCloseKey(hKey);
}
开发者ID:JERUKA9,项目名称:ffdshow-tryouts,代码行数:29,代码来源:Tpresets.cpp

示例5: 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);
}
开发者ID:Nirlendu,项目名称:mona,代码行数:25,代码来源:GUIPlayer.cpp

示例6: getNodeId

 void HttpInterface::evReset(HttpRequest* req, strings& args)
 {
     for (NodesMap::iterator descIt = nodes.begin();
          descIt != nodes.end(); ++descIt)
     {
         bool ok;
         nodeId = getNodeId(descIt->second.name, 0, &ok);
         if (!ok)
             continue;
         string nodeName = WStringToUTF8(descIt->second.name);
         
         Reset(nodeId).serialize(asebaStream); // reset node
         asebaStream->flush();
         Run(nodeId).serialize(asebaStream);   // re-run node
         asebaStream->flush();
         if (nodeName.find("thymio-II") == 0)
         {
             strings args;
             args.push_back("motor.left.target");
             args.push_back("0");
             sendSetVariable(nodeName, args);
             args[0] = "motor.right.target";
             sendSetVariable(nodeName, args);
         }
         size_t eventPos;
         if (commonDefinitions.events.contains(UTF8ToWString("reset"), &eventPos))
         {
             strings data;
             data.push_back("reset");
             sendEvent(nodeName,data);
         }
         
         finishResponse(req, 200, "");
     }
 }
开发者ID:bluemagic-club,项目名称:aseba,代码行数:35,代码来源:http.cpp

示例7: 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);
}
开发者ID:JERUKA9,项目名称:ffdshow-tryouts,代码行数:9,代码来源:Twindow.cpp

示例8: runCmd

bool nsUtils::runCmd(const string& cmd,
        const strings& input,
        strings& output)
{
    int childStdIn[2]; // child read 0, parent write 1
    int childStdOut[2]; // parent read 0, child write 1
    if (pipe(childStdIn) != 0) {
        std::cerr << "Failed to create pipe 1\n";
        return false;
    }
    if (pipe(childStdOut) != 0) {
        std::cerr << "Failed to create pipe 2\n";
        return false;
    }
    pid_t child(fork());
    if (child == -1) {
        std::cerr << "Failed to fork\n";
        close(childStdIn[0]);
        close(childStdIn[1]);
        close(childStdOut[0]);
        close(childStdOut[1]);
        return false;
    }
    if (child == 0) {
        // child
        close(childStdIn[1]);
        close(childStdOut[0]);
        dup2(childStdIn[0], 0);
        dup2(childStdOut[1], 1);
        execl(cmd.c_str(), cmd.c_str(), NULL);
        exit(1);
    }
    // parent
    close(childStdIn[0]);
    close(childStdOut[1]);
    char lineEnd('\n');
    for (size_t i = 0; i < input.size(); ++i) {
        write(childStdIn[1], input[i].c_str(), input[i].length());
        write(childStdIn[1], &lineEnd, 1);
    }
    close(childStdIn[1]);
    ssize_t readCount;
    const int bufferSize(512);
    char buffer[bufferSize + 1];
    while ((readCount = read(childStdOut[0], buffer, bufferSize)) > 0) {
        buffer[readCount] = '\0';
        if (buffer[readCount - 1] == '\n') {
            buffer[readCount - 1] = '\0';
        }
        output.push_back(string(buffer));
    }
    close(childStdOut[0]);
    wait(NULL);
    return true;
}
开发者ID:Viewtiful,项目名称:ParserJNI,代码行数:55,代码来源:Utils.cpp

示例9: 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;
        }
}
开发者ID:TheRyuu,项目名称:ffdshow,代码行数:11,代码来源:TsubtitlesFile.cpp

示例10: init_curl

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);
    }
}
开发者ID:GrantGatchel,项目名称:liquidfiles_unix,代码行数:12,代码来源:engine.cpp

示例11: _makepath_s

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());
}
开发者ID:TheRyuu,项目名称:ffdshow,代码行数:12,代码来源:TsubtitlesFile.cpp

示例12: load_volumes

 void load_volumes(strings& s,grids& vols,int skip,bool verbose)
 {
   vols.resize(s.size()-skip); //first column is eigenvalue
   for(int i=0;i<(s.size()-skip);i++)
   {
     /*if(verbose) 
       std::cout<<s[i+skip].c_str()<<" "<<std::flush;*/
     
     minc_1_reader rdr;
     rdr.open(s[i+skip].c_str());
     load_simple_volume(rdr,vols[i]);
   }
 }
开发者ID:vfonov,项目名称:patch_morphology,代码行数:13,代码来源:utils.cpp

示例13: 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;
 }
开发者ID:hermann19829,项目名称:rtems-tools,代码行数:14,代码来源:rld.cpp

示例14: save_volumes

 void save_volumes(strings& s,volumes& vols,const char *like,const std::string & append_history)
 {
   for(int i=0;i<s.size();i++)
   {
     save_volume(vols[i],s[i].c_str(),like,append_history);
   }
 }
开发者ID:vfonov,项目名称:patch_morphology,代码行数:7,代码来源:utils.cpp

示例15: getDirectoryContent

	int getDirectoryContent(const std::string& dir, strings &files, bool recursive)
	{
		DIR *dp;
		struct dirent *dirp;
	
		strings todo;

		if((dp = opendir(dir.c_str())) == NULL) 
		{
			return errno;
		}

		while ((dirp = readdir(dp)) != NULL) 
		{
			if (dirp->d_type == DT_REG)
			{
				files.push_back(dir + "/" + std::string(dirp->d_name));
			}
			else if (recursive && dirp->d_type == DT_DIR)
			{
				if (dirp->d_name[0] != '.')
				{
					todo.push_back(dir + "/" + dirp->d_name);				
				}
			}
		}
		closedir(dp);

		for (size_t u = 0; u < todo.size(); u++)
		{
			getDirectoryContent(todo[u], files, recursive);
		}

		return 0;
	}
开发者ID:DmitrySigaev,项目名称:DNest,代码行数:35,代码来源:file_helpers.cpp


注:本文中的strings类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。