OnInitialUpdate ()
{
CView::OnInitialUpdate ();
- CString sDoc = GetDocument ()->GetPathName (), sExt = GetExt (sDoc);
- if (!sExt.IsEmpty())
- SetTextType (sExt);
+ std::basic_string<tchar_t> sDoc = GetDocument ()->GetPathName (), sExt = GetExt (sDoc);
+ if (!sExt.empty ())
+ SetTextType (sExt.c_str ());
AttachToBuffer (nullptr);
CSplitterWnd *pSplitter = GetParentSplitter (this, false);
void CCrystalTextView::
OnToggleSourceHeader ()
{
+ auto FileExist = [](const tchar_t* lpszPath) -> bool
+ {
+ CFileStatus status;
+ return CFile::GetStatus(lpszPath, status) != 0;
+ };
if (m_CurSourceDef->type == CrystalLineParser::SRC_C)
{
CDocument *pDoc = GetDocument ();
<ClCompile Include="$(MSBuildThisFileDirectory)utils\cregexp.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)utils\cregexp_poco.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)utils\cs2cs.cpp" />
- <ClCompile Include="$(MSBuildThisFileDirectory)utils\filesup.cpp" />
+ <ClCompile Include="$(MSBuildThisFileDirectory)utils\filesup.cpp">
+ <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
+ <PrecompiledHeaderOutputFile>$(IntDir)$(TargetName)2.pch</PrecompiledHeaderOutputFile>
+ </ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)utils\hqbitmap.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)utils\icu.cpp" />
- <ClCompile Include="$(MSBuildThisFileDirectory)utils\wcwidth.cpp" />
+ <ClCompile Include="$(MSBuildThisFileDirectory)utils\wcwidth.cpp">
+ <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
+ <PrecompiledHeaderOutputFile>$(IntDir)$(TargetName)2.pch</PrecompiledHeaderOutputFile>
+ </ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)ViewableWhitespace.cpp">
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>$(IntDir)$(TargetName)2.pch</PrecompiledHeaderOutputFile>
// - LEAVE THIS HEADER INTACT
////////////////////////////////////////////////////////////////////////////
-#include "StdAfx.h"
+#include "pch.h"
#include "filesup.h"
////////////////////////////////////////////////////////////////////////////////
-bool FileExist(const tchar_t* lpszPath)
-{
- CFileStatus status;
- return CFile::GetStatus(lpszPath, status) != 0;
-}
-
int GetExtPosition (const tchar_t* pszString)
{
if (pszString == nullptr || !*pszString)
return 0;
- const CString sString = pszString;
- int len = sString.GetLength (), posit = len;
+ const std::basic_string<tchar_t> sString = pszString;
+ int len = static_cast<int>(sString.length ()), posit = len;
tchar_t test;
do
- if ((test = sString.GetAt (--posit)) == _T ('.'))
+ if ((test = sString.at (--posit)) == _T ('.'))
return posit;
#ifdef _UNICODE
while (posit && test != _T ('\\') && test != _T (':'));
return len;
}
-CString GetExt (CString sString)
+std::basic_string<tchar_t> GetExt (const std::basic_string<tchar_t>& sString)
{
- if (!sString.IsEmpty ())
+ std::basic_string<tchar_t> sString2 = sString;
+ if (!sString2.empty ())
{
- sString = sString.Mid (GetExtPosition (sString));
- if (!sString.IsEmpty () && sString[0] == _T ('.'))
+ sString2 = sString2.substr (GetExtPosition (sString2.c_str ()));
+ if (!sString2.empty () && sString2[0] == _T ('.'))
{
- sString = sString.Mid (1);
+ sString2 = sString2.substr (1);
}
}
- return sString;
-}
-
-CString GetName (const CString & sString)
-{
- int nPosition = GetNamePosition (sString), nPosition2 = GetExtPosition (sString);
-
- return sString.IsEmpty ()? sString : (nPosition2 == sString.GetLength ()? sString.Mid (nPosition) : sString.Mid (nPosition, nPosition2 - nPosition));
-}
-
-CString GetNameExt (const CString & sString)
-{
- return sString.IsEmpty ()? sString : sString.Mid (GetNamePosition (sString));
-}
-
-int GetNamePosition (const tchar_t* pszString)
-{
- if (pszString == nullptr || !*pszString)
- return 0;
- const CString sString = pszString;
- int posit = sString.GetLength ();
- do
- {
- tchar_t test;
-#ifdef _UNICODE
- if ((test = sString.GetAt (--posit)) == _T ('\\') || test == _T (':'))
-#else
- if (((test = sString.GetAt (--posit)) == _T ('\\') && !_ismbstrail((unsigned char *)pszString, (unsigned char *)pszString + posit)) || test == _T (':'))
-#endif
- return posit + 1;
- }
- while (posit);
- return posit;
-}
-
-CString GetPath (const CString & sString, bool bClose /*= false*/ )
-{
- if (sString.IsEmpty ())
- return sString;
- int posit = GetNamePosition (sString);
- if (posit == 0)
- return bClose ? _T (".\\") : _T (".");
-
- tchar_t test = sString.GetAt (posit - 1);
-
-#ifdef _UNICODE
- if (test == _T (':') || test == _T ('\\') && (posit == 1 || sString.GetAt (posit - 2) == _T (':')))
-#else
- if (test == _T (':') || (test == _T ('\\') && !_ismbstrail((unsigned char *)(const tchar_t*)sString, (unsigned char *)(const tchar_t*)sString + posit)) && (posit == 1 || sString.GetAt (posit - 2) == _T (':')))
-#endif
- return sString.Left (posit);
- return sString.Left (bClose ? posit : test == _T (':') ? posit : posit - 1);
-}
-
-CString GetPathName (const CString & sString)
-{
- int nPosition = GetExtPosition (sString);
-
- return sString.IsEmpty ()? sString : (nPosition == sString.GetLength ()? sString : sString.Left (nPosition));
+ return sString2;
}
////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "ctchar.h"
+#include <string>
/////////////////////////////////////////////////////////////////////////////
-bool EDITPADC_CLASS FileExist(const tchar_t* lpszPath);
int EDITPADC_CLASS GetExtPosition (const tchar_t* pszString);
-CString EDITPADC_CLASS GetExt (CString sString);
-CString EDITPADC_CLASS GetName (const CString & sString);
-CString EDITPADC_CLASS GetNameExt (const CString & sString);
-int EDITPADC_CLASS GetNamePosition (const tchar_t* pszString);
-CString EDITPADC_CLASS GetPath (const CString & sString, bool bClose = false);
-CString EDITPADC_CLASS GetPathName (const CString & sString);
+std::basic_string<tchar_t> EDITPADC_CLASS GetExt (const std::basic_string<tchar_t>& sString);