本文整理汇总了C++中stringlist::iterator::c_str方法的典型用法代码示例。如果您正苦于以下问题:C++ iterator::c_str方法的具体用法?C++ iterator::c_str怎么用?C++ iterator::c_str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stringlist::iterator
的用法示例。
在下文中一共展示了iterator::c_str方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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";
}
}
}
示例3: 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;
}
}
示例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: 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";
}
}
示例6: 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");
}
示例7: 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;
}
示例8: BookViewToolBar
//.........这里部分代码省略.........
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,
_("How Can I Become a Christian?"));
menuBibleStudies->Append(ID_MenuBibleStudyGrow,
_("How Can I Grow as a Christian?"));
wxMenuBar *menuBar = new wxMenuBar();
menuBar->Append(menuFile, _("&File"));
menuBar->Append(menuEdit, _("&Edit"));
menuBar->Append(menuBibleStudies, _("&Bible Studies"));
menuBar->Append(menuOptions, _("&Options"));
menuBar->Append(menuWindow, _("&Window"));
menuBar->Append(menuHelp, _("&Help"));
SetMenuBar(menuBar);
CreateStatusBar();
SetStatusText(_("Welcome to BibleStudy!"));
m_ToolBar =
new BookViewToolBar(this, ID_BookViewToolBar, wxTB_HORIZONTAL |
wxTB_FLAT | wxTB_TEXT | wxFULL_REPAINT_ON_RESIZE);
SetToolBar(m_ToolBar);
// Add the ReadingPlanner toolbar here.
m_PlanToolBar =
new ReadingPlannerToolBar(this, ID_ReadingPlannerToolBar, wxTB_HORIZONTAL |
wxTB_FLAT );
UpdatePlanToolBar();
ShowHidePlanBar(false);
SetupSplitterWindows();
LayoutChildren();
}
示例9: 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)
//.........这里部分代码省略.........
示例10: writeToFile
bool ObjectTemplateCustomizationDataWriter::writeToFile(const std::string &pathName, bool allowOverwrite)
{
//-- Don't write anything if there's no data to write.
bool hasData = false;
if (!m_paletteColorData->empty())
hasData = true;
if (!m_rangedIntData->empty())
hasData = true;
if (!hasData)
{
DEBUG_REPORT_LOG(true, ("writeToFile(): no data: skipped writing [%s].\n", pathName.c_str()));
return true;
}
//-- Handle no-overwrite case.
if (!allowOverwrite)
{
FILE *const testFile = fopen(pathName.c_str(), "r");
if (testFile != NULL)
{
fclose(testFile);
DEBUG_REPORT_LOG(true, ("writeToFile(): overwrite attempt: skipped writing [%s] because it already exists and allowOverwrite == false.\n", pathName.c_str()));
return false;
}
}
//-- open file
FILE *const file = fopen(pathName.c_str(), "w");
if (!file)
{
WARNING(true, ("failed to create file [%s].", pathName.c_str()));
return false;
}
//-- sort the output data
m_paletteColorData->sort();
m_rangedIntData->sort();
//-- write palette color variables
fprintf(file, "paletteColorCustomizationVariables = [");
{
int i = 0;
int const count = static_cast<int>(m_paletteColorData->size());
const StringList::iterator endIt = m_paletteColorData->end();
for (StringList::iterator it = m_paletteColorData->begin(); it != endIt; ++it, ++i)
{
if (i == (count - 1))
{
// -- Fixup last entry to use ] in place of final comma.
std::string::size_type position = it->rfind(',');
DEBUG_FATAL(static_cast<int>(position) == static_cast<int>(std::string::npos), ("bad data, where's the final comma?"));
(*it)[position] = ']';
}
fprintf(file, "\n %s", it->c_str());
}
}
if (m_paletteColorData->empty())
fprintf(file, "]");
fprintf(file, "\n\n");
//-- write ranged int variables
fprintf(file, "rangedIntCustomizationVariables = [");
{
int i = 0;
int const count = static_cast<int>(m_rangedIntData->size());
const StringList::iterator endIt = m_rangedIntData->end();
for (StringList::iterator it = m_rangedIntData->begin(); it != endIt; ++it, ++i)
{
if (i == (count - 1))
{
// -- Fixup last entry to use ] in place of final comma.
std::string::size_type position = it->rfind(',');
DEBUG_FATAL(static_cast<int>(position) == static_cast<int>(std::string::npos), ("bad data, where's the final comma?"));
(*it)[position] = ']';
}
fprintf(file, "\n %s", it->c_str());
}
}
if (m_rangedIntData->empty())
fprintf(file, "]");
fprintf(file, "\n\n");
fclose(file);
//-- return success
return true;
}