📄 var.cpp
字号:
// Var.cpp: implementation of the CVar class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "g.h"
#include "Var.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CVar::CVar()
{
}
CVar::~CVar()
{
}
void CVar::Create(CString sType, CString name, CString s1, CString s2,CString var)
{
m_sName=name;
m_s1=s1;
m_s2=s2;
m_var=var;
if(m_s2.IsEmpty())
m_s2=" ";
m_bInt=(sType=="#int");
m_bNew=s1.IsEmpty()?TRUE:FALSE;
}
void CVar::Update(CString s)
{
if(m_s1.IsEmpty())
return;
BOOL b=FALSE;
int n=s.Find(m_s1);
if(-1!=n)
{
s=s.Mid(n+m_s1.GetLength());
s.TrimLeft();
n=s.Find(m_s2);
if(n!=-1)
{
m_var=s.Left(n);
m_var.TrimRight();
b=TRUE;
}
}
m_bNew=b;
}
//////////////////////////////////////////////////////////////////////
// CTriger Class
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CTriger::CTriger()
{
}
CTriger::~CTriger()
{
}
void CTriger::Create(CString sID,CString sA, CString c, CString sB, CString sC)
{
m_sA=sA;
m_sCond=c;
m_sB=sB;
m_sC=sC;
m_sID=sID;
m_bActive=TRUE;
}
CString CTriger::GetTrString(CString s,CObList* pList)
{
CString ret;
if(!m_sA.IsEmpty())//是变量
{
int a,b;
CVar* pv;
POSITION pos=pList->GetHeadPosition();
while(pos)
{
pv=(CVar*)pList->GetNext(pos);
if(pv->m_sName==m_sA)//找到
{
if(!pv->m_bNew) //变量无效,返回
break;
if(pv->m_bInt)//是数字 #if1 a>b
{
a=::atoi((LPTSTR)(LPCTSTR)pv->m_var);
b=::atoi((LPTSTR)(LPCTSTR)m_sB);
if(m_sCond==">")
{
if(a>b)
ret=m_sC;
}
else if(m_sCond=="<")
{
if(a<b)
ret=m_sC;
}
else if(m_sCond==">=")
{
if(a>=b)
ret=m_sC;
}
else if(m_sCond=="<=")
{
if(a<=b)
ret=m_sC;
}
else if(m_sCond=="!=")
{
if(a!=b)
ret=m_sC;
}
else if(a==b)
ret=m_sC;
}
else if(!m_sCond.IsEmpty())//是字符串 #if s=dgdgg c
{
if(pv->m_var==m_sB)
ret=m_sC;
}
else if(-1!=s.Find(pv->m_var)) //是字符串 #if1 s c
ret=m_sC;
break;
}
}
}
else if(-1!=s.Find(m_sB)) //#if1 "dkfj"
ret=m_sC;
return ret;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -