⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dsacdobject.cpp

📁 dsacd_ivr 的实现
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// dsACDObject.cpp: implementation of the dsACDObject class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "dsACD_IVR.h"
#include "dsACDStruct.h"
#include "dsACDObject.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
/********************************************************************************
*						以下为链表结构中的操作          
/********************************************************************************/
void dsMapHTreeToObj::AddMapItem(HTREEITEM h, dsACDObjectBase *pObj)
{
	if (pListHead == NULL)
	{
		pListHead = pListTail = new ListMapItem;
		pListHead->hTree = h;
		pListHead->pACDObj = pObj;
		pListHead->pListNext =NULL;
	}
	else
	{
		ListMapItem *pTemp = new ListMapItem;
		pTemp->hTree = h;
		pTemp->pACDObj = pObj;
		pTemp->pListNext = NULL;

		pListTail->pListNext = pTemp;
		pListTail = pTemp;
	}
}

dsMapHTreeToObj::ListMapItem * dsMapHTreeToObj::Find(HTREEITEM h)
{
	ListMapItem * pTemp = pListHead;
	for (; pTemp != NULL; pTemp = pTemp->pListNext)
	{
		if (pTemp->hTree == h)
		{
			return pTemp;
		}
	}
	return NULL;
}

dsMapHTreeToObj::ListMapItem * dsMapHTreeToObj::GetPreItem(ListMapItem * pItem)
{
	ListMapItem * pTemp = pListHead;
	if (pItem == pListHead)
		return NULL;
	for (; pTemp!= NULL && (pTemp->pListNext)!= pItem; pTemp = pTemp->pListNext);
	return pTemp;
}

void dsMapHTreeToObj::RemoveMapItem(HTREEITEM h)
{
	ListMapItem * pTemp = Find(h);
	if (pTemp != NULL)
	{
		if (pTemp == pListHead)
		{
			if (pListTail == pListHead)
			{	
				delete pTemp->pACDObj; 
				delete pTemp;
				pListTail = pListHead = NULL;
			}
			else
			{
				pListHead = pListHead->pListNext;
				delete pTemp->pACDObj; 
				delete pTemp;
			}
		}
		else if (pTemp == pListTail)
		{
			ListMapItem * pPreTemp = GetPreItem(pTemp);
			pListTail = pPreTemp;
			pListTail->pListNext = NULL;
			delete pTemp->pACDObj; 
			delete pTemp;
		}
		else 
		{
			ListMapItem * pPreTemp = GetPreItem(pTemp);
			pPreTemp->pListNext = pTemp->pListNext;
			delete pTemp->pACDObj; 
			delete pTemp;
		}
	}
}

void  dsMapHTreeToObj::RemoveAllListItem()
{
	while (pListHead != NULL)
	{
		ListMapItem *pTemp = pListHead;
		pListHead = pListHead->pListNext;
		delete pTemp->pACDObj; 
		delete pTemp;		
	}
}

void dsMapHTreeToObj::SetAt(HTREEITEM h, dsACDObjectBase * pObj)
{
	ListMapItem * pTemp = Find(h);
	if (pTemp != NULL)
	{
		delete pTemp->pACDObj;
		pTemp->pACDObj = pObj;
	}
}

void dsMapHTreeToObj::SetTreeItem(HTREEITEM hOldTree, HTREEITEM hNewTree)
{
	ListMapItem * pTemp = Find(hOldTree);
	if (pTemp != NULL)
		pTemp->hTree = hNewTree;
}

dsACDObjectBase * dsMapHTreeToObj::FindObj(HTREEITEM h)
{
	ListMapItem * pTemp = Find(h);
	if (pTemp != NULL)
		return pTemp->pACDObj;
	return NULL;
}

/********************************************************************************
*						以下为具体语句中的文件操作          
/********************************************************************************/

//	四条框架语句中的写文件
void dsACDDataDefine::WritetoFile (CStdioFile& m_IOFile, int flag)
{
	m_IOFile.WriteString( "[DataDefine]\n");

	CString str;
	str.Format("%x",nID);
	m_IOFile.WriteString(str + ":");

	str.Format("%d",flag);
	m_IOFile.WriteString( "Flag=" + str + ";\n");
}

void dsACDReturnValue::WritetoFile (CStdioFile& m_IOFile, int flag)
{
	CString str;
	str.Format("%x",nID);
	m_IOFile.WriteString(str + ":");

	str.Format("%d",flag);
	m_IOFile.WriteString( "Flag=" + str + ";\n");
}

