本文整理汇总了C++中BString::split方法的典型用法代码示例。如果您正苦于以下问题:C++ BString::split方法的具体用法?C++ BString::split怎么用?C++ BString::split使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BString
的用法示例。
在下文中一共展示了BString::split方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleRequestDraftslotsBatch
bool CraftingManager::HandleRequestDraftslotsBatch(Object* object,Object* target,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
PlayerObject* playerObject = dynamic_cast<PlayerObject*>(object);
BString requestStr;
BStringVector dataElements;
uint16 elementCount;
message->getStringUnicode16(requestStr);
requestStr.convert(BSTRType_ANSI);
elementCount = requestStr.split(dataElements,' ');
if(!elementCount)
{
return false;
}
for(uint16 i = 1; i < elementCount; i += 2)
{
// since we currently store everything in 1 schematic object, just look up by the crc
// lookup of weights is done in requestresourceweightsbatch
uint64 itemId = boost::lexical_cast<uint64>(dataElements[i].getAnsi());
DraftSchematic* schematic = gSchematicManager->getSchematicBySlotId(static_cast<uint32>(itemId));
if(schematic)
{
gMessageLib->sendDraftslotsResponse(schematic,playerObject);
}
}
return true;
}
示例2: HandleRequestResourceWeightsBatch
bool CraftingManager::HandleRequestResourceWeightsBatch(Object* object,Object* target,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
PlayerObject* playerObject = dynamic_cast<PlayerObject*>(object);
BString requestStr;
BStringVector dataElements;
uint16 elementCount;
message->getStringUnicode16(requestStr);
requestStr.convert(BSTRType_ANSI);
elementCount = requestStr.split(dataElements,' ');
if(!elementCount)
{
return false;
}
for(uint16 i = 0; i < elementCount; i++)
{
uint64 itemId = boost::lexical_cast<uint64>(dataElements[i].getAnsi());
DraftSchematic* schematic = gSchematicManager->getSchematicByWeightId(static_cast<uint32>(itemId));
if(schematic)
{
gMessageLib->sendDraftWeightsResponse(schematic,playerObject);
}
}
return true;
}
示例3: _handleRequestWaypointAtPosition
void ObjectController::_handleRequestWaypointAtPosition(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
PlayerObject* player = dynamic_cast<PlayerObject*>(mObject);
Datapad* datapad = player->getDataPad();
//if(!datapad->getCapacity())
//{
// gMessageLib->sendSystemMessage(player,L"","base_player","too_many_waypoints");
// return;
//}
BStringVector dataElements;
BString dataStr;
std::string nameStr;
message->getStringUnicode16(dataStr);
// Have to convert BEFORE using split, since the conversion done there is removed It will assert().. evil grin...
// Either do the conversion HERE, or better fix the split so it handles unicoe also.
dataStr.convert(BSTRType_ANSI);
uint32 elementCount = dataStr.split(dataElements,' ');
if(elementCount < 5)
{
if(elementCount < 4)
{
return;
}
else
{
nameStr = gWorldManager->getPlanetNameThis();
std::transform(nameStr.begin(), nameStr.end(), nameStr.begin(), &tolower);
}
}
else
{
for(uint i = 4; i < elementCount; i++)
{
nameStr.append(dataElements[i].getAnsi());
if(i + 1 < elementCount)
nameStr.append(" ");
}
}
BString planetStr = dataElements[0].getAnsi();
//gLogger->log(LogManager::DEBUG,"ObjController::handleCreateWaypointAtPosition: planet %s",planetStr.getAnsi());
float x = static_cast<float>(atof(dataElements[1].getAnsi()));
float y = static_cast<float>(atof(dataElements[2].getAnsi()));
float z = static_cast<float>(atof(dataElements[3].getAnsi()));
int32 planetId = gWorldManager->getPlanetIdByName(planetStr);
if(planetId == -1)
{
return;
}
datapad->requestNewWaypoint(nameStr.c_str(), glm::vec3(x,y,z),static_cast<uint16>(planetId),Waypoint_blue);
}
示例4: _processSearchKnowledgeBaseMessage
void CSRManager::_processSearchKnowledgeBaseMessage(Message *message, DispatchClient* client)
{
BString search;
message->getStringUnicode16(search);
search.convert(BSTRType_ANSI);
BStringVector splitstring;
search.split(splitstring, ' ');
BStringVector::iterator iter = splitstring.begin();
BString sql = "%";
while (iter != splitstring.end())
{
int8 cleanSearchString[4000];
mDatabase->Escape_String(cleanSearchString, (*iter).getAnsi(), (*iter).getLength());
sql << cleanSearchString;
sql << "%";
++iter;
}
CSRAsyncContainer* asynccontainer = new CSRAsyncContainer(CSRQuery_SearchKB);
asynccontainer->mClient = client;
mDatabase->ExecuteProcedureAsync(this, asynccontainer, "CALL sp_CSRKnowledgeBaseArticleFind ('%s');", sql.getAnsi());
}
示例5: _handleGetAttributesBatch
void ObjectController::_handleGetAttributesBatch(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
PlayerObject* playerObject = dynamic_cast<PlayerObject*>(mObject);
BString requestStr;
BStringVector dataElements;
BStringVector dataElements2;
uint16 elementCount;
message->getStringUnicode16(requestStr);
requestStr.convert(BSTRType_ANSI);
requestStr.getRawData()[requestStr.getLength()] = 0;
elementCount = requestStr.split(dataElements,' ');
if(!elementCount)
{
return;
}
Message* newMessage;
for(uint16 i = 0; i < elementCount; i++)
{
uint64 itemId = boost::lexical_cast<uint64>(dataElements[i].getAnsi());
Object* object = gWorldManager->getObjectById(itemId);
if(object == NULL)
{
// could be a resource
Resource* resource = gResourceManager->getResourceById(itemId);
if(resource != NULL)
{
resource->sendAttributes(playerObject);
continue;
}
//could be a schematic!
Datapad* datapad = playerObject->getDataPad();
ManufacturingSchematic* schem = datapad->getManufacturingSchematicById(itemId);
if(schem != NULL)
{
schem->sendAttributes(playerObject);
continue;
}
MissionObject* mission = datapad->getMissionById(itemId);
if(mission != NULL)
{
mission->sendAttributes(playerObject);
continue;
}
IntangibleObject* data = datapad->getDataById(itemId);
if(data != NULL)
{
data->sendAttributes(playerObject);
continue;
}
// TODO: check our datapad items
if(playerObject->isConnected())
{
// default reply for schematics
gMessageFactory->StartMessage();
gMessageFactory->addUint32(opAttributeListMessage);
gMessageFactory->addUint64(itemId);
gMessageFactory->addUint32(0);
//gMessageFactory->addUint16(0);
//gMessageFactory->addUint32(40);
newMessage = gMessageFactory->EndMessage();
(playerObject->getClient())->SendChannelAUnreliable(newMessage, playerObject->getAccountId(), CR_Client, 8);
}
//finally, when we are crafting this could be the new item, not yet added to the worldmanager??
if(playerObject->getCraftingSession())
{
if(playerObject->getCraftingSession()->getItem()&&playerObject->getCraftingSession()->getItem()->getId() == itemId)
{
playerObject->getCraftingSession()->getItem()->sendAttributes(playerObject);
}
}
}
else
{
// Tutorial: I (Eru) have to do some hacks here, since I don't know how to get the info of what object the client has selected (by single click) in the Inventory.
if (gWorldConfig->isTutorial())
{
// Let's see if the actual object is the food item "Melon" in our inventory.
if (dynamic_cast<Inventory*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory))->getId() == object->getParentId())
{
//uint64 id = object->getId();
// Is it an Item?
Item* item = dynamic_cast<Item*>(object);
//.........这里部分代码省略.........
示例6: _handlePurchaseTicket
void ObjectController::_handlePurchaseTicket(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
PlayerObject* playerObject = dynamic_cast<PlayerObject*>(mObject);
BString dataStr;
BStringVector dataElements;
uint16 elements;
float purchaseRange = gWorldConfig->getConfiguration<float>("Player_TicketTerminalAccess_Distance",(float)10.0);
if(playerObject->states.getPosture() == CreaturePosture_SkillAnimating)
{
gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "wrong_state"), playerObject);
return;
}
//however we are able to use the purchaseticket command in starports
//without having to use a ticketvendor by just giving commandline parameters
//when we are *near* a ticket vendor
TravelTerminal* terminal = dynamic_cast<TravelTerminal*> (gWorldManager->getNearestTerminal(playerObject,TanType_TravelTerminal));
// iterate through the results
if((!terminal)|| (glm::distance(terminal->mPosition, playerObject->mPosition) > purchaseRange))
{
gMessageLib->SendSystemMessage(::common::OutOfBand("travel", "too_far"), playerObject);
return;
}
playerObject->setTravelPoint(terminal);
message->getStringUnicode16(dataStr);
// Have to convert BEFORE using split, since the conversion done there is removed It will assert().. evil grin...
// Either do the conversion HERE, or better fix the split so it handles unicoe also.
dataStr.convert(BSTRType_ANSI);
elements = dataStr.split(dataElements,' ');
if(elements < 4)
{
gMessageLib->SendSystemMessage(::common::OutOfBand("travel", "route_not_available"), playerObject);
return;
}
// get price and planet ids
TicketProperties ticketProperties;
gTravelMapHandler->getTicketInformation(dataElements,&ticketProperties);
if(!ticketProperties.dstPoint)
{
gMessageLib->SendSystemMessage(::common::OutOfBand("travel", "route_not_available"), playerObject);
return;
}
uint8 roundTrip = 0;
if(elements > 4)
roundTrip = atoi(dataElements[4].getAnsi());
if(dataElements[4].getCrc() == BString("single").getCrc())
roundTrip = 0;
//how many tickets will it be?
uint32 amount = 1;
if(roundTrip)
amount = 2;
Inventory* inventory = dynamic_cast<Inventory*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory));
Bank* bank = dynamic_cast<Bank*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Bank));
if(!inventory->checkSlots(static_cast<uint8>(amount)))
{
gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "inv_full"), playerObject);
return;
}
if(roundTrip == 1)
{
ticketProperties.price *= 2;
}
// update bank or inventory credits
if(!(inventory->updateCredits(-ticketProperties.price)))
{
if(!(bank->updateCredits(-ticketProperties.price)))
{
//gMessageLib->sendSystemMessage(entertainer,L"","travel","route_not_available");
gUIManager->createNewMessageBox(NULL,"ticketPurchaseFailed","The Galactic Travel Commission","You do not have enough money to complete the ticket purchase.",playerObject);
return;
}
}
if(playerObject->isConnected())
{
gMessageLib->SendSystemMessage(::common::OutOfBand("base_player", "prose_pay_acct_success", "", "", "", "", "money/acct_n", "travelsystem", ticketProperties.price), playerObject);
gObjectFactory->requestNewTravelTicket(inventory,ticketProperties,inventory->getId(),99);
//.........这里部分代码省略.........