本文整理汇总了C++中CString::Left方法的典型用法代码示例。如果您正苦于以下问题:C++ CString::Left方法的具体用法?C++ CString::Left怎么用?C++ CString::Left使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CString
的用法示例。
在下文中一共展示了CString::Left方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetUrls
int CFavUrlMenuDlg::GetUrls( CString strPath, CArray<ITEM, ITEM&> &arrItems )
{
CStringArray arrSubDir;
int curCnt = 0;
if(strPath[strPath.GetLength() - 1] != _T('\\'))
strPath += _T('\\');
CString strFind = strPath + "*.*";
WIN32_FIND_DATA findData;
HANDLE hFile = NULL;
hFile = FindFirstFile(strFind, &findData);
if (hFile != INVALID_HANDLE_VALUE)
{
do
{
if ( strcmp(".", findData.cFileName )==0
|| strcmp("..", findData.cFileName)==0)
continue;
// 略过隐藏文件和系统文件
if ( (findData.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)
|| (findData.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM))
continue;
// 目录
if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
arrSubDir.Add(findData.cFileName);
// 文件
CString strFileName = findData.cFileName;
strFileName.MakeLower();
if (strFileName.Right(4) == ".url")
{
ITEM item;
item.type = ITEM_TYPE_URL;
item.strPath = strPath + strFileName;
strFileName = strFileName.Left(strFileName.GetLength() - 4);
item.strName = strFileName;
arrItems.Add(item);
curCnt++;
}
} while (FindNextFile(hFile, &findData));
}
FindClose(hFile);
INT_PTR nSubDirNum = arrSubDir.GetSize();
for (INT_PTR i=0; i<nSubDirNum; i++)
{
CString strSubDirName = arrSubDir.GetAt(i);
CArray<ITEM, ITEM&> aItems;
int n = GetUrls(strPath+strSubDirName, aItems);
// if (n != 0) // 不添加空文件夹
if (1)
{
ITEM item;
item.type = ITEM_TYPE_DIRECTORY;
item.strName = strSubDirName;
item.strPath = strPath+strSubDirName;
arrItems.Add(item);
}
}
return curCnt;
}
示例2: GetBugIDFromLog
CString ProjectProperties::GetBugIDFromLog(CString& msg)
{
CString sBugID;
if (!sMessage.IsEmpty())
{
CString sBugLine;
CString sFirstPart;
CString sLastPart;
BOOL bTop = FALSE;
if (nBugIdPos < 0)
return sBugID;
sFirstPart = sMessage.Left(nBugIdPos);
sLastPart = sMessage.Mid(nBugIdPos + 7);
msg.TrimRight('\n');
if (msg.ReverseFind('\n')>=0)
{
if (bAppend)
sBugLine = msg.Mid(msg.ReverseFind('\n')+1);
else
{
sBugLine = msg.Left(msg.Find('\n'));
bTop = TRUE;
}
}
else
{
if (bNumber)
{
// find out if the message consists only of numbers
bool bOnlyNumbers = true;
for (int i=0; i<msg.GetLength(); ++i)
{
if (!_istdigit(msg[i]))
{
bOnlyNumbers = false;
break;
}
}
if (bOnlyNumbers)
sBugLine = msg;
}
else
sBugLine = msg;
}
if (sBugLine.IsEmpty() && (msg.ReverseFind('\n') < 0))
{
sBugLine = msg.Mid(msg.ReverseFind('\n')+1);
}
if (sBugLine.Left(sFirstPart.GetLength()).Compare(sFirstPart)!=0)
sBugLine.Empty();
if (sBugLine.Right(sLastPart.GetLength()).Compare(sLastPart)!=0)
sBugLine.Empty();
if (sBugLine.IsEmpty())
{
if (msg.Find('\n')>=0)
sBugLine = msg.Left(msg.Find('\n'));
if (sBugLine.Left(sFirstPart.GetLength()).Compare(sFirstPart)!=0)
sBugLine.Empty();
if (sBugLine.Right(sLastPart.GetLength()).Compare(sLastPart)!=0)
sBugLine.Empty();
bTop = TRUE;
}
if (sBugLine.IsEmpty())
return sBugID;
sBugID = sBugLine.Mid(sFirstPart.GetLength(), sBugLine.GetLength() - sFirstPart.GetLength() - sLastPart.GetLength());
if (bTop)
{
msg = msg.Mid(sBugLine.GetLength());
msg.TrimLeft('\n');
}
else
{
msg = msg.Left(msg.GetLength()-sBugLine.GetLength());
msg.TrimRight('\n');
}
}
return sBugID;
}
示例3: ParserFromRefLog
int ParserFromRefLog(CString ref, std::vector<GitRev> &refloglist)
{
refloglist.clear();
if (g_Git.m_IsUseLibGit2)
{
CAutoRepository repo(g_Git.GetGitRepository());
if (!repo)
{
MessageBox(nullptr, CGit::GetLibGit2LastErr(_T("Could not open repository.")), _T("TortoiseGit"), MB_ICONERROR);
return -1;
}
CAutoReflog reflog;
if (git_reflog_read(reflog.GetPointer(), repo, CUnicodeUtils::GetUTF8(ref)) < 0)
{
MessageBox(nullptr, CGit::GetLibGit2LastErr(_T("Could not read reflog.")), _T("TortoiseGit"), MB_ICONERROR);
return -1;
}
for (size_t i = 0; i < git_reflog_entrycount(reflog); ++i)
{
const git_reflog_entry *entry = git_reflog_entry_byindex(reflog, i);
if (!entry)
continue;
GitRev rev;
rev.m_CommitHash = (char *)git_reflog_entry_id_new(entry)->id;
rev.m_Ref.Format(_T("%[email protected]{%d}"), ref, i);
rev.GetCommitterDate() = CTime(git_reflog_entry_committer(entry)->when.time);
if (git_reflog_entry_message(entry) != nullptr)
{
CString one;
g_Git.StringAppend(&one, (BYTE *)git_reflog_entry_message(entry));
int message = one.Find(_T(":"), 0);
if (message > 0)
{
rev.m_RefAction = one.Left(message);
rev.GetSubject() = one.Mid(message + 1);
}
}
refloglist.push_back(rev);
}
}
else if (g_Git.m_IsUseGitDLL)
{
git_for_each_reflog_ent(CUnicodeUtils::GetUTF8(ref), AddToRefLoglist, &refloglist);
for (size_t i = 0; i < refloglist.size(); ++i)
refloglist[i].m_Ref.Format(_T("%[email protected]{%d}"), ref, i);
}
else
{
CString cmd, out;
GitRev rev;
cmd.Format(_T("git.exe reflog show --pretty=\"%%H %%gD: %%gs\" --date=raw %s"), ref);
if (g_Git.Run(cmd, &out, NULL, CP_UTF8))
return -1;
int i = 0;
CString prefix = ref + _T("@{");
int pos = 0;
while (pos >= 0)
{
CString one = out.Tokenize(_T("\n"), pos);
int refPos = one.Find(_T(' '), 0);
if (refPos < 0)
continue;
rev.Clear();
CString hashStr = one.Left(refPos);
rev.m_CommitHash = hashStr;
rev.m_Ref.Format(_T("%[email protected]{%d}"), ref, i++);
int prefixPos = one.Find(prefix, refPos + 1);
if (prefixPos != refPos + 1)
continue;
int spacePos = one.Find(_T(' '), prefixPos + prefix.GetLength() + 1);
if (spacePos < 0)
continue;
CString timeStr = one.Mid(prefixPos + prefix.GetLength(), spacePos - prefixPos - prefix.GetLength());
rev.GetCommitterDate() = CTime(_ttoi(timeStr));
int action = one.Find(_T("}: "), spacePos + 1);
if (action > 0)
{
action += 2;
int message = one.Find(_T(":"), action);
if (message > 0)
{
rev.m_RefAction = one.Mid(action + 1, message - action - 1);
rev.GetSubject() = one.Right(one.GetLength() - message - 1);
}
}
refloglist.push_back(rev);
}
}
return 0;
}
示例4: checkPhoneIsUnicom
BOOL checkPhoneIsUnicom(CString phone)
{
//strcmp(s1, s2)==0
// 130,131,132,155,156,185,186,145,176
if (phone.GetLength() < 11){
return false;
}
using namespace std;
vector<std::string>::iterator result = find(cUrls.phoneHeads.begin(),cUrls.phoneHeads.end(),(LPCTSTR)phone.Left(3));
if ( result == cUrls.phoneHeads.end( ) ) {
return false;
}else{
return true;
}
/*
if (strcmp(phone.Left(3), "130") == 0
|| strcmp(phone.Left(3), "131") == 0
|| strcmp(phone.Left(3), "132") == 0
|| strcmp(phone.Left(3), "155") == 0
|| strcmp(phone.Left(3), "156") == 0
|| strcmp(phone.Left(3), "185") == 0
|| strcmp(phone.Left(3), "186") == 0
|| strcmp(phone.Left(3), "145") == 0
|| strcmp(phone.Left(3), "176") == 0
){
return true;
}
return false;
*/
}
示例5: Onload
int CFileListIni::Onload(const void* param)
{
PFILE_LIST_INI_LOAD_PARAM pLoadParam = (PFILE_LIST_INI_LOAD_PARAM)param;
if (!CPathUtilEx::IsFileExist(pLoadParam->strX86File) && !CPathUtilEx::IsFileExist(pLoadParam->strX64File))
{
return Error_File_List_File_Is_Not_Exist;
}
//读取X86文件列表
int nCount = GetPrivateProfileInt(SECTION_FILE_LIST, FILE_LIST_COUNT, 0, pLoadParam->strX86File);
for (int i=0; i<nCount; i++)
{
CString strItem = GetPrivateProfileString(SECTION_FILE_LIST, StringAppendNumber(FILE_LIST_NAME_PREFIX, i), _T(""), pLoadParam->strX86File);
int nIndex = strItem.Find(_T('>'));
if (nIndex == -1) //大于号未找到
{
return Error_File_List_Greater_Than_Not_Find;
}
else
{
CString strSrcFile = strItem.Left(nIndex);
CString strDestFile = strItem.Mid(nIndex+1);
if (strSrcFile.IsEmpty())
{
return Error_File_List_Source_File_Is_Empty;
}
else if (strDestFile.IsEmpty())
{
return Error_File_List_Dest_File_Is_Empty;
}
else
{
FILE_ITEM fileItem;
fileItem.strName = CPathUtilEx::ExtractFileName(strSrcFile);
if (fileItem.strName.IsEmpty())
{
return Error_File_List_Source_File_Is_Path;
}
else
{
fileItem.strSrcPath = strSrcFile;
fileItem.strDestPath = strDestFile;
m_x86FileList.push_back(fileItem);
}
}
}
}
//读取X64文件列表
nCount = GetPrivateProfileInt(SECTION_FILE_LIST, FILE_LIST_COUNT, 0, pLoadParam->strX64File);
for (int i=0; i<nCount; i++)
{
CString strItem = GetPrivateProfileString(SECTION_FILE_LIST, StringAppendNumber(FILE_LIST_NAME_PREFIX, i), _T(""), pLoadParam->strX64File);
int nIndex = strItem.Find(_T('>'));
if (nIndex == -1) //大于号未找到
{
return Error_File_List_Greater_Than_Not_Find;
}
else
{
CString strSrcFile = strItem.Left(nIndex);
CString strDestFile = strItem.Mid(nIndex+1);
if (strSrcFile.IsEmpty())
{
return Error_File_List_Source_File_Is_Empty;
}
else if (strDestFile.IsEmpty())
{
return Error_File_List_Dest_File_Is_Empty;
}
else
{
FILE_ITEM fileItem;
fileItem.strName = CPathUtilEx::ExtractFileName(strSrcFile);
if (fileItem.strName.IsEmpty())
{
return Error_File_List_Source_File_Is_Path;
}
else
{
fileItem.strSrcPath = strSrcFile;
fileItem.strDestPath = strDestFile;
m_x64FileList.push_back(fileItem);
}
}
}
}
return Error_File_List_Success;
}
示例6: SendContinuosFrames
void CUDSMainWnd::SendContinuosFrames( unsigned char abByteArr[],mPSTXSELMSGDATA psTxCanMsgUds, UDS_INTERFACE FInterface)
{
CString Length;
CString omTempByte;
CString omByteStrTemp;
int numberofFrames =0; // It will indicate how many multiples frames have been sent
int c_numberOfTaken = numberOfTaken+2; // The consecutive Messages will contain one byte more that the FirstFrame
int i = aux_Finterface + c_numberOfTaken/2; // aux_Finterface it's used to indicate that i must be bigger if we're in extended Addressing
if (TotalLength*2<c_numberOfTaken) // It only enters here once, at the end when the last message of the multiple frames has to be sent when
{
i = TotalLength+aux_Finterface; // the number of frames that has to be sent is less than c_numberOfTaken
}
while (DatatoSend.GetLength()) // While there is remaining data that has to be sent
{
omByteStrTemp = DatatoSend.Left(c_numberOfTaken); //I take the part of the message that is going to be sent in the current Frame
//while(FWait_SendingFrame){} // Wait if something is being sent in this moment
while (omByteStrTemp.GetLength())
{
omTempByte = omByteStrTemp.Right(NO_OF_CHAR_IN_BYTE);
abByteArr[i--] = (BYTE)_tcstol(omTempByte, L'\0', 16); // It fills the array
omByteStrTemp = omByteStrTemp.Left(omByteStrTemp.GetLength() - NO_OF_CHAR_IN_BYTE);
}
psTxCanMsgUds->m_psTxMsg->m_ucDataLen = 8; // Consecutive Frames can always have 8 bytes
abByteArr[initialByte]= ConsecutiveFrame; // Put the initial Byte of the consecutive frames in a long request
SendSimpleDiagnosticMessage(); // Send the current Message
DatatoSend = DatatoSend.Right(((UINT)TotalLength*2)-c_numberOfTaken); // DatatoSend will contain the rest of the bytes that hasn't been sent yet.
TotalLength = (((UINT)TotalLength*2)-c_numberOfTaken)/2;
ConsecutiveFrame++;
if (ConsecutiveFrame == 0x30)
{
ConsecutiveFrame=0x20; // Requirement from the ISO TP
}
numberofFrames++;
if (numberofFrames == BSizE) // It enters here when I've reached the quantity of Blocks settled by the ECU in the flow Control
{
FWaitFlow = TRUE; // Now it has to wait for the Flow control again
numberofFrames = 0;
c_dDiffTime =0;
return ; // Now it has to wait for another FlowControl
}
else
{
for(c_dDiffTime =0,c_unPreviousTime =-1 ; c_dDiffTime <=STMin; CalculateDiffTime()) {} // Wait for the STMin Time settled by the ECU in the flow Control
}
c_unPreviousTime = -1; //ReStart the variables for the timmings
c_dDiffTime = 0;
i = aux_Finterface + c_numberOfTaken/2; // it must be a bigger number in the case of extended addressing-> aux_Finterface to control this.
if (TotalLength*2<c_numberOfTaken) // It only enters here once, at the end when the last message of the multiple frames has to be sent when
{
i = TotalLength+aux_Finterface; // the number of frames that has to be sent is less than c_numberOfTaken
}
}
m_omSendButton.EnableWindow(TRUE); // It only enters here when it has sent all the msg
// In the case that this function cannot be completed there is a timer as default to activate the SEND button
}
示例7: Render
void CTemplateWizardDialog::Render()
{
// Enable and disable the proper buttons.
GreyButtons();
// Set the new title.
CString title;
GetWindowText(title);
int parenPos = title.Find(" (", 0);
if (parenPos != -1)
title = title.Left(parenPos);
CString newTitle;
if (m_curPage == -1)
{
newTitle = title;
}
else
{
newTitle.Format("%s (Page %d of %d)", title, m_curPage + 1, m_code.GetPageCount());
}
SetWindowText(newTitle);
// Get the module name and strip the module filename from it, leaving the
// module path.
TCHAR moduleName[_MAX_PATH];
moduleName[0] = 0;
::GetModuleFileName(AfxGetInstanceHandle(), (TCHAR*)&moduleName, _MAX_PATH);
TCHAR* ptr = _tcsrchr(moduleName, '\\');
if (ptr)
{
ptr++;
*ptr = 0;
}
///////////////////////////////////////////////////////////////////////////
// Render the page.
const CString& pageStr = (m_curPage == -1) ? m_page : m_code.GetPage(m_curPage);
CRect clientRect;
GetClientRect(clientRect);
int curPos = 0;
// while (true)
// {
// Grab the text.
CString staticStr = pageStr;
// }
// See if it is a special case of a URL.
bool isURL = false;
CString leftStaticStr = staticStr.Left(7);
if (leftStaticStr == "http://" || leftStaticStr == "file://")
{
isURL = true;
}
CString strURL;
if (!isURL)
{
m_htmlFile.SetLength(0);
if (strnicmp(staticStr, "<html>", 6) != 0)
{
WriteString("<html><head>");
WriteString("</head><body>");
WriteString(staticStr);
WriteString("</body></html>");
}
else
{
WriteString(staticStr);
}
// Generate a unique temporary name.
char* asciiTempName = _tempnam(NULL, "WW200_");
m_asciiFilename = CString(asciiTempName);
free(asciiTempName);
DWORD size = (DWORD)m_htmlFile.GetLength();
BYTE* mem = m_htmlFile.Detach();
CFile asciiFile;
asciiFile.Open(m_asciiFilename, CFile::modeCreate | CFile::modeWrite);
asciiFile.Write(mem, size);
asciiFile.Close();
free(mem);
// CComBSTR bstrURL = "about:blank";
// m_pBrowserApp->Navigate(bstrURL, NULL, NULL, NULL, NULL);
strURL = m_asciiFilename;
}
else
{
m_asciiFilename.Empty();
strURL = pageStr;
strURL = "http://workspacewhiz.com";
}
m_pBrowserApp->Navigate2(COleVariant(strURL), NULL, NULL, NULL, NULL);
}
示例8: PrintFile
bool CHTTPSock::PrintFile(const CString& sFileName, CString sContentType) {
CString sFilePath = sFileName;
if (!m_sDocRoot.empty()) {
sFilePath.TrimLeft("/");
sFilePath = CDir::CheckPathPrefix(m_sDocRoot, sFilePath, m_sDocRoot);
if (sFilePath.empty()) {
PrintErrorPage(403, "Forbidden", "You don't have permission to access that file on this server.");
DEBUG("THIS FILE: [" << sFilePath << "] does not live in ...");
DEBUG("DOCUMENT ROOT: [" << m_sDocRoot << "]");
return false;
}
}
CFile File(sFilePath);
if (!File.Open()) {
PrintNotFound();
return false;
}
if (sContentType.empty()) {
if (sFileName.Right(5).Equals(".html") || sFileName.Right(4).Equals(".htm")) {
sContentType = "text/html; charset=utf-8";
} else if (sFileName.Right(4).Equals(".css")) {
sContentType = "text/css; charset=utf-8";
} else if (sFileName.Right(3).Equals(".js")) {
sContentType = "application/x-javascript; charset=utf-8";
} else if (sFileName.Right(4).Equals(".jpg")) {
sContentType = "image/jpeg";
} else if (sFileName.Right(4).Equals(".gif")) {
sContentType = "image/gif";
} else if (sFileName.Right(4).Equals(".ico")) {
sContentType = "image/x-icon";
} else if (sFileName.Right(4).Equals(".png")) {
sContentType = "image/png";
} else if (sFileName.Right(4).Equals(".bmp")) {
sContentType = "image/bmp";
} else {
sContentType = "text/plain; charset=utf-8";
}
}
const time_t iMTime = File.GetMTime();
bool bNotModified = false;
CString sETag;
if (iMTime > 0 && !m_bHTTP10Client) {
sETag = "-" + CString(iMTime); // lighttpd style ETag
AddHeader("Last-Modified", GetDate(iMTime));
AddHeader("ETag", "\"" + sETag + "\"");
AddHeader("Cache-Control", "public");
if (!m_sIfNoneMatch.empty()) {
m_sIfNoneMatch.Trim("\\\"'");
bNotModified = (m_sIfNoneMatch.Equals(sETag, true));
}
}
if (bNotModified) {
PrintHeader(0, sContentType, 304, "Not Modified");
} else {
off_t iSize = File.GetSize();
// Don't try to send files over 16 MiB, because it might block
// the whole process and use huge amounts of memory.
if (iSize > 16 * 1024 * 1024) {
DEBUG("- Abort: File is over 16 MiB big: " << iSize);
PrintErrorPage(500, "Internal Server Error", "File too big");
return true;
}
#ifdef HAVE_ZLIB
bool bGzip = m_bAcceptGzip && (sContentType.Left(5).Equals("text/") || sFileName.Right(3).Equals(".js"));
if (bGzip) {
DEBUG("- Sending gzip-compressed.");
AddHeader("Content-Encoding", "gzip");
PrintHeader(0, sContentType); // we do not know the compressed data's length
WriteFileGzipped(File);
} else
#endif
{
PrintHeader(iSize, sContentType);
WriteFileUncompressed(File);
}
}
DEBUG("- ETag: [" << sETag << "] / If-None-Match [" << m_sIfNoneMatch << "]");
Close(Csock::CLT_AFTERWRITE);
return true;
}
示例9: GetEnvVariable
//.........这里部分代码省略.........
SYSTEM_VERSION m_eSysVer;
KAEGetSystemVersion(&m_eSysVer);
CString StrSuffix;
if(m_eSysVer == enumSystem_Win_7)
{
StrSuffix = _T("\\$RECYCLE.BIN");
}
else
StrSuffix = _T("\\Recycled");
strResult = GetDrive(StrSuffix);
goto Exit0;
}
else if ( CString("minidump").CompareNoCase(pszName) == 0 )
{
DWORD len = sizeof(szLongPathBuffer);
GetRegistryValue(HKEY_LOCAL_MACHINE,
L"SYSTEM\\CurrentControlSet\\Control\\CrashControl",
L"MinidumpDir",
NULL,
(LPBYTE)szLongPathBuffer,
&len
);
if(wcslen(szLongPathBuffer) == 0)
strResult = L"%minidump%";
else
{
int nFirstPos = 0;
int nSecondPos = 0;
BOOL bFind = FALSE;
bFind = FindEnvironmentPos(szLongPathBuffer, nFirstPos, nSecondPos);
if(bFind)
{
CString strLeft ;
CString strRight ;
CString strEnvName ;
CString strEnvVariable;
strResult = szLongPathBuffer;
strLeft = strResult.Left(nFirstPos);
strRight = strResult.Mid (nSecondPos + 1);
strEnvName = strResult.Mid(nFirstPos + 1, nSecondPos - nFirstPos - 1);
TCHAR szTempBuf[MAX_PATH];
DWORD dwResult = GetEnvironmentVariable(strEnvName.GetBuffer(), szTempBuf, MAX_PATH);
if (dwResult > 0)
strEnvVariable = szTempBuf;
strResult = CombinationPath(strLeft, strEnvVariable, strRight);
}
else
strResult = szLongPathBuffer;
goto Exit0;
}
}
else if ( CString("memdump").CompareNoCase(pszName) == 0 )
{
DWORD len = sizeof(szLongPathBuffer);
GetRegistryValue(HKEY_LOCAL_MACHINE,
L"SYSTEM\\CurrentControlSet\\Control\\CrashControl",
L"DumpFile",
NULL,
(LPBYTE)szLongPathBuffer,
&len
示例10: ExtractLatLon
bool ExtractLatLon(CString str, double& dLat, double& dLon)
{
CString strCoord1;
CString strCoord2;
int nPos = str.Find(",");
if (nPos == -1) {
return false;
}
strCoord1 = str.Left(nPos);
strCoord2 = str.Mid(nPos+1);
if (strCoord1.FindOneOf("nNsS") > 0) {
// DM: 48�.834'N, 3�.787'W
// DMS: 48�'50.0"N, 3�'47.2"W
// Deg: 48.23056癗, 3.34645癢
// Deg: 48.23056, -3.34645
dLat = atof(strCoord1);
if (strCoord1.Find("�") && strCoord1.Find("'")) {
double dSeconds = 0.0;
if (strCoord1.Find("\"")) {
int nSecondPos = strCoord1.Find("'")+1;
dSeconds = atof(strCoord1.Mid(nSecondPos));
}
int nMinutePos = strCoord1.Find("�")+1;
double dMinutes = atof(strCoord1.Mid(nMinutePos));
double dFraction = ((dMinutes * 60.0) + dSeconds) / 3600.0;
dLat = dLat + dFraction;
}
if (strCoord1.FindOneOf("sS") > 0) {
dLat = -dLat;
}
} else if (strCoord2.FindOneOf("nNsS") > 0) {
dLat = atof(strCoord2);
if (strCoord2.Find("�") && strCoord2.Find("'")) {
double dSeconds = 0.0;
if (strCoord2.Find("\"")) {
int nSecondPos = strCoord2.Find("'")+1;
dSeconds = atof(strCoord2.Mid(nSecondPos));
}
int nMinutePos = strCoord2.Find("�")+1;
double dMinutes = atof(strCoord1.Mid(nMinutePos));
double dFraction = ((dMinutes * 60.0) + dSeconds) / 3600.0;
dLat = dLat + dFraction;
}
if (strCoord2.FindOneOf("sS") > 0) {
dLat = -dLat;
}
} else {
dLat = atof(strCoord1);
}
if (strCoord1.FindOneOf("eEwW") > 0) {
dLon = atof(strCoord1);
if (strCoord1.Find("�") && strCoord1.Find("'")) {
double dSeconds = 0.0;
if (strCoord1.Find("\"")) {
int nSecondPos = strCoord1.Find("'")+1;
dSeconds = atof(strCoord1.Mid(nSecondPos));
}
int nMinutePos = strCoord1.Find("�")+1;
double dMinutes = atof(strCoord1.Mid(nMinutePos));
double dFraction = ((dMinutes * 60.0) + dSeconds) / 3600.0;
dLon = dLon + dFraction;
}
if (strCoord1.FindOneOf("wW") > 0) {
dLon = -dLon;
}
} else if (strCoord2.FindOneOf("eEwW") > 0) {
dLon = atof(strCoord2);
if (strCoord2.Find("�") && strCoord2.Find("'")) {
double dSeconds = 0.0;
if (strCoord2.Find("\"")) {
int nSecondPos = strCoord2.Find("'")+1;
dSeconds = atof(strCoord2.Mid(nSecondPos));
}
int nMinutePos = strCoord2.Find("�")+1;
double dMinutes = atof(strCoord2.Mid(nMinutePos));
double dFraction = ((dMinutes * 60.0) + dSeconds) / 3600.0;
dLon = dLon + dFraction;
}
if (strCoord2.FindOneOf("wW") > 0) {
dLon = -dLon;
}
} else {
dLon = atof(strCoord2);
}
return true;
}
示例11: OnMapButton
/////////////////////////////////////////////////////////////////////////////
// get which map they want
/////////////////////////////////////////////////////////////////////////////
void CNetworkServerDialog::OnMapButton()
{
int i;
CString str;
CMapDatabaseDialog dlg;
if(IDOK == dlg.DoModal())
{
m_iMap = dlg.getMap();
//update all of the players readiness
for(i = 0; i < (int) GAME->m_players.size(); i++)
{
//skip self
if(i == GAME->m_iIndex)
{
continue;
}
VIEW->clientReady(GAME->m_players[i].m_player.getID(), FALSE);
}
//set the team text
if(TRUE == GAME->m_bTeam)
{
str = "This is a team game.\n\n";
}
//set the ladder text
if(TRUE == GAME->m_bLadder)
{
//get rid of the extra newline
str = str.Left(str.GetLength() - 1);
//add the ladder text
str += "This is a ladder game.\n\n";
}
//create info string (which loads the map)
str += MAPS->getMapInfo(m_iMap);
//set variant qualities
VARIANTS->m_iStockRoads = MAP->m_iStockRoads;
VARIANTS->m_iStockShips = MAP->m_iStockShips;
VARIANTS->m_iStockCities = MAP->m_iStockCities;
VARIANTS->m_iStockSettlements = MAP->m_iStockSettlements;
VARIANTS->m_iAllowedCards = MAP->m_iAllowedCards;
VARIANTS->m_iPoints = MAP->m_iPoints;
//reset bit string
VARIANTS->m_iVariants &= ~(VARIANT_ALTER_ROADS | VARIANT_ALTER_CITIES | VARIANT_ALTER_SETTLEMENTS | VARIANT_ALTER_ALLOWED_CARDS);
//set settings
if(TRUE == GetPrivateProfileInt(INI_VARIANT, INI_VAR_TRADE_ZERO, 0, INI_FILE)) VARIANTS->m_iVariants |= VARIANT_TRADE_ZERO;
if(TRUE == GetPrivateProfileInt(INI_VARIANT, INI_VAR_EQUAL_ODDS, 0, INI_FILE)) VARIANTS->m_iVariants |= VARIANT_EQUAL_ODDS;
if(TRUE == GetPrivateProfileInt(INI_VARIANT, INI_VAR_TRADE_BUILD, 0, INI_FILE)) VARIANTS->m_iVariants |= VARIANT_TRADE_AFTER_BUILD;
if(TRUE == GetPrivateProfileInt(INI_VARIANT, INI_VAR_NO_7, 0, INI_FILE)) VARIANTS->m_iVariants |= VARIANT_NO_7_FIRST_ROUND;
if(TRUE == GetPrivateProfileInt(INI_VARIANT, INI_VAR_SHOW_CARDS, 0, INI_FILE)) VARIANTS->m_iVariants |= VARIANT_SHOW_ALL_CARDS;
if(TRUE == GetPrivateProfileInt(INI_VARIANT, INI_VAR_ROUND_UP, 0, INI_FILE)) VARIANTS->m_iVariants |= VARIANT_ROUND_LOST_UP;
if(TRUE == GetPrivateProfileInt(INI_VARIANT, INI_VAR_HIDE_CHIPS, 0, INI_FILE)) VARIANTS->m_iVariants |= VARIANT_HIDE_CHIPS;
if(TRUE == GetPrivateProfileInt(INI_VARIANT, INI_VAR_SPECIAL, 0, INI_FILE)) VARIANTS->m_iVariants |= VARIANT_SPECIAL_BUILD;
if(TRUE == GetPrivateProfileInt(INI_VARIANT, INI_VAR_TOUR_START, 0, INI_FILE)) VARIANTS->m_iVariants |= VARIANT_TOURNAMENT_START;
if(TRUE == GetPrivateProfileInt(INI_VARIANT, INI_VAR_NO_TRADE, 0, INI_FILE)) VARIANTS->m_iVariants |= VARIANT_NO_TRADING;
if(TRUE == GetPrivateProfileInt(INI_VARIANT, INI_VAR_LIMIT_TRADE, 0, INI_FILE)) VARIANTS->m_iVariants |= VARIANT_LIMIT_TRADING;
//no 7's rounds
VARIANTS->m_nNoSevens = GetPrivateProfileInt(INI_VARIANT, INI_VAR_NO_SEVENS, 1, INI_FILE);
//trade offers limit
VARIANTS->m_nTradeOffers = GetPrivateProfileInt(INI_VARIANT, INI_VAR_LIMIT_NUM, 3, INI_FILE);
//set the allowed cards if the special build phase is turned on
if(IS_VARIANT(VARIANT_SPECIAL_BUILD) && (9 == MAP->m_iAllowedCards))
{
//set it
VARIANTS->m_iAllowedCards = 7;
VARIANTS->m_iVariants |= VARIANT_ALTER_ALLOWED_CARDS;
}
//desert/volcanoes/jungles
VARIANTS->m_iVariants |= GetPrivateProfileInt(INI_VARIANT, INI_VAR_DESERTS, 0, INI_FILE);
//must load sea chips as well if using jungles or deserts
if(IS_VARIANT(VARIANT_USE_JUNGLE) || IS_VARIANT(VARIANT_USE_VOLCANO) || IS_VARIANT(VARIANT_USE_VOLCANO_GOLD))
{
MAP->m_iChipsUsed |= MAP_USES_SEA_CHIPS;
}
//add variant string
str += VARIANTS->getVariantString();
//tell all
VIEW->setInfoString(str);
//handle ladder restrictions
handleLadder();
//now we can choose variants
//.........这里部分代码省略.........
示例12: startReload
/////////////////////////////////////////////////////////////////////////////
// initial start settings
/////////////////////////////////////////////////////////////////////////////
void CNetworkServerDialog::startReload()
{
int i;
CString str;
//set map
m_iMap = GAME->m_uiMapID;
//set the team text
if(TRUE == GAME->m_bTeam)
{
str = "This is a team game.\n\n";
}
//set the ladder text
if(TRUE == GAME->m_bLadder)
{
//get rid of the extra newline
str = str.Left(str.GetLength() - 1);
//add the ladder text
str += "This is a ladder game.\n\n";
}
//create info string
str += MAPS->getMapInfo(m_iMap);
//add variant string
str += VARIANTS->getVariantString();
//set map text
VIEW->setInfoString(str);
//disable map button
m_MapButton.EnableWindow(FALSE);
//boot player button is disabled
m_BootButton.EnableWindow(FALSE);
//enable the connector button for restarts
m_ConnectorButton.EnableWindow();
//set button text
m_OKButton.SetWindowText("Continue!");
//add players to the control
for(i = 0; i < (int) GAME->m_players.size(); i++)
{
m_PlayerList.addPlayer(&(GAME->m_players[i].m_player), GAME->m_players[i].m_iColor);
//add AI's as joined already
if(TRUE == GAME->m_players[i].m_player.getAI())
{
//tell the list
m_PlayerList.updateJoin(GAME->m_players[i].m_player.getID(), TRUE);
//set their flag as joined
GAME->m_players[i].m_bJoined = TRUE;
}
}
//set the server player as joined
m_PlayerList.updateJoin(GAME->m_uiPlayerID, TRUE);
//set their flag as joined
GAME->m_players[GAME->m_iIndex].m_bJoined = TRUE;
//set title text
SetWindowText("Restart a network game");
//with AI, see if we can continue yet
checkForContinue();
}
示例13: DBFSetColumn
int CDbfFile::DBFSetColumn(CStringArray* psDBFColNameList)
{
DBFHandle hDBF;
INT i;
INT j;
INT k;
INT iStringLength;
INT iNumField;
//CString szPolyId;
CString szAttItem;
CFileFind DBFFile;
if (_szDBFName.IsEmpty())
{
_szDBFName = _szFileName.Left(_szFileName.Find('.'));
_szDBFName.Insert(_szFileName.GetLength(), ".dbf");
}
if ((DBFFile.FindFile(_szDBFName)) && (_eMode == KEEP))
{
printf("DBF file already exist");
return 1;
}
else if ((DBFFile.FindFile(_szDBFName) && (_eMode == OVERWRITE)) ||
(!DBFFile.FindFile(_szDBFName)))
{
hDBF = DBFCreate();
if( hDBF == NULL )
{
printf( "DBFCreate(%s) failed.\n", _szDBFName );
return 1;
}
/* if (_szFileName.Find('\\') > 0)
{
szPolyId = _szFileName.Right(_szFileName.GetLength()-_szFileName.ReverseFind('\\')-1);
szPolyId = szPolyId.Left(8) + "_";
}
else
szPolyId = _szFileName.Left(8) + "_";
if( DBFAddField( hDBF, szPolyId, FTDouble, 11, 0) == -1 )
{
printf( "DBFAddField(%s,FTDouble,8,0) failed.\n", szPolyId);
return 1;
}
if (szPolyId.GetLength() > 8)
szPolyId = szPolyId + "i";
else
szPolyId = szPolyId + "id";
if( DBFAddField( hDBF, szPolyId, FTDouble, 11, 0) == -1 )
{
printf( "DBFAddField(%s,FTDouble,8,0) failed.\n", szPolyId);
return 1;
} */
/* -------------------------------------------------------------------- */
/* Loop over the field definitions adding new fields. */
/* -------------------------------------------------------------------- */
iNumField = psDBFColNameList->GetSize();
for( i = 0; i < iNumField; i++ )
{
szAttItem = psDBFColNameList->GetAt(i);
if( strcmp(szAttItem.Left(2),"-s") == 0 )
{
szAttItem.Delete(0, 3);
iStringLength = szAttItem.GetLength();
k = szAttItem.Find(' ');
ASSERT (k > 0);
if( DBFAddField( hDBF, szAttItem.Left(k), FTString,
atoi(szAttItem.Right(iStringLength-k-1)), 0 ) == -1 )
{
printf( "DBFAddField(%s,FTString,%d,0) failed.\n",
psDBFColNameList->GetAt(i+1), atoi(psDBFColNameList->GetAt(i)) );
return 1;
}
}
else if( strcmp(szAttItem.Left(2),"-n") == 0 )
{
szAttItem.Delete(0, 3);
iStringLength = szAttItem.GetLength();
j = szAttItem.Find(' ');
ASSERT (j > 0);
k = szAttItem.ReverseFind(' ');
ASSERT (k > 0);
if( DBFAddField( hDBF, szAttItem.Left(j), FTDouble, atoi(szAttItem.Mid(j+1, k-j-1)),
atoi(szAttItem.Right(iStringLength-k-1)) ) == -1 )
{
printf( "DBFAddField(%s,FTDouble,%d,%d) failed.\n",
psDBFColNameList->GetAt(i+1), atoi(psDBFColNameList->GetAt(i)), atoi(psDBFColNameList->GetAt(i+3)) );
return 1;
}
}
else
{
if(strcmp(szAttItem.Left(2),"-l") == 0)
{
szAttItem.Delete(0, 3);
iStringLength = szAttItem.GetLength();
k = szAttItem.Find(' ');
//.........这里部分代码省略.........
示例14: store_variable
int CChitemDlg::store_variable(CString varname, int storeflags, int opcode, int trigger, int block)
{
CString tmp;
loc_entry dummyloc;
CPoint dummypoint;
int cnt;
int i;
int sf;
sf=storeflags&0xff;
if((trigger&0xff)==SCANNING)
{
if(member_array(sf, scanned_types)==-1) return 0;
}
tmp=resolve_scriptelement(opcode, trigger, block);
switch(sf)
{
case NO_CHECK:
return 0;
case CHECK_GAME:
if(varname.GetLength()>32)
{
log("Bad string constant: '%s' (%s)",varname,tmp);
return 1;
}
return 0;
case CHECK_NUM:
if(chkflg&NORESCHK) return 0;
cnt=varname.GetLength();
if(cnt&3)
{
log("Bad spellnumber list, crippled number: '%s' (%s)",varname,tmp);
return 1; //spell numbers are 4 digits
}
if(cnt>32 || cnt<1)
{
log("Bad spellnumber list, length: '%s' (%s)",varname,tmp);
return 1;
}
while(cnt--)
{
if(!isdigit(varname.GetAt(cnt)) )
{
log("Bad spellnumber list, not numeric: '%s' (%s)",varname,tmp);
return 1;
}
}
return 0;
case IS_VAR:
if(chkflg&NOVARCHK) return 0;
if(!varname.GetLength()) return 0;
log("Unexpected variable: '%s' (%s)",varname,tmp);
return 1;
case CHECK_SRC:
if(chkflg&NORESCHK) return 0;
if(strings.Lookup(varname, dummyloc) ) return 0;
log("Missing strref source: '%s' (%s)", varname, tmp);
return 1;
case CHECK_MOVIE:
if(chkflg&NORESCHK) return 0;
if(movies.Lookup(varname, dummyloc) ) return 0;
if(wbms.Lookup(varname, dummyloc) ) return 0;
log("Missing movie: '%s' (%s)", varname, tmp);
return 1;
case CHECK_SOUND2:
if(varname.IsEmpty()) return 0; // may be empty (iwd2 playsoundeffect)
case CHECK_SOUND:
if(chkflg&NORESCHK) return 0;
if(sounds.Lookup(varname, dummyloc) ) return 0;
log("Missing sound: '%s' (%s)", varname, tmp);
return 1;
case CHECK_DSOUND:
if(chkflg&NORESCHK) return 0;
i=varname.Find(':');
if(i>8 || i<0)
{
log("Invalid sound resource: '%s' (%s)",varname, tmp);
return 1;
}
varname2=varname.Left(i);
varname=varname.Mid(i+1);
if(varname.GetLength() && !sounds.Lookup(varname, dummyloc) )
{
log("Missing sound: '%s' (%s)", varname, tmp);
return 1;
}
if(varname2.GetLength() && !sounds.Lookup(varname2, dummyloc) )
{
log("Missing sound: '%s' (%s)", varname2, tmp);
return 1;
}
return 0;
case CHECK_PAL:
if(chkflg&NORESCHK) return 0;
if(bitmaps.Lookup(varname, dummyloc) ) return 0;
log("Missing palette: '%s' (%s)", varname, tmp);
return 1;
case CHECK_ITEM2:
if(varname.IsEmpty()) return 0; // may be empty (useitemslot)
//.........这里部分代码省略.........
示例15: ImportOldSettings
void CSettingsSaver::ImportOldSettings(CPartFile* file)
{
SettingsList daten;
CString datafilepath;
datafilepath.Format(_T("%s\\%s\\%s.sivka"), file->GetTempPath(), _T("Extra Lists"), file->GetPartMetFileName());
CString strLine;
CStdioFile f;
if (!f.Open(datafilepath, CFile::modeReadWrite | CFile::typeText))
return;
while(f.ReadString(strLine))
{
if (strLine.GetAt(0) == _T('#'))
continue;
int pos = strLine.Find(_T('\n'));
if (pos == -1)
continue;
CString strData = strLine.Left(pos);
CSettingsData* newdata = new CSettingsData(_tstol(strData));
daten.AddTail(newdata);
}
f.Close();
POSITION pos = daten.GetHeadPosition();
if(!pos)
return;
if( ((CSettingsData*)daten.GetAt(pos))->dwData == 0 || ((CSettingsData*)daten.GetAt(pos))->dwData == 1)
{
file->SetEnableAutoDropNNS((((CSettingsData*)daten.GetAt(pos))->dwData)!=0);
}
else
file->SetEnableAutoDropNNS(thePrefs.GetEnableAutoDropNNSDefault());
daten.GetNext(pos);
if( ((CSettingsData*)daten.GetAt(pos))->dwData >= 0 && ((CSettingsData*)daten.GetAt(pos))->dwData <= 60000)
file->SetAutoNNS_Timer(((CSettingsData*)daten.GetAt(pos))->dwData);
else
file->SetAutoNNS_Timer(thePrefs.GetAutoNNS_TimerDefault());
daten.GetNext(pos);
if( ((CSettingsData*)daten.GetAt(pos))->dwData >= 50 && ((CSettingsData*)daten.GetAt(pos))->dwData <= 100)
file->SetMaxRemoveNNSLimit((uint16)((CSettingsData*)daten.GetAt(pos))->dwData);
else
file->SetMaxRemoveNNSLimit(thePrefs.GetMaxRemoveNNSLimitDefault());
daten.GetNext(pos);
if( ((CSettingsData*)daten.GetAt(pos))->dwData == 0 || ((CSettingsData*)daten.GetAt(pos))->dwData == 1)
{
file->SetEnableAutoDropFQS((((CSettingsData*)daten.GetAt(pos))->dwData)!=0);
}
else
file->SetEnableAutoDropFQS(thePrefs.GetEnableAutoDropFQSDefault());
daten.GetNext(pos);
if( ((CSettingsData*)daten.GetAt(pos))->dwData >= 0 && ((CSettingsData*)daten.GetAt(pos))->dwData <= 60000)
file->SetAutoFQS_Timer(((CSettingsData*)daten.GetAt(pos))->dwData);
else
file->SetAutoFQS_Timer(thePrefs.GetAutoFQS_TimerDefault());
daten.GetNext(pos);
if( ((CSettingsData*)daten.GetAt(pos))->dwData >= 50 && ((CSettingsData*)daten.GetAt(pos))->dwData <= 100)
file->SetMaxRemoveFQSLimit((uint16)((CSettingsData*)daten.GetAt(pos))->dwData);
else
file->SetMaxRemoveFQSLimit(thePrefs.GetMaxRemoveFQSLimitDefault());
daten.GetNext(pos);
if( ((CSettingsData*)daten.GetAt(pos))->dwData == 0 || ((CSettingsData*)daten.GetAt(pos))->dwData == 1)
{
file->SetEnableAutoDropQRS((((CSettingsData*)daten.GetAt(pos))->dwData)!=0);
}
else
file->SetEnableAutoDropQRS(thePrefs.GetEnableAutoDropQRSDefault());
daten.GetNext(pos);
if( ((CSettingsData*)daten.GetAt(pos))->dwData >= 0 && ((CSettingsData*)daten.GetAt(pos))->dwData <= 60000)
file->SetAutoHQRS_Timer(((CSettingsData*)daten.GetAt(pos))->dwData);
else
file->SetAutoHQRS_Timer(thePrefs.GetAutoHQRS_TimerDefault());
daten.GetNext(pos);
if( ((CSettingsData*)daten.GetAt(pos))->dwData >= 1000 && ((CSettingsData*)daten.GetAt(pos))->dwData <= 10000)
file->SetMaxRemoveQRS((uint16)((CSettingsData*)daten.GetAt(pos))->dwData);
else
file->SetMaxRemoveQRS(thePrefs.GetMaxRemoveQRSDefault());
daten.GetNext(pos);
if( ((CSettingsData*)daten.GetAt(pos))->dwData >= 50 && ((CSettingsData*)daten.GetAt(pos))->dwData <= 100)
file->SetMaxRemoveQRSLimit((uint16)((CSettingsData*)daten.GetAt(pos))->dwData);
else
file->SetMaxRemoveQRSLimit(thePrefs.GetMaxRemoveQRSLimitDefault());
if(daten.GetCount() > 10) // emulate StulleMule <= v2.2 files
{
// ==> Global Source Limit (customize for files) - Stulle
daten.GetNext(pos);
if( ((CSettingsData*)daten.GetAt(pos))->dwData == 0 || ((CSettingsData*)daten.GetAt(pos))->dwData == 1)
{
file->SetGlobalHL((((CSettingsData*)daten.GetAt(pos))->dwData)!=0);
}
//.........这里部分代码省略.........