本文整理汇总了C++中stringlist::iterator类的典型用法代码示例。如果您正苦于以下问题:C++ iterator类的具体用法?C++ iterator怎么用?C++ iterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了iterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetAt
if(nIndex<0 || nIndex>=m_count) return (char*)" ";
STRINGLIST::iterator plist;
plist=m_lst.begin();
for(int i=0;i<nIndex;i++) plist++;
return (char*)plist->c_str();
}
void CSList::SetAt(char *buffer,int nIndex)
{
if(nIndex<0 || nIndex>=m_count) return;
STRINGLIST::iterator plist;
plist=m_lst.begin();
for(int i=0;i<nIndex;i++)
plist++;
示例2: serializeStrList
ustring DataValue::serializeStrList(void *value) {
ustring result("#");
StringList list;
list = *(ustring*)value;
for(StringList::iterator line = list.begin(); line != list.end(); line++)
result += int_to_str(line->size()) + ":" + *line + "|";
return result;
}
示例3: parse_error
Command::Command(const char* first, const char* last) throw(parse_error)
: from(INVALID_SID), to(INVALID_SID), dirty(false), full(first, last)
{
initNumPosParams();
// optimize later
// this is lazy due to a DC++ bug that sends empty parameters...
// ideally, we should not be using it
StringList sl = Util::lazyStringTokenize(full);
full += '\n';
if(full.size() < 5 || sl[0].size() != 4)
throw parse_error("invalid message type");
action = sl[0][0];
cmd = (CmdInt)(stringToFourCC(sl[0]) & 0xFFFFFF00);
StringList::size_type loc; // message parameters start at this index
switch(action) {
case 'F':
from = ADC::toSid(sl[1]);
features = sl[2];
checkFeatures();
loc = 3;
break;
case 'D':
case 'E':
from = ADC::toSid(sl[1]);
to = ADC::toSid(sl[2]);
loc = 3;
break;
case 'B':
case 'S':
from = ADC::toSid(sl[1]);
loc = 2;
break;
case 'I':
case 'H':
case 'L':
loc = 1;
break;
default:
throw parse_error(string("invalid action type '") + action + '\'');
}
if (loc >= sl.size())
throw parse_error("not enough tokens for message type");
if (numPosParams.count(cmd)) {
// known command -- check that positional and named params are correct
if (loc + numPosParams[cmd] > sl.size())
throw parse_error("missing parameters");
for (StringList::iterator i = sl.begin() + loc + numPosParams[cmd]; i != sl.end(); ++i) {
// param name parts can't be escaped chars
if (i->size() < 2 || ADC::CSE(i->substr(0, 2)).size() != 2)
throw parse_error("invalid named parameter: " + *i);
}
}
params.resize(sl.size() - loc);
transform(sl.begin() + loc, sl.end(), params.begin(), &ADC::CSE);
}
示例4: printf
Console::~Console() // Destructor
{
if (print_on_delete) {
StringList::iterator i;
for (i = loglines.end();;) {
--i;
printf("%s\n", i->c_str());
if (i == loglines.begin()) {
break;
}
}
}
if (save_to_file) {
out.close();
}
}
示例5: Plugin
void Kernel::LoadPlugins (std::string & dir)
{
StringList files ;
ListFiles (dir.c_str(), "*.so", files) ;
for (StringList::iterator it = files.begin(); it != files.end(); ++it) {
string full = dir + "/" + it->c_str() ;
Plugin *p = new Plugin (full) ;
if (p->Register(*this) ) {
this->_loadedPlugins.insert(PluginMap::value_type(*it, p)) ;
DOMOASTER_INFO << "\t- " << it->c_str() << " : OK";
} else {
delete p ;
DOMOASTER_WARN << "\t- " << it->c_str() << " : KO";
}
}
}
示例6: main
int main(int argc, char **argv) {
const char *xml = "<verse osisID=\"John.1.1\" type=\'test type\' yeah = \"stuff\" />";
cout << ((argc > 1) ? argv[1]: xml) << "\n";
XMLTag x((argc > 1) ? argv[1] : xml);
cout << x.toString() << "\n";
x.setAttribute("addedAttribute", "with a \" quote");
cout << x.toString() << "\n";
cout << "Tag name: [" << x.getName() << "]\n";
StringList attributes = x.getAttributeNames();
for (StringList::iterator it = attributes.begin(); it != attributes.end(); it++) {
const char *name = it->c_str();
cout << " - attribute: [" << name << "] = [";
cout << x.getAttribute(name) << "]\n";
int count = x.getAttributePartCount(name, ' ');
cout << "\t" << count << " parts:\n";
int i = (count > 1) ? 0 : -1; // -1 for whole value cuz it's faster, but does the same thing as 0
do {
cout << "\t" << x.getAttribute(name, i, ' ') << "\n";
if (i < 0) i = 0; // to handle our -1 condition
} while (++i < count);
}
cout << " isEmpty: " << x.isEmpty() << "\n";
cout << " isEndTag: " << x.isEndTag() << "\n";
cout << "\n";
if (argc < 2) { // only run if we're defaulted
const char *testParts="ABC D EF GHIJ";
cout << "Setting attribute 'multiPart' to: '" << testParts << "'\n";
x.setAttribute("multiPart", testParts);
cout << x << "\n";
cout << "Setting part 2 to 'MMM'\n";
x.setAttribute("multiPart", "MMM", 2, ' ');
cout << x << "\n";
cout << "Removing part 1\n";
x.setAttribute("multiPart", 0, 1, ' ');
cout << x << "\n";
cout << "Removing part 2\n";
x.setAttribute("multiPart", 0, 2, ' ');
cout << x << "\n";
}
}
示例7: Update
void ListBox::Update()
{
StringList::iterator it = m_messages.begin();
for (uint16 i = 0; i < m_curLineIndex; i++)
{
if (it != m_messages.end())
++it;
}
for(uint16 i = 0; i < m_lineNbr; ++i)
{
if (it == m_messages.end())
m_lines[i]->SetMsg("");
else {
m_lines[i]->SetMsg(it->data());
++it;
}
}
}
示例8: find
String File::find(const String& filename, StringList directories)
{
String filename_new = filename;
// empty string cannot be found, so throw Exception.
// The code below would return success on empty string, since a path is prepended and thus the location exists
if (filename_new.trim().empty()) throw Exception::FileNotFound(__FILE__, __LINE__, __PRETTY_FUNCTION__, filename);
//add data dir in OpenMS data path
directories.push_back(getOpenMSDataPath());
//add path suffix to all specified directories
String path = File::path(filename);
if (path != "")
{
for (StringList::iterator it = directories.begin(); it != directories.end(); ++it)
{
it->ensureLastChar('/');
*it += path;
}
filename_new = File::basename(filename);
}
//look up file
for (StringList::const_iterator it = directories.begin(); it != directories.end(); ++it)
{
String loc = *it;
loc.ensureLastChar('/');
loc = loc + filename_new;
if (exists(loc))
{
return String(QDir::cleanPath(loc.toQString()));
}
}
//if the file was not found, throw an exception
throw Exception::FileNotFound(__FILE__, __LINE__, __PRETTY_FUNCTION__, filename);
//this is never reached, but needs to be there to avoid compiler warnings
return "";
}
示例9: ShowMessages
void TextManager::ShowMessages()
{
STRINGLIST::iterator it;
World.getTextManager().ClearDisplayLines();
SetDisplayLine(0, "Previous Messages");
SetDisplayLine(1, "=================");
SetDisplayLine(2, "");
int i = 3;
for (it = messageList.begin(); it != messageList.end(); it++, i++)
{
SetDisplayLine(i, (char *)it->c_str());
}
SetDisplayLine(39, "[+/-] scroll - [x] to exit");
}
示例10: load
void DiskDir::load()
{
_files.clear();
_subdirs.clear();
// TODO: cache existing files and keep them unless they do no longer exist
StringList li;
GetFileList(fullname(), li);
for(StringList::iterator it = li.begin(); it != li.end(); ++it)
{
DiskFile *f = new DiskFile(joinPath(fullname(), it->c_str()).c_str());
_files[f->name()] = f;
}
li.clear();
GetDirList(fullname(), li, 0);
for(StringList::iterator it = li.begin(); it != li.end(); ++it)
{
// GetDirList() returns relative paths, so need to join
Dir *d = createNew(joinPath(fullname(), it->c_str()).c_str());
_subdirs[d->name()] = d;
}
}
示例11: FileExtensions
StringList FileFormat::FileExtensions() const
{
size_type count = 0;
size_type maxLen = 0;
(*API->FileFormat->GetFileFormatFileExtensions)( m_data->handle, 0, &count, &maxLen );
StringList extensions( count );
if ( count > 0 )
{
Array<char16_type*> ptrs;
for ( size_type i = 0; i < count; ++i )
{
extensions[i].Reserve( maxLen );
ptrs.Add( extensions[i].c_str() );
}
if ( (*API->FileFormat->GetFileFormatFileExtensions)( m_data->handle, ptrs.Begin(), &count, &maxLen ) == api_false )
throw APIFunctionError( "GetFileFormatFileExtensions" );
for ( StringList::iterator i = extensions.Begin(); i != extensions.End(); ++i )
i->ResizeToNullTerminated();
}
return extensions;
}
示例12: processText
char ThMLFootnotes::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
SWBuf token;
bool intoken = false;
bool hide = false;
SWBuf tagText;
XMLTag startTag;
SWBuf refs = "";
int footnoteNum = 1;
char buf[254];
SWKey *p = (module) ? module->createKey() : (key) ? key->clone() : new VerseKey();
VerseKey *parser = SWDYNAMIC_CAST(VerseKey, p);
if (!parser) {
delete p;
parser = new VerseKey();
}
*parser = key->getText();
SWBuf orig = text;
const char *from = orig.c_str();
for (text = ""; *from; from++) {
if (*from == '<') {
intoken = true;
token = "";
continue;
}
if (*from == '>') { // process tokens
intoken = false;
XMLTag tag(token);
if (!strcmp(tag.getName(), "note")) {
if (!tag.isEndTag()) {
if (!tag.isEmpty()) {
refs = "";
startTag = tag;
hide = true;
tagText = "";
continue;
}
}
if (hide && tag.isEndTag()) {
if (module->isProcessEntryAttributes()) {
SWBuf fc = module->getEntryAttributes()["Footnote"]["count"]["value"];
footnoteNum = (fc.length()) ? atoi(fc.c_str()) : 0;
sprintf(buf, "%i", ++footnoteNum);
module->getEntryAttributes()["Footnote"]["count"]["value"] = buf;
StringList attributes = startTag.getAttributeNames();
for (StringList::iterator it = attributes.begin(); it != attributes.end(); it++) {
module->getEntryAttributes()["Footnote"][buf][it->c_str()] = startTag.getAttribute(it->c_str());
}
module->getEntryAttributes()["Footnote"][buf]["body"] = tagText;
startTag.setAttribute("swordFootnote", buf);
if ((startTag.getAttribute("type")) && (!strcmp(startTag.getAttribute("type"), "crossReference"))) {
if (!refs.length())
refs = parser->parseVerseList(tagText.c_str(), *parser, true).getRangeText();
module->getEntryAttributes()["Footnote"][buf]["refList"] = refs.c_str();
}
}
hide = false;
if ((option) || ((startTag.getAttribute("type") && (!strcmp(startTag.getAttribute("type"), "crossReference"))))) { // we want the tag in the text; crossReferences are handled by another filter
text += startTag;
text.append(tagText);
}
else continue;
}
}
// if not a note token, keep token in text
if ((!strcmp(tag.getName(), "scripRef")) && (!tag.isEndTag())) {
SWBuf osisRef = tag.getAttribute("passage");
if (refs.length())
refs += "; ";
refs += osisRef;
}
if (!hide) {
text += '<';
text.append(token);
text += '>';
}
else {
tagText += '<';
tagText.append(token);
tagText += '>';
}
continue;
}
if (intoken) { //copy token
token += *from;
}
else if (!hide) { //copy text which is not inside a token
text += *from;
}
else tagText += *from;
}
delete parser;
return 0;
}
示例13: BookViewToolBar
//.........这里部分代码省略.........
menuWindow->Append(ID_MenuNewTab, _("&New Tab"));
menuWindow->Append(ID_MenuCloseTab, _("Close Tab"));
menuWindow->Append(ID_MenuCloseOtherTabs, _("Close Other Tabs"));
menuWindow->Append(ID_MenuDetachTab, _("Detach Tab"));
menuWindow->Append(ID_MenuDuplicateTab, _("Duplicate Tab"));
StringList optlist;
optlist = m_SwordTools->GetSwordManager()->getGlobalOptions();
// unsigned char mychars[13];
// mychars[0] = 68;
// mychars[1] = 69;
// mychars[2] = 226;
// mychars[3] = 128;
// mychars[4] = 156;
// mychars[5] = 67;
// mychars[6] = 46;
// mychars[7] = 46;
// mychars[8] = 46;
// mychars[9] = 226;
// mychars[10] = 128;
// mychars[11] = 157;
// mychars[12] = 0;
//
// wxString leftquote = wxString((const char *)mychars, wxConvUTF8);
//
// wxMessageBox(leftquote, wxT("Quote Test"), wxOK |
// wxICON_INFORMATION, this);
/*
* Add global options reported by SwordManager
*/
StringList::iterator it;
int id = ID_MenuTopBookOption;
menuOptions->Append(ID_MenuSearch, _("Search"));
menuOptions->AppendSeparator();
menuOptions->Append(ID_MenuPrefs, _("Preferences"));
menuOptions->AppendSeparator();
for (it = optlist.begin(); it != optlist.end(); it++)
{
menuOptions->AppendCheckItem(id, wxString(it->c_str(), wxConvUTF8),
wxString(m_SwordTools->GetSwordManager()->
getGlobalOptionTip(it->c_str()),
wxConvUTF8));
/*
* If global option is on, check the menu item
*/
if (!strcmp
(m_SwordTools->GetSwordManager()->getGlobalOption(it->c_str()), "On"))
{
menuOptions->Check(id, true);
}
else
{
menuOptions->Check(id, false);
}
id++;
}
// menuBibleStudies->Append(ID_MenuBibleStudyWhy, wxT("Why Should I
// Become a Christian?"));
menuBibleStudies->Append(ID_MenuBibleStudyHow,
示例14: searchProc
void SearchContext::searchProc()
{
int id = searchID_;
HANDLE findHandle = INVALID_HANDLE_VALUE;
StringList paths;
paths = params_.paths;
RegexList filespecRegexes;
pcre *matchRegex = NULL;
directoriesSearched_ = 0;
directoriesSkipped_ = 0;
filesSearched_ = 0;
filesSkipped_ = 0;
filesWithHits_ = 0;
linesWithHits_ = 0;
hits_ = 0;
unsigned int startTick = GetTickCount();
bool filespecUsesRegexes = ((params_.flags & SF_FILESPEC_REGEXES) != 0);
bool matchUsesRegexes = ((params_.flags & SF_MATCH_REGEXES) != 0);
delete pokeData_;
pokeData_ = new PokeData;
if(matchUsesRegexes)
{
const char *error;
int erroffset;
int flags = 0;
if(!(params_.flags & SF_MATCH_CASE_SENSITIVE))
flags |= PCRE_CASELESS;
matchRegex = pcre_compile(params_.match.c_str(), flags, &error, &erroffset, NULL);
if(!matchRegex)
{
MessageBox(window_, error, "Match Regex Error", MB_OK);
goto cleanup;
}
}
for(StringList::iterator it = params_.filespecs.begin(); it != params_.filespecs.end(); ++it)
{
std::string regexString = it->c_str();
if(!filespecUsesRegexes)
convertWildcard(regexString);
int flags = 0;
if(!(params_.flags & SF_FILESPEC_CASE_SENSITIVE))
flags |= PCRE_CASELESS;
const char *error;
int erroffset;
pcre *regex = pcre_compile(regexString.c_str(), flags, &error, &erroffset, NULL);
if(regex)
filespecRegexes.push_back(regex);
else
{
MessageBox(window_, error, "Filespec Regex Error", MB_OK);
goto cleanup;
}
}
PostMessage(window_, WM_SEARCHCONTEXT_STATE, 1, 0);
while(!paths.empty())
{
directoriesSearched_++;
stopCheck();
std::string currentSearchPath = paths.back();
std::string currentSearchWildcard = currentSearchPath + "\\*";
paths.pop_back();
WIN32_FIND_DATA wfd;
findHandle = FindFirstFile(currentSearchWildcard.c_str(), &wfd);
if(findHandle == INVALID_HANDLE_VALUE)
continue;
while(FindNextFile(findHandle, &wfd))
{
stopCheck();
bool isDirectory = ((wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0);
if((wfd.cFileName[0] == '.') || (wfd.cFileName[0] == 0))
{
if(isDirectory)
directoriesSkipped_++;
else
filesSkipped_++;
continue;
}
std::string filename = currentSearchPath;
filename += "\\";
filename += wfd.cFileName;
if(isDirectory)
{
if(params_.flags & SF_RECURSIVE)
//.........这里部分代码省略.........
示例15: HandleRequest
// creates a page based on user input -- either displays data from
// form or presents a form for users to submit data.
ResponseCode FormTester::HandleRequest ( HttpRequest * ipoHttpRequest,
HttpResponse * ipoHttpResponse )
{
char psHtml[ 5000 ];
// if we got data from the user, show it
if ( ipoHttpRequest->oFormValueMap [ "user" ].sBody.length ( ) ||
ipoHttpRequest->oFormValueMap [ "existinguser" ].sBody.length ( ) ) {
std::string sName;
sName = ipoHttpRequest->oFormValueMap [ "existinguser" ].sBody;
if ( ipoHttpRequest->oFormValueMap [ "user" ].sBody.length() ) {
sName = ipoHttpRequest->oFormValueMap [ "user" ].sBody;
}
fprintf ( stderr, "Got name of %s\n", sName.c_str ( ) );
char * psHtml = new char [ 5000 ];
sprintf ( psHtml, "<html><head><title>StringList</title></head>\n<body>Hi %s</body></html>", sName.c_str ( ) );
oNameList.push_back ( sName );
ipoHttpResponse->SetBody( psHtml, strlen( psHtml ) );
return HTTPRESPONSECODE_200_OK;
} else {
// otherwise, present the form to the user to fill in
fprintf ( stderr, "Got no form data\n" );
// create the options for the dropdown box
char * psOptions;
if ( oNameList.size ( ) > 0 )
psOptions = new char [ oNameList.size ( ) * 200 ];
else
psOptions = new char [1];
psOptions [ 0 ] = '\0';
for ( StringList::iterator oCurrentName = oNameList.begin();
oCurrentName != oNameList.end ( );
oCurrentName++ ) {
char psOption [ 200 ];
sprintf ( psOption, "<option>%s\n",
oCurrentName->substr ( 0, 150 ).c_str ( ) );
strcat ( psOptions, psOption );
}
sprintf ( psHtml, "<html><head><title>StringList</title></head> <body>Please log in<P> <form action = \"/\" method=GET> User name: <input type = text name = user><BR> <select name = existinguser width = 20> %s </select> <input type = submit> </form>\n",
psOptions );
delete[] psOptions;
ipoHttpResponse->SetBody( psHtml, strlen( psHtml ) );
return HTTPRESPONSECODE_200_OK;
}
}