void dsACDFlowBegin::WritetoFile (CStdioFile& m_IOFile, int flag)
{
	m_IOFile.WriteString( "[FlowBegin]\n");

	CString str;
	str.Format("%x",nID);
	m_IOFile.WriteString(str + ":");

	str.Format("%d",flag);
	m_IOFile.WriteString( "Flag=" + str + ";\n");
}

void dsACDFlowEnd::WritetoFile (CStdioFile& m_IOFile, int flag)
{
	m_IOFile.WriteString( "[FlowEnd]\n");

	CString str;
	str.Format("%x",nID);
	m_IOFile.WriteString(str + ":");

	str.Format("%d",flag);	
	m_IOFile.WriteString( "Flag=" + str + ";\n");
}

//	变量定义语句中的文件读写
void dsACDObjVariable::WritetoFile (CStdioFile& m_IOFile, int flag)
{
	CString str;
	str.Format("%x",nID);
	m_IOFile.WriteString( str + ":" );

	str.Format("%d",flag);		
	m_IOFile.WriteString( "Flag=" + str + ";");

	m_IOFile.WriteString( "Name=" + pInfo->Name + ";");
	m_IOFile.WriteString( "Value=" + pInfo->Value + ";");
	m_IOFile.WriteString( "Comment=" + pInfo->Comment + "\n");
}
void dsACDObjVariable::ReadformFile(const CString &buf, dsVD_INFO *pInfo, CString &csItemText)
{
	pInfo->Name = buf.Mid(buf.Find("Name")+5, buf.Find("Value")-buf.Find("Name")-6);
	pInfo->Value = buf.Mid(buf.Find("Value")+6, buf.Find("Comment")-buf.Find("Value")-7);
	pInfo->Comment = buf.Right(buf.GetLength()-buf.Find("Comment")-8);

	if ((pInfo->Value == "")&&(pInfo->Comment == ""))
		csItemText = "变量定义:" + pInfo->Name ;
	else if (pInfo->Value == "")
		csItemText = "变量定义:" + pInfo->Name  + " {" + pInfo->Comment + "}";
	else if (pInfo->Comment == "")
		csItemText = "变量定义:" + pInfo->Name  + " 初值 " +pInfo->Value;
	else
		csItemText = "变量定义:" + pInfo->Name  + " 初值 " +pInfo->Value + " {" + pInfo->Comment + "}";
}

//	数据分类语句中的文件读写
void dsACDObjDataSort::WritetoFile (CStdioFile& m_IOFile, int flag)
{
	CString str;
	str.Format("%x",nID);
	m_IOFile.WriteString( str + ":" );

	str.Format("%d",flag);		
	m_IOFile.WriteString( "Flag=" + str + ";");

	m_IOFile.WriteString( "Comment=" + pInfo->Comment + "\n");
}
void dsACDObjDataSort::ReadformFile(const CString &buf, dsDS_INFO *pInfo, CString &csItemText)
{
	pInfo->Comment = buf.Right(buf.GetLength()-buf.Find("Comment")-8);

	if (pInfo->Comment == "")
		csItemText = "数据分类";
	else
		csItemText = "数据分类 {" + pInfo->Comment + "}";
}

//	数据库连接语句中的文件读写
void dsACDDBConnect::WritetoFile (CStdioFile& m_IOFile, int flag)
{
	CString str;
	str.Format("%x",nID);
	m_IOFile.WriteString( str + ":" );

	str.Format("%d",flag);		
	m_IOFile.WriteString( "Flag=" + str + ";");

	m_IOFile.WriteString( "DB_NAME=" + pInfo->Name + ";");
	m_IOFile.WriteString( "DB_LINK=" + pInfo->Link + ";");
	m_IOFile.WriteString( "CMD_TYPE=" + pInfo->Type + ";");
	m_IOFile.WriteString( "CMD_CONTENT=" + pInfo->Content + ";");
	m_IOFile.WriteString( "DB_COMMENT=" + pInfo->Comment + "\n");
}
void dsACDDBConnect::ReadformFile(const CString &buf, dsDBConn_INFO *pInfo, CString &csItemText)
{
	pInfo->Name = buf.Mid(buf.Find("DB_NAME")+8, buf.Find("DB_LINK")-buf.Find("DB_NAME")-9);
	pInfo->Link = buf.Mid(buf.Find("DB_LINK")+8, buf.Find("CMD_TYPE")-buf.Find("DB_LINK")-9);
	pInfo->Type = buf.Mid(buf.Find("CMD_TYPE")+9, buf.Find("CMD_CONTENT")-buf.Find("CMD_TYPE")-10);
	pInfo->Content = buf.Mid(buf.Find("CMD_CONTENT")+12, buf.Find("DB_COMMENT")-buf.Find("CMD_CONTENT")-13);
	pInfo->Comment = buf.Right(buf.GetLength()-buf.Find("DB_COMMENT")-11);

	if (pInfo->Comment != "")
		csItemText = "数据库连接:" + pInfo->Name + " " + pInfo->Type + " " + pInfo->Content + " {" + pInfo->Comment + "}";
	else 
		csItemText = "数据库连接:" + pInfo->Name + " " + pInfo->Type + " " + pInfo->Content;
}

