DiosConsoleScript.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // CcosConsoleScript.cpp : 定义 DLL 应用程序的导出函数。
  2. //
  3. #include "stdafx.h"
  4. #include "CcosConsoleScript.h"
  5. #include "common_api.h"
  6. //CCOSCONSOLESCRIPT_CAPI INT LoadDCS(CcosConsoleScript **pDCSList)
  7. //{
  8. // return 0;
  9. //}
  10. CcosConsoleScript::CcosConsoleScript(void)
  11. {
  12. m_pCommandMap = new map<string, const char*>();
  13. }
  14. CcosConsoleScript::~CcosConsoleScript()
  15. {
  16. if (m_pCommandMap)
  17. {
  18. delete m_pCommandMap;
  19. m_pCommandMap = NULL;
  20. }
  21. }
  22. bool CcosConsoleScript::MakeCmd(const char *pCmd, const char* pClassFunc)
  23. {
  24. if (pCmd && pClassFunc && strlen(pCmd) > 0)
  25. {
  26. map<string, const char*>::iterator iter = m_pCommandMap->find(pCmd);
  27. if (iter == m_pCommandMap->end())
  28. {
  29. //ok
  30. (*m_pCommandMap)[pCmd] = pClassFunc;
  31. return true;
  32. }
  33. }
  34. return false;
  35. }
  36. const char* CcosConsoleScript::GetFunc(const char *pCmd)
  37. {
  38. if (pCmd && strlen(pCmd) > 0)
  39. {
  40. map<string, const char*>::iterator iter = m_pCommandMap->find(pCmd);
  41. if (iter != m_pCommandMap->end())
  42. {
  43. //ok
  44. return iter->second;
  45. }
  46. }
  47. return NULL;
  48. }
  49. ResDataObject CcosConsoleScript::SeperateCommand(const char *pReq)
  50. {
  51. ResDataObject ret;
  52. string args = " ";
  53. vector<string> nodes;
  54. if (SplitString(pReq, args, nodes))
  55. {
  56. for (size_t i = 0; i < nodes.size(); i++)
  57. {
  58. string idx = "";
  59. std::stringstream strm;
  60. strm << i;
  61. strm >> idx;
  62. ret.add(idx.c_str(), nodes[i].c_str());
  63. }
  64. }
  65. return ret;
  66. }
  67. void CcosConsoleScript::Help()
  68. {
  69. return;
  70. }
  71. DCS_RET CcosConsoleScript::Command(ResDataObject &Req)
  72. {
  73. return DCS_NOT_SUPPORT;
  74. }