コード例 #1
0
ファイル: DirDoc.cpp プロジェクト: YueLinHo/WinMerge
/**
 * @brief Load line filters to the compare context.
 * Loads linefilters, converts them to UTF-8 and sets them for compare context.
 */
void CDirDoc::LoadLineFilterList()
{
	ASSERT(m_pCtxt);
	
	BOOL bFilters = GetOptionsMgr()->GetBool(OPT_LINEFILTER_ENABLED);
	String filters = GetMainFrame()->m_pLineFilters->GetAsString();
	if (!bFilters || filters.empty())
	{
		delete m_pCtxt->m_pFilterList;
		m_pCtxt->m_pFilterList = NULL;
		return;
	}

	if (m_pCtxt->m_pFilterList)
		m_pCtxt->m_pFilterList->RemoveAllFilters();
	else
		m_pCtxt->m_pFilterList = new FilterList();

	char * regexp_str;
	FilterList::EncodingType type;

	regexp_str = UCS2UTF8_ConvertToUtf8(filters.c_str());
	type = FilterList::ENC_UTF8;

	m_pCtxt->m_pFilterList->AddRegExp(regexp_str, type);

	UCS2UTF8_Dealloc(regexp_str);
}
コード例 #2
0
/**
 * @brief Check if any of filefilter rules match to filename.
 *
 * @param [in] szFileName Filename to test.
 * @return TRUE unless we're suppressing this file by filter
 */
BOOL FileFilterHelper::includeFile(LPCTSTR szFileName)
{
	if (m_bUseMask)
	{
		if (m_pMaskFilter == NULL)
		{
			_RPTF0(_CRT_ERROR, "Use mask set, but no filter rules for mask!");
			return TRUE;
		}

		// preprend a backslash if there is none
		CString strFileName = szFileName;
		strFileName.MakeLower();
		if (strFileName[0] != _T('\\'))
			strFileName = _T('\\') + strFileName;
		// append a point if there is no extension
		if (strFileName.Find(_T('.')) == -1)
			strFileName = strFileName + _T('.');

		char * name_utf = UCS2UTF8_ConvertToUtf8(strFileName);
		bool match = m_pMaskFilter->Match(strlen(name_utf), name_utf);
		UCS2UTF8_Dealloc(name_utf);
		return match;
	}
	else
	{
		if (!m_fileFilterMgr || !m_currentFilter)
			return TRUE;
		return m_fileFilterMgr->TestFileNameAgainstFilter(m_currentFilter, szFileName);
	}
}
コード例 #3
0
ファイル: ProjectFile.cpp プロジェクト: seanedwards/COS-420
static std::string T2UTF8(const TCHAR *str)
{
	char *utf8 = UCS2UTF8_ConvertToUtf8(str ? str : _T(""));
	std::string newstr(utf8);
	UCS2UTF8_Dealloc(utf8);
	return newstr;
}
コード例 #4
0
/** 
 * @brief Set filemask for filtering.
 * @param [in] strMask Mask to set (e.g. *.cpp;*.h).
 */
void FileFilterHelper::SetMask(LPCTSTR strMask)
{
	if (!m_bUseMask)
	{
		_RPTF0(_CRT_ERROR, "Filter mask tried to set when masks disabled!");
		return;
	}
	m_sMask = strMask;
	CString regExp = ParseExtensions(strMask);

	char * regexp_str;
	FilterList::EncodingType type;

	regexp_str = UCS2UTF8_ConvertToUtf8(regExp);
	type = FilterList::ENC_UTF8;

	m_pMaskFilter->RemoveAllFilters();
	m_pMaskFilter->AddRegExp(regexp_str, type);

	UCS2UTF8_Dealloc(regexp_str);
}