123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- // 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<string, const char*>();
- }
- 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<string, const char*>::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<string, const char*>::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<string> 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;
- }
|