vc aaa
来源:互联网 发布:大学c语言编程软件 编辑:程序博客网 时间:2024/06/06 15:42
CString sPath;
GetModuleFileName(NULL,sPath.GetBufferSetLength (MAX_PATH+1),MAX_PATH);
sPath.ReleaseBuffer ();
int nPos;
nPos=sPath.ReverseFind ('//');
sPath=sPath.Left(nPos);
CStdioFile file;
if(file.Open(sPath + "//ldf.ldf", CFile::modeRead))
{
CString strTmp;
while(file.ReadString(strTmp)){
m_strFileText = m_edtOutFile += strTmp + "/r/n";
}
file.Close();
UpdateData(FALSE);
}else
AfxMessageBox("打开ldf文件出错");
m_EdtInput = "Signals.AnmSig_Tx_L14_dummy";
// 按指定字符分割字符串
void split(const CString& str, const CString strCh, CStringArray& strArry)
{
int nS,nE;
nS = nE = 0;
while(1)
{
nE = str.Find(strCh, nS);
if(nE == -1)
nE = str.GetLength();
if(nS <= nE)
{
CString strTmp = str.Mid(nS,nE-nS);
strArry.Add(strTmp);
nS = nE+1;
}else
break;
}
}
// 查找结构体
void searchStruct(const CString& strKey, const CString& str, CString& strStruct)
{
strStruct.Empty();
int nS = str.Find(strKey);
int nE = 0;
int len = str.GetLength();
bool bFirst = true;
UINT nLeftBracesCount = 0;
for (int i = nS; i != -1 && i < len; ++i)
{
TCHAR ch = str.GetAt(i);
if(ch == '{')
{
++nLeftBracesCount;
bFirst = false;
}
strStruct += ch;
if(ch == '}')
--nLeftBracesCount;
if(nLeftBracesCount == 0 && !bFirst)
break;
}
// pThis->m_edtOutFile = strStruct;
// pThis->UpdateData(FALSE);
}
// 取得没有大括号的成员 并以分号结尾的成员
bool getNormMemBer(const CString& strKey ,const CString& strStruct, CString& strMember)
{
strMember.Empty();
//TRACE("getNormMemBer ----/n%s",strStruct);
int nS = 0, len = strStruct.GetLength();
nS = strStruct.Find(strKey);
for (int i = nS; i < len; ++i)
{
TCHAR ch = strStruct.GetAt(i);
if(ch == '{' || ch == '}')
return false;
strMember += ch;
if(ch == ';')
break;
}
return true;
}
// 取得有大括号的成员
bool getBracesMemBer(const CString& strKey ,const CString& strStruct, CString& strMember)
{
//TRACE("getBracesMemBer ----/n%s",strStruct);
searchStruct(strKey, strStruct, strMember);
return !strMember.IsEmpty();
}
// 取得面员
void getMember(const CString& strKey, const CString& strStruct, CString& strMember)
{
if(getNormMemBer(strKey,strStruct, strMember))
return;
getBracesMemBer(strKey,strStruct, strMember);
}
//
CString GetData(const CString& strPath, const CString& strFile)
{
CStringArray strAry;
split(strPath,".",strAry);
CString strStruct = "";
if(strAry.GetSize() != 0)
searchStruct(strAry.GetAt(0), strFile, strStruct);
if(strStruct.IsEmpty())
return "";
CString strRc = strStruct;
for (int i = 1; i < strAry.GetSize();++i)
{
getMember(strAry[i], strStruct, strRc);
strStruct = strRc;
}
return strRc;
}
void CLdfDlg::OnOK()
{
int nS,nE;
((CEdit*)GetDlgItem(IDC_EDIT3))->GetSel(nS,nE);
m_edtOut.Empty();
m_edtOutFile.Empty();
UpdateData(TRUE);
m_EdtInput.TrimLeft(" ");
m_EdtInput.TrimRight(" ");
m_edtOut = GetData(m_EdtInput, m_strFileText);
UpdateData(FALSE);
((CEdit*)GetDlgItem(IDC_EDIT3))->SetSel(nS,nE);
return;
}
#endif
void CLdfDlg::OnBnClickedOk()
{
// TODO: 在此添加控件通知处理程序代码
OnOK();
}
// 按指定字符分割字符串
void split(const CString& str, const CString strCh, CStringArray& strArry)
{
int nS,nE;
nS = nE = 0;
while(1)
{
nE = str.Find(strCh, nS);
if(nE == -1)
nE = str.GetLength();
if(nS <= nE)
{
CString strTmp = str.Mid(nS,nE-nS);
strArry.Add(strTmp);
nS = nE+1;
}else
break;
}
}
// 查找结构体
void searchStruct(const CString& strKey, const CString& str, CString& strStruct)
{
strStruct.Empty();
int nS = str.Find(strKey);
int nE = 0;
int len = str.GetLength();
bool bFirst = true;
UINT nLeftBracesCount = 0;
for (int i = nS; i != -1 && i < len; ++i)
{
TCHAR ch = str.GetAt(i);
if(ch == '{')
{
++nLeftBracesCount;
bFirst = false;
}
strStruct += ch;
if(ch == '}')
--nLeftBracesCount;
if(nLeftBracesCount == 0 && !bFirst)
break;
}
// pThis->m_edtOutFile = strStruct;
// pThis->UpdateData(FALSE);
}
// 取得没有大括号的成员 并以分号结尾的成员
bool getNormMemBer(const CString& strKey ,const CString& strStruct, CString& strMember)
{
strMember.Empty();
//TRACE("getNormMemBer ----/n%s",strStruct);
int nS = 0, len = strStruct.GetLength();
nS = strStruct.Find(strKey);
for (int i = nS; i < len; ++i)
{
TCHAR ch = strStruct.GetAt(i);
if(ch == '{' || ch == '}')
return false;
strMember += ch;
if(ch == ';')
break;
}
return true;
}
// 取得有大括号的成员
bool getBracesMemBer(const CString& strKey ,const CString& strStruct, CString& strMember)
{
//TRACE("getBracesMemBer ----/n%s",strStruct);
searchStruct(strKey, strStruct, strMember);
return !strMember.IsEmpty();
}
// 取得面员
void getMember(const CString& strKey, const CString& strStruct, CString& strMember)
{
if(getNormMemBer(strKey,strStruct, strMember))
return;
getBracesMemBer(strKey,strStruct, strMember);
}
//
CString GetData(const CString& strPath, const CString& strFile)
{
CStringArray strAry;
split(strPath,".",strAry);
CString strStruct = "";
if(strAry.GetSize() != 0)
searchStruct(strAry.GetAt(0), strFile, strStruct);
if(strStruct.IsEmpty())
return "";
CString strRc = strStruct;
for (int i = 1; i < strAry.GetSize();++i)
{
getMember(strAry[i], strStruct, strRc);
strStruct = strRc;
}
return strRc;
}
void CLdfDlg::OnOK()
{
int nS,nE;
((CEdit*)GetDlgItem(IDC_EDIT3))->GetSel(nS,nE);
m_edtOut.Empty();
m_edtOutFile.Empty();
UpdateData(TRUE);
m_EdtInput.TrimLeft(" ");
m_EdtInput.TrimRight(" ");
m_edtOut = GetData(m_EdtInput, m_strFileText);
UpdateData(FALSE);
((CEdit*)GetDlgItem(IDC_EDIT3))->SetSel(nS,nE);
return;
}
#endif
void CLdfDlg::OnBnClickedOk()
{
// TODO: 在此添加控件通知处理程序代码
OnOK();
}
- vc aaa
- aaa
- aaa
- aaa
- aaa
- aaa
- aaa
- aaa
- AAA
- aaa
- aaa
- aaa
- aaa
- aaa
- aaa
- aaa
- aaa
- aaa
- 新年新起点-荣获2011年度Silverlight方向Microsoft® MVP奖
- Linux系统共享库编程
- 【WSD】the 1st week:WSD's Motivation
- C#动态生成Word文档并填充数据(一)
- 类Linux中各种各样的编程语言
- vc aaa
- C#动态生成Word文档并填充数据(二)
- Checked vs UnChecked 异常
- Linux操作系统内核模块和驱动的编写过程
- Linux操作系统下取得UUID的方法
- __declspec(selectany) 的作用是什么
- 程序员的十层楼
- 游戏策划需要了解的网游数据结构
- Linux操作系统Shell基础知识