//	条件控制语句中的文件读写
void dsACDConControl::WritetoFile (CStdioFile& m_IOFile, int flag)
{
	CString str;
	str.Format("%x",nID);
	m_IOFile.WriteString( str + ":" );

	str.Format("%d",flag);		
	m_IOFile.WriteString( "Flag=" + str + ";");

	m_IOFile.WriteString( "Condition=" + pInfo->Condition + ";");
	m_IOFile.WriteString( "Comment=" + pInfo->Comment + "\n");
}
void dsACDConControl::ReadformFile(const CString &buf, dsCC_INFO *pInfo, CString &csItemText)
{
	pInfo->Condition = buf.Mid(buf.Find("Condition")+10, buf.Find("Comment")-buf.Find("Condition")-11);
	pInfo->Comment = buf.Right(buf.GetLength()-buf.Find("Comment")-8);

	if ((pInfo->Condition == "")&&(pInfo->Comment == ""))
		csItemText = "条件控制: 空" ;
	else if (pInfo->Condition == "")
		csItemText = "条件控制: 空 {" + pInfo->Comment + "}";
	else if (pInfo->Comment == "")
		csItemText = "条件控制: " + pInfo->Condition;
	else
		csItemText = "条件控制: " + pInfo->Condition + " {" + pInfo->Comment + "}";
}
void dsACDConTrue::WritetoFile (CStdioFile& m_IOFile, int flag)
{
	CString str;
	str.Format("%x",nID);
	m_IOFile.WriteString(str + ":");

	str.Format("%d",flag);
	m_IOFile.WriteString( "Flag=" + str + ";\n");
}
void dsACDConFalse::WritetoFile (CStdioFile& m_IOFile, int flag)
{
	CString str;
	str.Format("%x",nID);
	m_IOFile.WriteString(str + ":");

	str.Format("%d",flag);
	m_IOFile.WriteString( "Flag=" + str + ";\n");
}

//	多路分支语句中的文件读写
void dsACDSwitch::WritetoFile (CStdioFile& m_IOFile, int flag)
{
	CString str;
	str.Format("%x",nID);
	m_IOFile.WriteString( str + ":" );

	str.Format("%d",flag);		
	m_IOFile.WriteString( "Flag=" + str + ";");

	m_IOFile.WriteString( "Condition=" + pInfo->Condition + ";");
	m_IOFile.WriteString( "Comment=" + pInfo->Comment + "\n");
}
void dsACDSwitch::ReadformFile(const CString &buf, dsSM_INFO *pInfo, CString &csItemText)
{
	pInfo->Condition = buf.Mid(buf.Find("Condition")+10, buf.Find("Comment")-buf.Find("Condition")-11);
	pInfo->Comment = buf.Right(buf.GetLength()-buf.Find("Comment")-8);

	if ((pInfo->Condition == "")&&(pInfo->Comment == ""))
		csItemText = "多路分支: 空" ;
	else if (pInfo->Condition == "")
		csItemText = "多路分支: 空 {" + pInfo->Comment + "}";
	else if (pInfo->Comment == "")
		csItemText = "多路分支: " + pInfo->Condition;
	else
		csItemText = "多路分支: " + pInfo->Condition + " {" + pInfo->Comment + "}";
}
void dsACDDefaultMatch::WritetoFile (CStdioFile& m_IOFile, int flag)
{
	CString str;
	str.Format("%x",nID);
	m_IOFile.WriteString(str + ":");

	str.Format("%d",flag);
	m_IOFile.WriteString( "Flag=" + str + ";\n");
}

//	分支匹配语句中的文件读写
void dsACDMatch::WritetoFile (CStdioFile& m_IOFile, int flag)
{
	CString str;
	str.Format("%x",nID);
	m_IOFile.WriteString( str + ":" );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -