本文整理汇总了C++中deserialize函数的典型用法代码示例。如果您正苦于以下问题:C++ deserialize函数的具体用法?C++ deserialize怎么用?C++ deserialize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了deserialize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: deserialize
/**
* Wątek obsługujący pojedynczą wiadomość przesłaną do serwera.
*/
void Server::handleMessage(tcp::socket* socket){
boost::array<char, 8192> messageBuffer;
boost::system::error_code error;
ioService.run();
socket->read_some(boost::asio::buffer(messageBuffer), error);
if (error){
cerr<<error<<endl;
socket->close();
delete socket;
return;
}
Message message;
deserialize(message, messageBuffer.data());
cout<<"Otrzymano wiadomość: "<<endl;
cout<<message.toString()<<endl;
int result;
string response;
string sessionId;
History emptyHistory;
vector<string> mismatchingParameters;
History* history;
if(message.getAction()!=REGISTER
&& message.getAction()!=LOGIN
&& message.getAction()!=UNREGISTER
&& (serverStore.getSessionId(message.getUserId())!=message.getSessionId()
|| serverStore.getSessionId(message.getUserId())==""))
{
response = createResponse(NOT_LOGGED_IN);
socket->write_some(boost::asio::buffer(response), error);
socket->close();
delete socket;
return;
}
switch(message.getAction()){
case REGISTER:
{
// muszą być dwa parametry
if (message.getParameters().size() != 2)
{
response = createResponse(WRONG_SYNTAX);
socket->write_some(boost::asio::buffer(response), error);
}
else
{
// tworzymy użyszkodnika
result = serverStore.registerUser(message.getParameters()[0], message.getParameters()[1]);
switch (result)
{
case 0: // użytkownik dodany poprawnie
response = createResponse(OK);
break;
case -1: // login zajęty
response = createResponse(INCORRECT_LOGIN);
break;
}
socket->write_some(boost::asio::buffer(response), error);
}
break;
}
case LOGIN:
{
// muszą być dwa parametry
if (message.getParameters().size() != 2)
{
response = createResponse(WRONG_SYNTAX, "", &emptyHistory);
socket->write_some(boost::asio::buffer(response), error);
}
else
{
// logowanie użyszkodnika
result = serverStore.loginUser(message.getParameters()[0], message.getParameters()[1]);
switch (result)
{
case 0: // użytkownik zalogowany poprawnie
history = serverStore.getHistory(message.getUserId());
if(history==NULL){
history = &emptyHistory;
}
sessionId = generateSessionId();
serverStore.setSessionId(message.getUserId(), sessionId);
response = createResponse(OK, sessionId, history);
serverStore.clearHistory(message.getUserId());
break;
case -1: // niepoprawny login
response = createResponse(INCORRECT_LOGIN, "", &emptyHistory);
break;
case -2: // niepoprawne haslo
response = createResponse(INCORRECT_PASSWORD, "", &emptyHistory);
break;
}
socket->write_some(boost::asio::buffer(response), error);
}
//.........这里部分代码省略.........
示例2: deserialize
LineSegment::LineSegment(class BinaryInput& b) {
deserialize(b);
}
示例3: deserialize
ClusterState::ClusterState(const ClusterState& other) {
vespalib::nbostream o;
other.serialize(o);
deserialize(o);
}
示例4: deserialize
void PrimitiveDeserializer::deserialize(GAFStream* in, cocos2d::Rect* out)
{
deserialize(in, &out->origin);
deserialize(in, &out->size);
}
示例5: deserialize
bool deserialize(const std::string& filename, value_type& value) {
JsonReader reader;
JsonNode root = reader.Parse(filename.c_str());
return deserialize(root, value);
}
示例6: shutdown
// -----------------------------------------------------------------------------
bool DeviceManager::initialize()
{
GamepadConfig *gamepadConfig = NULL;
GamePadDevice *gamepadDevice = NULL;
m_map_fire_to_select = false;
bool created = false;
// Shutdown in case the device manager is being re-initialized
shutdown();
if(UserConfigParams::logMisc())
{
Log::info("Device manager","Initializing Device Manager");
Log::info("-","---------------------------");
}
deserialize();
// Assign a configuration to the keyboard, or create one if we haven't yet
if(UserConfigParams::logMisc()) Log::info("Device manager","Initializing keyboard support.");
if (m_keyboard_configs.size() == 0)
{
if(UserConfigParams::logMisc())
Log::info("Device manager","No keyboard configuration exists, creating one.");
m_keyboard_configs.push_back(new KeyboardConfig());
created = true;
}
const int keyboard_amount = m_keyboard_configs.size();
for (int n=0; n<keyboard_amount; n++)
{
m_keyboards.push_back(new KeyboardDevice(m_keyboard_configs.get(n)));
}
if(UserConfigParams::logMisc())
Log::info("Device manager","Initializing gamepad support.");
irr_driver->getDevice()->activateJoysticks(m_irrlicht_gamepads);
int num_gamepads = m_irrlicht_gamepads.size();
if(UserConfigParams::logMisc())
{
Log::info("Device manager","Irrlicht reports %d gamepads are attached to the system.",
num_gamepads);
}
// Create GamePadDevice for each physical gamepad and find a GamepadConfig to match
for (int id = 0; id < num_gamepads; id++)
{
core::stringc name = m_irrlicht_gamepads[id].Name;
// Some linux systems report a disk accelerometer as a gamepad, skip that
if (name.find("LIS3LV02DL") != -1) continue;
#ifdef WIN32
// On Windows, unless we use DirectInput, all gamepads are given the
// same name ('microsoft pc-joystick driver'). This makes configuration
// totally useless, so append an ID to the name. We can't test for the
// name, since the name is even translated.
name = name + " " + StringUtils::toString(id).c_str();
#endif
if (UserConfigParams::logMisc())
{
Log::info("Device manager","#%d: %s detected...", id, name.c_str());
}
// Returns true if new configuration was created
if (getConfigForGamepad(id, name, &gamepadConfig) == true)
{
if(UserConfigParams::logMisc())
Log::info("Device manager","creating new configuration.");
created = true;
}
else
{
if(UserConfigParams::logMisc())
Log::info("Device manager","using existing configuration.");
}
gamepadConfig->setPlugged();
gamepadDevice = new GamePadDevice(id,
name.c_str(),
m_irrlicht_gamepads[id].Axes,
m_irrlicht_gamepads[id].Buttons,
gamepadConfig );
addGamepad(gamepadDevice);
} // end for
if (created) serialize();
return created;
} // initialize
示例7: from_json
inline void
from_json (const nlohmann::json& j, object& o)
{
JSON_VALIDATE_REQUIRED(j, id, is_number);
JSON_VALIDATE_REQUIRED(j, name, is_string);
JSON_VALIDATE_REQUIRED(j, type, is_string);
JSON_VALIDATE_REQUIRED(j, x, is_number);
JSON_VALIDATE_REQUIRED(j, y, is_number);
JSON_VALIDATE_REQUIRED(j, width, is_number);
JSON_VALIDATE_REQUIRED(j, height, is_number);
JSON_VALIDATE_REQUIRED(j, visible, is_boolean);
JSON_VALIDATE_REQUIRED(j, rotation, is_number_float);
JSON_VALIDATE_OPTIONAL(j, properties, is_object);
JSON_VALIDATE_OPTIONAL(j, propertytypes, is_object);
JSON_VALIDATE_OPTIONAL(j, gid, is_number);
JSON_VALIDATE_OPTIONAL(j, point, is_boolean);
JSON_VALIDATE_OPTIONAL(j, ellipse, is_boolean);
JSON_VALIDATE_OPTIONAL(j, polygon, is_array);
JSON_VALIDATE_OPTIONAL(j, polyline, is_array);
JSON_VALIDATE_OPTIONAL(j, text, is_string);
o.id = j["id"].get<int32>();
o.name = j["name"].get<std::string>();
o.type = j["type"].get<std::string>();
o.x = j["x"].get<int32>();
o.y = j["y"].get<int32>();
o.width = j["width"].get<int32>();
o.height = j["height"].get<int32>();
o.visible = j["visible"].get<bool>();
o.rotation = j["rotation"].get<float>();
deserialize(j, o.properties);
if (j.count("gid"))
{
o.gid = j["gid"].get<int32>();
if (o.gid <= 0)
{
throw std::invalid_argument("object has invalid gid");
}
o.otype = object_type::sprite;
return;
}
o.otype = object_type::rect;
if (j.count("point") && j["point"].get<bool>())
{
o.otype = object_type::point;
}
if (j.count("ellipse") && j["ellipse"].get<bool>())
{
o.otype = object_type::ellipse;
}
if (j.count("polygon"))
{
o.otype = object_type::polygon;
o.coords = j["polygon"].get<std::vector<coordinate>>();
}
if (j.count("polyline"))
{
o.otype = object_type::polyline;
o.coords = j["polyline"].get<std::vector<coordinate>>();
}
if (j.count("text"))
{
o.otype = object_type::text;
o.text = j["text"].get<object_text>();
}
}
示例8: queryHostIP
void TransferServer::deserializeAction(MemoryBuffer & msg, unsigned action)
{
SocketEndpoint ep;
ep.deserialize(msg);
if (!ep.isLocal())
{
StringBuffer host, expected;
queryHostIP().getIpText(host);
ep.getIpText(expected);
throwError2(DFTERR_WrongComputer, expected.str(), host.str());
}
srcFormat.deserialize(msg);
tgtFormat.deserialize(msg);
msg.read(calcInputCRC);
msg.read(calcOutputCRC);
deserialize(partition, msg);
msg.read(numParallelSlaves);
msg.read(updateFrequency);
msg.read(replicate);
msg.read(mirror);
msg.read(isSafeMode);
srand((unsigned)get_cycles_now());
int adjust = (rand() * rand() * rand()) % updateFrequency - (updateFrequency/2);
lastTick = msTick() + adjust;
StringBuffer localFilename;
if (action == FTactionpull)
{
partition.item(0).outputName.getPath(localFilename);
LOG(MCdebugProgress, unknownJob, "Process Pull Command: %s", localFilename.str());
}
else
{
partition.item(0).inputName.getPath(localFilename);
LOG(MCdebugProgress, unknownJob, "Process Push Command: %s", localFilename.str());
}
LOG(MCdebugProgress, unknownJob, "Num Parallel Slaves=%d Adjust=%d/%d", numParallelSlaves, adjust, updateFrequency);
LOG(MCdebugProgress, unknownJob, "replicate(%d) mirror(%d) safe(%d) incrc(%d) outcrc(%d)", replicate, mirror, isSafeMode, calcInputCRC, calcOutputCRC);
displayPartition(partition);
unsigned numProgress;
msg.read(numProgress);
for (unsigned i = 0; i < numProgress; i++)
{
OutputProgress & next = *new OutputProgress;
next.deserialize(msg);
progress.append(next);
}
if (msg.remaining())
msg.read(throttleNicSpeed);
if (msg.remaining())
msg.read(compressedInput).read(compressOutput);
if (msg.remaining())
msg.read(copyCompressed);
if (msg.remaining())
msg.read(transferBufferSize);
if (msg.remaining())
msg.read(encryptKey).read(decryptKey);
if (msg.remaining())
{
srcFormat.deserializeExtra(msg, 1);
tgtFormat.deserializeExtra(msg, 1);
}
LOG(MCdebugProgress, unknownJob, "throttle(%d), transferBufferSize(%d)", throttleNicSpeed, transferBufferSize);
PROGLOG("compressedInput(%d), compressedOutput(%d), copyCompressed(%d)", compressedInput?1:0, compressOutput?1:0, copyCompressed?1:0);
PROGLOG("encrypt(%d), decrypt(%d)", encryptKey.isEmpty()?0:1, decryptKey.isEmpty()?0:1);
//---Finished deserializing ---
displayProgress(progress);
totalLengthRead = 0;
totalLengthToRead = 0;
ForEachItemIn(idx, partition)
totalLengthToRead += partition.item(idx).inputLength;
}
示例9: deserialize
void Property::deserializeValue(XmlDeserializer& s) {
serializeValue_ = true;
deserialize(s);
serializeValue_ = false;
}
示例10: deserialize
void CInitMessage_Map::Deserialize(const unsigned char *p)
{
p += header.Deserialize(p);
p += deserialize(p, this->MapPath);
p += deserialize32(p, &this->MapUID);
}
示例11: TEST
TEST(DictionaryDeserialization, EmptyDictionary) {
deserialize(AmfDictionary(false, false), v8 { 0x11, 0x01, 0x00 });
deserialize(AmfDictionary(false, true), v8 { 0x11, 0x01, 0x01 });
deserialize(AmfDictionary(false, true), v8 { 0x11, 0x01, 0x01, 0x01 }, 1);
}
示例12: deserialize
Box::Box(class BinaryInput& b) {
deserialize(b);
}
示例13: deserialize
NestedInteger deserialize(string s)
{
return deserialize(s, 0, s.length() - 1);
}
示例14: deserialize
Vector4::Vector4(BinaryInput& b) {
deserialize(b);
}
示例15: deserialize
/*
* Deserialisierungs-Konstruktor von @p LobbyPlayerInfo.
*
* @author FloSoft
*/
LobbyPlayerInfo::LobbyPlayerInfo(const unsigned playerid, Serializer* ser)
{
deserialize(ser);
}