// CcosConsoleScript.cpp : 定义 DLL 应用程序的导出函数。 // #include "stdafx.h" #include "CcosConsoleScript.h" #include "common_api.h" //CCOSCONSOLESCRIPT_CAPI INT LoadDCS(CcosConsoleScript **pDCSList) //{ // return 0; //} CcosConsoleScript::CcosConsoleScript(void) { m_pCommandMap = new map(); } CcosConsoleScript::~CcosConsoleScript() { if (m_pCommandMap) { delete m_pCommandMap; m_pCommandMap = NULL; } } bool CcosConsoleScript::MakeCmd(const char *pCmd, const char* pClassFunc) { if (pCmd && pClassFunc && strlen(pCmd) > 0) { map::iterator iter = m_pCommandMap->find(pCmd); if (iter == m_pCommandMap->end()) { //ok (*m_pCommandMap)[pCmd] = pClassFunc; return true; } } return false; } const char* CcosConsoleScript::GetFunc(const char *pCmd) { if (pCmd && strlen(pCmd) > 0) { map::iterator iter = m_pCommandMap->find(pCmd); if (iter != m_pCommandMap->end()) { //ok return iter->second; } } return NULL; } ResDataObject CcosConsoleScript::SeperateCommand(const char *pReq) { ResDataObject ret; string args = " "; vector nodes; if (SplitString(pReq, args, nodes)) { for (size_t i = 0; i < nodes.size(); i++) { string idx = ""; std::stringstream strm; strm << i; strm >> idx; ret.add(idx.c_str(), nodes[i].c_str()); } } return ret; } void CcosConsoleScript::Help() { return; } DCS_RET CcosConsoleScript::Command(ResDataObject &Req) { return DCS_NOT_SUPPORT; }