本文整理汇总了C++中StringList::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ StringList::begin方法的具体用法?C++ StringList::begin怎么用?C++ StringList::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringList
的用法示例。
在下文中一共展示了StringList::begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 "";
}
示例2: String
String ID3v2::Tag::genre() const
{
// TODO: In the next major version (TagLib 2.0) a list of multiple genres
// should be separated by " / " instead of " ". For the moment to keep
// the behavior the same as released versions it is being left with " ".
if(d->frameListMap["TCON"].isEmpty() ||
!dynamic_cast<TextIdentificationFrame *>(d->frameListMap["TCON"].front()))
{
return String();
}
// ID3v2.4 lists genres as the fields in its frames field list. If the field
// is simply a number it can be assumed that it is an ID3v1 genre number.
// Here was assume that if an ID3v1 string is present that it should be
// appended to the genre string. Multiple fields will be appended as the
// string is built.
TextIdentificationFrame *f = static_cast<TextIdentificationFrame *>(
d->frameListMap["TCON"].front());
StringList fields = f->fieldList();
StringList genres;
for(StringList::Iterator it = fields.begin(); it != fields.end(); ++it) {
if((*it).isEmpty())
continue;
bool ok;
int number = (*it).toInt(&ok);
if(ok && number >= 0 && number <= 255) {
*it = ID3v1::genre(number);
}
if(std::find(genres.begin(), genres.end(), *it) == genres.end())
genres.append(*it);
}
return genres.toString();
}
示例3: resolveRelativePath
bool AbstractFileManager::resolveRelativePath(const String& relativePath, const StringList& rootPaths, String& absolutePath) {
StringList::const_iterator rootIt, rootEnd;
for (rootIt = rootPaths.begin(), rootEnd = rootPaths.end(); rootIt != rootEnd; ++rootIt) {
const String& rootPath = *rootIt;
absolutePath = makeAbsolute(relativePath, rootPath);
if (exists(absolutePath))
return true;
}
return false;
}
示例4: unloadAll
// Unloads all loaded modules
void ModuleFactory::unloadAll()
{
StringList modules = m_dependency.getSortedList();
std::for_each(modules.begin(), modules.end(),
boost::bind(&ModuleFactory::unload, this, _1));
// clear dependencies
m_dependency.clear();
// stop all left
getScheduler()->stop();
}
示例5:
StringList
MessageEncodingRegistry::getCommonEncodings(const StringList& encodingList) const
{
/// Currently only one encoding available.
StringList commonEncodingList;
for (StringList::const_iterator i = encodingList.begin(); i != encodingList.end(); ++i) {
if (*i == "TightBE1")
commonEncodingList.push_back(*i);
}
return commonEncodingList;
}
示例6: getFiles
// Reads a folder and provides a list with filename from the
// folder
// @param[in] folder - the folder with files
// @exception @ref Result
const StringList Utils::getFiles(const std::string& folder, bool recursive)
{
DIR* dir = NULL;
BOOST_ASSERT(Utils::fileExist(folder) == true);
StringList res;
dir = opendir(folder.c_str());
if (dir != NULL)
{
struct dirent* dir_info = NULL;
// Process all files in the subdirectory
while ((dir_info = readdir(dir)))
{
if ((strcmp(dir_info->d_name, ".") != 0) &&
(strcmp(dir_info->d_name, "..") != 0))
{
std::string file_name = folder;
file_name += "/";
file_name += dir_info->d_name;
struct stat st;
if (lstat(file_name.c_str(), &st) < 0)
{
klk_log(KLKLOG_ERROR, "Error %d in lstat(): %s",
errno, strerror(errno));
KLKASSERT(0);
continue;
}
// process only reg file
if (S_ISREG(st.st_mode))
{
res.push_back(file_name);
}
else if (S_ISDIR(st.st_mode) && recursive)
{
StringList files = getFiles(file_name, recursive);
std::copy(files.begin(), files.end(),
std::back_inserter(res));
}
}
}
closedir(dir);
}
else
{
throw Exception(__FILE__, __LINE__,
"Error %d in opendir() for %s: %s", errno,
folder.c_str(), strerror(errno));
}
return res;
}
示例7: stringListContain
static inline bool stringListContain(StringList& strList, const string& str)
{
StringList::iterator iter = strList.begin();
for (; iter != strList.end(); iter++)
{
if (*iter == str) {
return true;
}
}
return false;
}
示例8: StringListAccumulator
// Converts a list to a string with items separated
// by the specified separator
const std::string
Utils::convert2String(const StringList& list, const std::string& sep)
{
const std::string result = std::accumulate(
list.begin(),
list.end(), std::string(""),
boost::bind<std::string>(
StringListAccumulator(), _1, _2, sep));
return result;
}
示例9: fieldList
StringList UserTextIdentificationFrame::fieldList() const
{
StringList l = TextIdentificationFrame::fieldList();
if(!l.isEmpty()) {
StringList::Iterator it = l.begin();
l.erase(it);
}
return l;
}
示例10: wipeExternal
void CCUtils::wipeExternal(StringList paths) {
string internalStorage = getInternalStoragePath();
if(internalStorage[internalStorage.length() - 1] != '/') {
internalStorage += "/";
}
for(StringList::iterator iter = paths.begin(); iter != paths.end(); iter++) {
string fullpath = internalStorage + (*iter);
if(isPathExistent(fullpath)) {
deleteFile(fullpath);
}
}
}
示例11: writeObjectFields
void OutputStream::writeObjectFields( const osg::Object* obj )
{
std::string name = obj->libraryName();
name += std::string("::") + obj->className();
ObjectWrapper* wrapper = Registry::instance()->getObjectWrapperManager()->findWrapper( name );
if ( !wrapper )
{
OSG_WARN << "OutputStream::writeObject(): Unsupported wrapper class "
<< name << std::endl;
return;
}
_fields.push_back( name );
const StringList& associates = wrapper->getAssociates();
for ( StringList::const_iterator itr=associates.begin(); itr!=associates.end(); ++itr )
{
const std::string& assocName = *itr;
ObjectWrapper* assocWrapper = Registry::instance()->getObjectWrapperManager()->findWrapper(assocName);
if ( !assocWrapper )
{
OSG_WARN << "OutputStream::writeObject(): Unsupported associated class "
<< assocName << std::endl;
continue;
}
else if ( _useSchemaData )
{
if ( _inbuiltSchemaMap.find(assocName)==_inbuiltSchemaMap.end() )
{
StringList properties;
assocWrapper->writeSchema( properties );
if ( properties.size()>0 )
{
std::string propertiesString;
for ( StringList::iterator sitr=properties.begin(); sitr!=properties.end(); ++sitr )
{
propertiesString += *sitr;
propertiesString += ' ';
}
_inbuiltSchemaMap[assocName] = propertiesString;
}
}
}
_fields.push_back( assocWrapper->getName() );
assocWrapper->write( *this, *obj );
if ( getException() ) return;
_fields.pop_back();
}
_fields.pop_back();
}
示例12: parseRelations
static int parseRelations()
{
depTable.clear();
confTable.clear();
char assistName[MAX_PATH];
sprintf(assistName, "%s\\%s\\%s", WtoA(getMiscPath(PATH_IPS)), BurnDrvGetTextA(DRV_NAME), "assistant.txt");
//parse ips dat and update the treewidget
FILE* fp = fopen(assistName, "rt");
if (!fp) {
return 1;
}
char s[1024];
char* p = NULL;
string line;
size_t nLen = 0;
size_t pos = string::npos;
while (!feof(fp)) {
if (fgets(s, sizeof s, fp) != NULL) {
p = s;
// skip UTF-8 sig
if (strncmp(p, UTF8_SIGNATURE, strlen(UTF8_SIGNATURE)) == 0) {
p += strlen(UTF8_SIGNATURE);
}
if (p[0] == '#') {
continue; // skip comment
}
getLine(p);
line = p;
pos = line.find(">");
if (pos != string::npos) {
StringList depStrs = split2Str(line, ">");
string parent = *(depStrs.begin());
lowerString(parent);
StringList children = stringSplit(depStrs.back(), ",");
lowerTrimmed(children);
depTable.insert(make_pair(parent, children));
} else {
StringList conflicts = stringSplit(line, ",");
lowerTrimmed(conflicts);
confTable.push_back(conflicts);
}
}
}
return 0;
}
示例13: main
int main ()
{
// Create a list of critters.
StringList critters;
// Insert a few critters.
critters.insert (critters.begin (), "antelope");
critters.insert (critters.begin (), "bear");
critters.insert (critters.begin (), "cat");
// Print out the list.
std::cout << critters << '\n';
// Change cat to cougar.
*std::find (critters.begin (),critters.end (), "cat") = "cougar";
std::cout << critters << '\n';
// Put a zebra at the beginning, an ocelot ahead of antelope,
// and a rat at the end.
critters.push_front ("zebra");
critters.insert (std::find (critters.begin (), critters.end (),
"antelope"), "ocelot");
critters.push_back ("rat");
std::cout << critters << '\n';
// Sort the list (Use list's sort function since the
// generic algorithm requires a random access iterator
// and list only provides bidirectional)
critters.sort ();
std::cout << critters << '\n';
// Now let's erase half of the critters.
StringList::size_type half = critters.size () / 2;
for (StringList::size_type i = 0; i != half; ++i)
critters.erase (critters.begin ());
std::cout << critters << '\n';
return 0;
}
示例14: if
// Retrives list of possible completions for a n's parameter
const cli::ParameterVector
ScanStart::getCompletion(const cli::ParameterVector& setparams)
{
cli::ParameterVector res;
if (setparams.empty())
{
// possible source names
IDevList list =
getFactory()->getResources()->getResourceByType(dev::DVB_ALL);
for (IDevList::iterator i = list.begin(); i != list.end(); i++)
{
const std::string source = (*i)->getStringParam(dev::SOURCE);
if (!source.empty())
{
const std::string source_name =
dvb::Utils::getSourceName(getFactory(),
source);
if (std::find(res.begin(), res.end(), source_name) ==
res.end())
{
res.push_back(source_name);
}
}
}
}
else if (setparams.size() == 1)
{
IDevPtr dev = getDev(setparams[0]);
// possible frequency table
StringList list;
if (dev->getStringParam(dev::TYPE) == dev::DVB_T)
{
list = base::Utils::getFiles(dir::SHARE + "/scan/dvb-t");
}
else if (dev->getStringParam(dev::TYPE) == dev::DVB_S)
{
list = base::Utils::getFiles(dir::SHARE + "/scan/dvb-s");
}
for (StringList::iterator i = list.begin(); i != list.end(); i++)
{
const std::string fname = base::Utils::getFileName(*i);
if (std::find(res.begin(), res.end(), fname) == res.end())
{
res.push_back(fname);
}
}
}
return res;
}
示例15: GetRocketRow
void GetRocketRow( StringList &rocketRow, int row_index, const StringList& cols ) const {
RowsList::const_iterator r_it = rows.begin();
std::advance( r_it, row_index );
if( r_it == rows.end() ) {;
return;
}
const Row &row = *r_it;
for( StringList::const_iterator it = cols.begin(); it != cols.end(); ++it ) {
Row::const_iterator v = row.find( (*it).CString() );
rocketRow.push_back( v == row.end() ? "" : v->second.c_str() );
}
}