const char* Property::ParseInstanceNameProperty(const char* fullName, char* agentIntanceName, char* agentType) { //Self.AgentActionTest::Action2(0) const char* pClassBegin = strchr(fullName, '.'); if (pClassBegin) { int posClass = pClassBegin - fullName; BEHAVIAC_ASSERT(posClass < kInstanceLength); string_ncpy(agentIntanceName, fullName, posClass); agentIntanceName[posClass] = '\0'; const char* pAgentType = pClassBegin + 1; const char* pPropertyName = strrchr(pAgentType, ':'); BEHAVIAC_ASSERT(pPropertyName); int agentTypeLength = pPropertyName - 1 - pAgentType; string_ncpy(agentType, pAgentType, agentTypeLength); agentType[agentTypeLength] = '\0'; const char* propertyName = pPropertyName + 1; return propertyName; } return fullName; }
const char* Action::ParseMethodNames(const char* fullName, char* agentIntanceName, char* agentClassName, char* methodName) { //Self.test_ns::AgentActionTest::Action2(0) string str; const char* pClassBegin = strchr(fullName, '.'); BEHAVIAC_ASSERT(pClassBegin); size_t posClass = pClassBegin - fullName; BEHAVIAC_ASSERT(posClass < kNameLength); string_ncpy(agentIntanceName, fullName, posClass); agentIntanceName[posClass] = '\0'; const char* pBeginAgentClass = pClassBegin + 1; const char* pBeginP = strchr(pBeginAgentClass, '('); BEHAVIAC_ASSERT(pBeginP); //test_ns::AgentActionTest::Action2(0) const char* pBeginMethod = strrchr(pBeginAgentClass, pBeginP, ':'); BEHAVIAC_ASSERT(pBeginMethod); //skip '::' BEHAVIAC_ASSERT(pBeginMethod[0] == ':' && pBeginMethod[-1] == ':'); pBeginMethod += 1; size_t pos1 = pBeginP - pBeginMethod; BEHAVIAC_ASSERT(pos1 < kNameLength); string_ncpy(methodName, pBeginMethod, pos1); methodName[pos1] = '\0'; size_t pos = pBeginMethod - 2 - pBeginAgentClass; BEHAVIAC_ASSERT(pos < kNameLength); string_ncpy(agentClassName, pBeginAgentClass, pos); agentClassName[pos] = '\0'; return pBeginP; }
void Workspace::SetFilePath(const char* szExportPath) { string_ncpy(this->m_szWorkspaceExportPath, szExportPath, kMaxPath); int len = strlen(szExportPath); if (szExportPath[len - 1] == '/' || szExportPath[len - 1] == '\\') { } else { this->m_szWorkspaceExportPath[len] = '/'; this->m_szWorkspaceExportPath[len + 1] = '\0'; } }
void ConnectorInterface::SendText(const char* text, uint8_t commandId) { if (this->IsConnected()) { Packet packet(commandId, s_seq.Next()); char* pT = (char*)packet.data; BEHAVIAC_ASSERT(kMaxTextLength < kMaxPacketDataSize); string_ncpy(pT, text, kMaxTextLength); pT[kMaxTextLength] = '\0'; this->AddPacket(packet, true); gs_packetsStats.texts++; } }
void ConnectorInterface::RecordText(const char* text) { if (this->m_packetPool) { //if it is out of memory here, please check 'SetupConnection' Packet* pP = this->m_packetPool->Allocate(); if (pP) { pP->Init(CommandId::CMDID_TEXT, s_seq.Next()); Text* pT = (Text*)pP->data; string_ncpy(pT->buffer, text, kMaxTextLength); pT->buffer[kMaxTextLength] = '\0'; } } }
void Workspace::SetFilePath(const char* szExportPath) { string_ncpy(this->m_szWorkspaceExportPath, szExportPath, kMaxPath); BEHAVIAC_LOGINFO(m_szWorkspaceExportPath); }