Esempio n. 1
0
StrList	FileSystemManager::getWorkingDirectoryContents(QString filter)
{
	if (!scnManager->getCurrentLibrary())
		return getDirectoryContents(native(scnManager->getWorkingDirectory()), filter);
	
	StrList files;
	QListIterator<QString> dirIt(scnManager->getCurrentLibrary()->getFolderPaths());
	while (dirIt.hasNext())
	{
		StrList list = getDirectoryContents(dirIt.next(), filter);
		files.insert(files.end(), list.begin(), list.end());
	}
	return files;
}
Esempio n. 2
0
void CViewMsgDlg::OnMenuQuickReply() 
{
#define IDM_QUICK_REPLY	1000
	
	CMenu menu;
	menu.CreatePopupMenu();

	IcqOption &options = icqLink->options;
	StrList l;
	IcqDB::loadQuickReply(l);
	StrList::iterator it;
	UINT id = IDM_QUICK_REPLY;

	CString str;
	for (it = l.begin(); it != l.end(); ++it) {
		CString str = (*it).c_str();
		if (str.GetLength() > 20)
			str = str.Left(20) + "...";
		menu.AppendMenu(
			str == options.quickReplyText.c_str() ? MF_CHECKED : MF_UNCHECKED,
			id++, str);
	}
	str.LoadString(IDS_QUICK_REPLY_SETTING);
	menu.AppendMenu(MF_STRING, id++, str);

	CRect rc;
	GetDlgItem(IDC_MENU_QUICK_REPLY)->GetWindowRect(rc);
	id = menu.TrackPopupMenu(TPM_RETURNCMD, rc.left, rc.bottom, this);
	if (id == 0)
		return;

	id -= IDM_QUICK_REPLY;
	if (id == menu.GetMenuItemCount() - 1)
		((CIcqDlg *) AfxGetMainWnd())->showOptions(1);
	else {
		int i = 0;
		for (it = l.begin(); it != l.end() && i < id; ++it, ++i)
			;
		if (it != l.end()) {
			options.quickReplyText = *it;
			IcqDB::saveOptions(options);
			OnQuickReply();
		}
	}
}
void V3PreProcImp::openFile(FileLine* fl, V3InFilter* filterp, const string& filename) {
    // Open a new file, possibly overriding the current one which is active.
    V3File::addSrcDepend(filename);

    // Read a list<string> with the whole file.
    StrList wholefile;
    bool ok = filterp->readWholefile(filename, wholefile/*ref*/);
    if (!ok) {
	error("File not found: "+filename+"\n");
	return;
    }

    if (!m_preprocp->isEof()) {  // IE not the first file.
	// We allow the same include file twice, because occasionally it pops
	// up, with guards preventing a real recursion.
	if (m_lexp->m_streampStack.size()>V3PreProc::INCLUDE_DEPTH_MAX) {
	    error("Recursive inclusion of file: "+filename);
	    return;
	}
	// There's already a file active.  Push it to work on the new one.
	addLineComment(0);
    }

    // Create new stream structure
    m_lexp->scanNewFile(m_preprocp->fileline()->create(filename, 1));
    addLineComment(1); // Enter

    // Filter all DOS CR's en-mass.  This avoids bugs with lexing CRs in the wrong places.
    // This will also strip them from strings, but strings aren't supposed to be multi-line without a "\"
    for (StrList::iterator it=wholefile.begin(); it!=wholefile.end(); ++it) {
	// We don't end-loop at \0 as we allow and strip mid-string '\0's (for now).
	bool strip = false;
	const char* sp = it->data();
	const char* ep = sp + it->length();
	// Only process if needed, as saves extra string allocations
	for (const char* cp=sp; cp<ep; cp++) {
	    if (VL_UNLIKELY(*cp == '\r' || *cp == '\0')) {
		strip = true; break;
	    }
	}
	if (strip) {
	    string out;  out.reserve(it->length());
	    for (const char* cp=sp; cp<ep; cp++) {
		if (!(*cp == '\r' || *cp == '\0')) {
		    out += *cp;
		}
	    }
	    *it = out;
	}

	// Push the data to an internal buffer.
	m_lexp->scanBytesBack(*it);
	// Reclaim memory; the push saved the string contents for us
	*it = "";
    }
}
Esempio n. 4
0
void TripodClient::GetList(const std::string& key, StrList& value, int begin, int limit) {
  RedisCacheClientPtr client = GetRedisCacheClient();
  if (!client) {
    MCE_INFO("TripodClient::GetList() RedisCacheClient is NULL");
    return;
  }
  const StrList& list = client->GetList(key, begin, limit, namespaceId_, businessId_);
  if (!list.empty()) {
    value.insert(value.end(), list.begin(), list.end());
  }
}
void EventsGenerator::desiresCB(const hbba_msgs::DesiresSet::ConstPtr& msg)
{
	typedef std::vector<std::string> StrVec;
	typedef std::list<std::string> StrList;
	typedef std::vector<hbba_msgs::Desire> DesVec;
	typedef std::map<std::string,std::string> TypeMap;
	const DesVec& desires = msg->desires;
	TypeMap typeMap;
	StrVec ids;
	ids.reserve(desires.size());
	for (DesVec::const_iterator d = desires.begin(); d != desires.end(); ++d)
	{
		ids.push_back(d->id);
		typeMap[d->id] = d->type;
	}

    // First, remove desires not in it the current desires set.
    StrList del;
    for (Model::const_iterator i = model_.begin(); i != model_.end(); ++i)
    {
        const std::string& id = i->first;
        if (std::find(ids.begin(), ids.end(), id) == ids.end())
            del.push_back(id);
    }
    for (StrList::const_iterator i = del.begin(); i != del.end(); ++i)
    {
        const std::string& id = *i;
	
        event(id, model_[id].type, hbba_msgs::Event::DES_OFF);
        if (model_[id].flags & FLAG_INT)
            event(id, model_[id].type, hbba_msgs::Event::INT_OFF);
        if (model_[id].flags & FLAG_EXP)
            event(id, model_[id].type, hbba_msgs::Event::EXP_OFF);

        model_.erase(id);
    }

	// Then, generate events for new desires.
	for (StrVec::const_iterator i = ids.begin(); i != ids.end(); ++i)
	{
		const std::string& id = *i;
		if (model_.find(id) == model_.end())
		{
			model_[id].flags = FLAG_NONE;
			model_[id].type = typeMap[id]; //set type in the model
			event(id, model_[id].type, hbba_msgs::Event::DES_ON);
		}
	}

}
void ProductRankerTestFixture::convertMerchantId_(
    const std::string& merchantList,
    PropValueIdList& idList)
{
    typedef std::vector<std::string> StrList;
    StrList strList;
    split_str_to_items(merchantList, strList);

    for (StrList::const_iterator it = strList.begin(); it != strList.end(); ++it)
    {
        merchant_id_t merchantId = 0;
        std::vector<izenelib::util::UString> path;
        path.push_back(izenelib::util::UString(*it, ENCODING_TYPE));

        merchantId = merchantValueTable_.insertPropValueId(path);
        idList.push_back(merchantId);
    }
}
Esempio n. 7
0
/*
 Must LockFileQueue() first,
 and UnlockFileQueue() after finished opertion.
 */
