本文整理汇总了C++中behaviac::string类的典型用法代码示例。如果您正苦于以下问题:C++ string类的具体用法?C++ string怎么用?C++ string使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了string类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: BEHAVIAC_UNUSED_VAR
bool CFileSystem::StartMonitoringDirectory(const wchar_t* dir) {
BEHAVIAC_UNUSED_VAR(dir);
#if BEHAVIAC_CCDEFINE_GCC_LINUX
if (!s_bThreadFinish) {
return true;
}
s_bThreadFinish = false;
behaviac::wstring dirW = dir;
//to use static!
static behaviac::string s_buffer = "";
s_buffer = behaviac::StringUtils::Wide2Char(dirW);
if (pthread_create(&s_tid, NULL, ThreadFunc, const_cast<char*>(s_buffer.c_str())) < 0) {
return false;
}
//pthread_detach(tid);
#endif
return true;
}
开发者ID:czfsvn,项目名称:LinuxC,代码行数:27,代码来源:filesystem_gcc.cpp
示例2: MBSToWCS
/// convert multibyte string to wide char string
bool MBSToWCS(behaviac::wstring& resultString, const behaviac::string& str, const char* locale)
{
BEHAVIAC_UNUSED_VAR(resultString);
BEHAVIAC_UNUSED_VAR(str);
BEHAVIAC_UNUSED_VAR(locale);
bool ret = false;
#if BEHAVIAC_COMPILER_MSVC
const int cp = (strcmp(locale, LOCALE_CN_UTF8) == 0) ? CP_UTF8 : CP_ACP;
const int dwNum = MultiByteToWideChar(cp, 0, str.c_str(), -1, 0, 0);
wchar_t* buffer = (wchar_t*)BEHAVIAC_MALLOC_WITHTAG(dwNum * 2 + 2, "MBSToWCS");
if (buffer)
{
MultiByteToWideChar(cp, 0, str.c_str(), -1, buffer, dwNum);
resultString = buffer;
BEHAVIAC_FREE(buffer);
ret = true;
}
#else
uint32_t dwNum = (str.size() + 1) * 4;
wchar_t* buffer = (wchar_t*)BEHAVIAC_MALLOC_WITHTAG(dwNum, "MBSToWCS");
if (buffer)
{
//remember it to restore it later
char* currrentLocale = setlocale(LC_ALL, 0);
char* loc = setlocale(LC_ALL, locale);
if (loc)
{
mbstowcs(buffer, str.c_str(), dwNum);
ret = true;
}
//restore
setlocale(LC_ALL, currrentLocale);
resultString = buffer;
BEHAVIAC_FREE(buffer);
}
#endif//#if BEHAVIAC_COMPILER_MSVC
return ret;
}
开发者ID:1414648814,项目名称:behaviac,代码行数:52,代码来源:stringutils.cpp
示例3: ParseForParams
//suppose params are seprated by ','
static void ParseForParams(const behaviac::string& tsrc, behaviac::vector<behaviac::string>& params)
{
int tsrcLen = (int)tsrc.size();
int startIndex = 0;
int index = 0;
int quoteDepth = 0;
for (; index < tsrcLen; ++index)
{
if (tsrc[index] == '"')
{
quoteDepth++;
//if (quoteDepth == 1)
//{
// startIndex = index;
//}
if ((quoteDepth & 0x1) == 0)
{
//closing quote
quoteDepth -= 2;
BEHAVIAC_ASSERT(quoteDepth >= 0);
}
}
else if (quoteDepth == 0 && tsrc[index] == ',')
{
//skip ',' inside quotes, like "count, count"
int lengthTemp = index - startIndex;
behaviac::string strTemp = tsrc.substr(startIndex, lengthTemp);
params.push_back(strTemp);
startIndex = index + 1;
}
}//end for
// the last param
int lengthTemp = index - startIndex;
if (lengthTemp > 0)
{
behaviac::string strTemp = tsrc.substr(startIndex, lengthTemp);
params.push_back(strTemp);
//params.push_back(strTemp);
}
}
开发者ID:Evilcoolkings,项目名称:behaviac,代码行数:47,代码来源:action.cpp
示例4: test_stochastic_distribution_0
void test_stochastic_distribution_0(behaviac::string tree, behaviac::Workspace::EFileFormat format)
{
behaviac::Profiler::CreateInstance();
behaviac::Config::SetSocketing(false);
behaviac::Config::SetLogging(false);
//behaviac::Agent::Register<AgentNodeTest>();
registerAllTypes();
AgentNodeTest* myTestAgent = AgentNodeTest::DynamicCast(behaviac::Agent::Create<AgentNodeTest>());
behaviac::Agent::SetIdMask(1);
myTestAgent->SetIdFlag(1);
//ms_workspace = new BehaviacWorkspace();
myTestAgent->btload(tree.c_str());
myTestAgent->btsetcurrent(tree.c_str());
myTestAgent->resetProperties();
int counts[3] = { 0, 0, 0 };
int loopCount = STOCHASTIC_SAMPLE_COUNT;
while (loopCount > 0)
{
myTestAgent->btexec();
++(counts[myTestAgent->testVar_0]);
--loopCount;
}
#if BEHAVIAC_COMPILER_MSVC
for (int i = 0; i < 3; ++i)
{
int k = counts[i];
int bias = abs(k - STOCHASTIC_SAMPLE_COUNT / 3);
CHECK_LESS(bias, (STOCHASTIC_SAMPLE_COUNT / 20));
}
#endif
unregisterAllTypes();
BEHAVIAC_DELETE(myTestAgent);
//behaviac::Agent::UnRegister<AgentNodeTest>();
behaviac::Profiler::DestroyInstance();
}
开发者ID:Evilcoolkings,项目名称:behaviac,代码行数:43,代码来源:NodeUnitTest.cpp
示例5: BEHAVIAC_UNUSED_VAR
void LogManager::Log(const behaviac::Agent* pAgent, const char* typeName, const char* varName, const char* value)
{
BEHAVIAC_UNUSED_VAR(pAgent);
BEHAVIAC_UNUSED_VAR(typeName);
BEHAVIAC_UNUSED_VAR(varName);
BEHAVIAC_UNUSED_VAR(value);
if (Config::IsLoggingOrSocketing())
{
//BEHAVIAC_PROFILE("LogManager::LogVar");
if (pAgent && pAgent->IsMasked())
{
const char* agentClassName = pAgent->GetObjectTypeName();
const behaviac::string agentInstanceName = pAgent->GetName();
//[property]WorldState::World WorldState::time->276854364
//[property]Ship::Ship_1 GameObject::HP->100
//[property]Ship::Ship_1 GameObject::age->0
//[property]Ship::Ship_1 GameObject::speed->0.000000
behaviac::string buffer;
bool bIsPar = IsParVar(varName);
if (bIsPar)
{
behaviac::string tn = typeName;
//filter out "signed "
const char* p = strstr(typeName, "signed ");
if (p)
{
behaviac::string tn2;
for (const char* pi = typeName; pi < p; ++pi)
{
tn2 += *pi;
}
tn2 += (p + 7);
tn = tn2;
}
buffer = FormatString("[property]%s#%s %s %s->%s\n", agentClassName, agentInstanceName.c_str(), tn.c_str(), varName, value);
}
else
{
buffer = FormatString("[property]%s#%s %s->%s\n", agentClassName, agentInstanceName.c_str(), varName, value);
}
this->Output(pAgent, buffer.c_str());
Socket::SendText(buffer.c_str());
}
}
}
开发者ID:1414648814,项目名称:behaviac,代码行数:55,代码来源:logmanager.cpp
示例6: test_stochastic_distribution_1
void test_stochastic_distribution_1(behaviac::string tree, behaviac::Workspace::EFileFormat format,
int loopCount = STOCHASTIC_SAMPLE_COUNT, int referenceValue = STOCHASTIC_SAMPLE_COUNT / 3, int checkValue = STOCHASTIC_SAMPLE_COUNT / 30)
{
behaviac::Profiler::CreateInstance();
behaviac::Config::SetSocketing(false);
behaviac::Config::SetLogging(false);
//behaviac::Agent::Register<AgentNodeTest>();
registerAllTypes();
AgentNodeTest* myTestAgent = AgentNodeTest::DynamicCast(behaviac::Agent::Create<AgentNodeTest>());
behaviac::Agent::SetIdMask(1);
myTestAgent->SetIdFlag(1);
int predicateValueCount = 0;
myTestAgent->btload(tree.c_str());
myTestAgent->btsetcurrent(tree.c_str());
myTestAgent->resetProperties();
while (loopCount > 0)
{
myTestAgent->resetProperties();
myTestAgent->btexec();
if (myTestAgent->testVar_0 == 0)
{
predicateValueCount++;
}
--loopCount;
}
#if BEHAVIAC_COMPILER_MSVC
int bias = abs(predicateValueCount - referenceValue);
CHECK_LESS(bias, checkValue);
#endif
unregisterAllTypes();
BEHAVIAC_DELETE(myTestAgent);
//behaviac::Agent::UnRegister<AgentNodeTest>();
behaviac::Profiler::DestroyInstance();
}
开发者ID:Evilcoolkings,项目名称:behaviac,代码行数:42,代码来源:NodeUnitTest.cpp
示例7: AutoProfileBlockSend
/// Construct. begin a profiling block with the specified name and optional call count.
AutoProfileBlockSend(Profiler* profiler, const behaviac::string& taskClassid, const Agent* agent) : profiler_(profiler)
{
if (Config::IsProfiling())
{
profiler_ = profiler;
if (profiler_)
{
profiler_->BeginBlock(taskClassid.c_str(), agent);
}
}
}
开发者ID:xfw5,项目名称:behaviac,代码行数:13,代码来源:behaviortree_task.cpp
示例8: IsArrayString
//it returns true if 'str' starts with a count followed by ':'
//3:{....}
bool IsArrayString(const behaviac::string& str, int posStart, behaviac::string::size_type& posEnd)
{
//begin of the count of an array?
//int posStartOld = posStart;
bool bIsDigit = false;
int strLen = (int)str.size();
while (posStart < strLen)
{
char c = str[posStart++];
if (isdigit(c))
{
bIsDigit = true;
}
else if (c == ':' && bIsDigit)
{
//transit_points = 3:{coordX = 0; coordY = 0; } | {coordX = 0; coordY = 0; } | {coordX = 0; coordY = 0; };
//skip array item which is possible a struct
int depth = 0;
for (int posStart2 = posStart; posStart2 < strLen; posStart2++)
{
char c1 = str[posStart2];
if (c1 == ';' && depth == 0)
{
//the last ';'
posEnd = posStart2;
break;
}
else if (c1 == '{')
{
BEHAVIAC_ASSERT(depth < 10);
depth++;
}
else if (c1 == '}')
{
BEHAVIAC_ASSERT(depth > 0);
depth--;
}
}
return true;
}
else
{
break;
}
}
return false;
}
开发者ID:Evilcoolkings,项目名称:behaviac,代码行数:55,代码来源:tagobject.cpp
示例9: test_stochastic_distribution_2
//< Selector Probability Tests
void test_stochastic_distribution_2(behaviac::string tree, behaviac::Workspace::EFileFormat format, int refs[3])
{
behaviac::Profiler::CreateInstance();
behaviac::Config::SetSocketing(false);
behaviac::Config::SetLogging(false);
//behaviac::Agent::Register<AgentNodeTest>();
registerAllTypes();
AgentNodeTest* myTestAgent = AgentNodeTest::DynamicCast(behaviac::Agent::Create<AgentNodeTest>());
behaviac::Agent::SetIdMask(1);
myTestAgent->SetIdFlag(1);
myTestAgent->btload(tree.c_str());
myTestAgent->btsetcurrent(tree.c_str());
myTestAgent->resetProperties();
int counts[3] = { 0, 0, 0 };
int loopCount = 10000;
while (loopCount > 0)
{
myTestAgent->btexec();
++(counts[myTestAgent->testVar_0]);
--loopCount;
}
for (int i = 0; i < 3; ++i)
{
int k = counts[i];
int bias = abs(k - refs[i]);
CHECK_LESS(bias, 1000);
}
unregisterAllTypes();
BEHAVIAC_DELETE(myTestAgent);
//behaviac::Agent::UnRegister<AgentNodeTest>();
behaviac::Profiler::DestroyInstance();
}
开发者ID:Evilcoolkings,项目名称:behaviac,代码行数:39,代码来源:NodeUnitTest.cpp
示例10: ReadText
bool ConnectorInterface::ReadText(behaviac::string& text)
{
if (this->IsConnected())
{
ScopedLock lock(ms_cs);
text = this->ms_texts;
this->ms_texts.clear();
return !text.empty();
}
return false;
}
开发者ID:AdamHyl,项目名称:behaviac,代码行数:14,代码来源:socketconnect_base.cpp
示例11: BEHAVIAC_UNUSED_VAR
void Planner::LogPlanNodeEnd(Agent* a, BehaviorNode* n, const behaviac::string& result)
{
BEHAVIAC_UNUSED_VAR(a);
BEHAVIAC_UNUSED_VAR(n);
BEHAVIAC_UNUSED_VAR(result);
#if !BEHAVIAC_RELEASE
if (Config::IsLoggingOrSocketing())
{
behaviac::string ni = BehaviorTask::GetTickInfo(a, n, NULL);
LogManager::GetInstance()->Log("[plan_node_end]%s %s\n", ni.c_str(), result.c_str());
}
#endif
}
开发者ID:Evilcoolkings,项目名称:behaviac,代码行数:16,代码来源:planner.cpp
示例12: MakeXmlNodeStruct
XmlNodeRef MakeXmlNodeStruct(const char* str, const behaviac::string& typeNameT)
{
behaviac::string src = str;
//{color=0;id=;type={bLive=false;name=0;weight=0;};}
//the first char is '{'
//the last char is '}'
behaviac::string::size_type posCloseBrackets = behaviac::StringUtils::Private::SkipPairedBrackets(src);
BEHAVIAC_ASSERT(posCloseBrackets != behaviac::string::npos);
bool bIsStructMember = false;
XmlNodeRef xmlNode = CreateXmlNode(typeNameT.c_str());
//{color=0;id=;type={bLive=false;name=0;weight=0;};}
//{color=0;id=;type={bLive=false;name=0;weight=0;};transit_points=3:{coordX=0;coordY=0;}|{coordX=0;coordY=0;}|{coordX=0;coordY=0;};}
behaviac::string::size_type posBegin = 1;
behaviac::string::size_type posEnd = src.find_first_of(';', posBegin);
while (posEnd != behaviac::string::npos)
{
BEHAVIAC_ASSERT(src[posEnd] == ';');
//the last one might be empty
if (posEnd > posBegin)
{
behaviac::string::size_type posEqual = src.find_first_of('=', posBegin);
BEHAVIAC_ASSERT(posEqual > posBegin);
size_t length = posEqual - posBegin;
behaviac::string memmberName = src.substr(posBegin, length);
behaviac::string memmberValue;
char c = src[posEqual + 1];
if (c != '{')
{
//to check if it is an array
if (IsArrayString(src, posEqual + 1, posEnd))
{
length = posEnd - posEqual - 1;
memmberValue = src.substr(posEqual + 1, length);
}
else
{
length = posEnd - posEqual - 1;
memmberValue = src.substr(posEqual + 1, length);
}
}
else
{
bIsStructMember = true;
const char* pStructBegin = src.c_str();
pStructBegin += posEqual + 1;
const char* posCloseBrackets_ = behaviac::StringUtils::Private::SkipPairedBrackets(pStructBegin);
length = posCloseBrackets_ - pStructBegin + 1;
memmberValue = src.substr(posEqual + 1, length);
posEnd = posEqual + 1 + length;
}
if (bIsStructMember)
{
XmlNodeRef memberNode = MakeXmlNodeStruct(memmberValue.c_str(), memmberName);
xmlNode->addChild(memberNode);
}
else
{
//behaviac::string memmberNameFull = typeNameT + "::" + memmberName;
//xmlNode->setAttr(memmberNameFull.c_str(), memmberValue.c_str());
xmlNode->setAttr(memmberName.c_str(), memmberValue.c_str());
}
}
bIsStructMember = false;
//skip ';'
posBegin = posEnd + 1;
//{color=0;id=;type={bLive=false;name=0;weight=0;};transit_points=3:{coordX=0;coordY=0;}|{coordX=0;coordY=0;}|{coordX=0;coordY=0;};}
posEnd = src.find_first_of(';', posBegin);
if (posEnd > posCloseBrackets)
{
break;
}
}
return xmlNode;
}
开发者ID:Evilcoolkings,项目名称:behaviac,代码行数:91,代码来源:tagobject.cpp
注:本文中的behaviac::string类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论