StrList::iterator InsertDir(const string& strDirPath,
                            bool fInsertFront, bool fAddSubDir)
{
    StrList::iterator itrFile;
    if(fInsertFront)
        itrFile = s_fileList.begin();
    else
        itrFile = --s_fileList.end();
    
    DIR *pDir;
    struct dirent *pDirent;
    
    pDir = opendir(strDirPath.c_str());
    if(pDir)
    {
        struct stat fileStat;
        while((pDirent = readdir(pDir)) != NULL)
        {
            string strPath(pDirent->d_name);
            if(strPath != "." && strPath != "..")
            {
                if(strDirPath[strDirPath.length() - 1] == '/')
                    strPath = strDirPath + strPath;
                else
                    strPath = strDirPath + "/" + strPath;
                
                if(strPath.find(".DS_Store") != string::npos ||
                   strPath.find(".Trashes") != string::npos ||
                   strPath.find(".TemporaryItems") != string::npos)
                    continue;
                
                stat(strPath.c_str(), &fileStat);
                if((fileStat.st_mode & S_IFREG) ||
                   ((fileStat.st_mode & S_IFDIR) && fAddSubDir))
                    itrFile = InsertFile(strPath, itrFile);
            }
        }
        
        closedir(pDir);
    }

    return itrFile;
}
Esempio n. 8
0
int CMsgTreeView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CTreeView::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	CTreeCtrl &tree = GetTreeCtrl();
	tree.SetImageList(&getApp()->smallImageList, TVSIL_NORMAL);
	tree.SetItemHeight(24);

	IcqUser &myInfo = icqLink->myInfo;
	CString str;
	str.Format("%s(%s)", myInfo.qid.toString(), myInfo.nick.c_str());
	HTREEITEM root = tree.InsertItem(str, getApp()->getFaceIndex(myInfo.face),
		getApp()->getFaceIndex(myInfo.face, STATUS_AWAY), NULL);

	MyICQCtrl &outbar = ((CIcqDlg *) AfxGetMainWnd())->outbarCtrl;
	int n = outbar.getFolderCount();
	QID *qid;
	CString name;
	int image;
	HTREEITEM stranger = NULL;

	StrList qidList;
	IcqDB::getMsgQIDList(qidList);

	for (int i = 0; i < n; ++i) {
		outbar.getFolderName(i, name);
		image = getApp()->iconIndex(ICON_FOLDER);
		HTREEITEM parent = tree.InsertItem(name, image, image, root);

		int nrItems = outbar.getItemCount(i);
		for (int j = 0; j < nrItems; ++j) {
			IcqContact *c = outbar.contact(i, j);
			str.Format("%s (%s)", c->qid.toString(), c->nick.c_str());
			HTREEITEM hItem = tree.InsertItem(str, getApp()->getFaceIndex(c->face),
				getApp()->getFaceIndex(c->face, STATUS_AWAY), parent);

			qid = new QID(c->qid);
			tree.SetItemData(hItem, (DWORD) qid);

			qidList.remove(c->qid.toString());
		}

		if (i == n - 2)
			stranger = parent;
	}

	HTREEITEM item;

	// Add the remaining UINs to the stranger folder
	StrList::iterator it;
	for (it = qidList.begin(); it != qidList.end(); ++it) {
		const char *s = (*it).c_str();
		qid = new QID;
		if (!qid->parse(s)) {
			delete qid;
			continue;
		}

		item = tree.InsertItem(s, getApp()->getFaceIndex(0),
			getApp()->getFaceIndex(0, STATUS_AWAY), stranger);
		tree.SetItemData(item, (DWORD) qid);
	}

	str.LoadString(IDS_SYSMSG);
	image = getApp()->iconIndex(ICON_SYSMSG);
	item = tree.InsertItem(str, image, image, root);
	qid = new QID;
	tree.SetItemData(item, (DWORD) qid);
	
	return 0;
}