本文整理汇总了C++中deserialize函数的典型用法代码示例。如果您正苦于以下问题:C++ deserialize函数的具体用法?C++ deserialize怎么用?C++ deserialize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了deserialize函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
//.........这里部分代码省略.........
开发者ID:Macielos,项目名称:tin-project,代码行数:101,代码来源:Server.cpp
示例2: deserialize
LineSegment::LineSegment(class BinaryInput& b) {
deserialize(b);
}
开发者ID:Jekls,项目名称:PhantomCore,代码行数:3,代码来源:LineSegment.cpp
示例3: deserialize
ClusterState::ClusterState(const ClusterState& other) {
vespalib::nbostream o;
other.serialize(o);
deserialize(o);
}
开发者ID:songhtdo,项目名称:vespa,代码行数:5,代码来源:clusterstate.cpp
示例4: deserialize
void PrimitiveDeserializer::deserialize(GAFStream* in, cocos2d::Rect* out)
{
deserialize(in, &out->origin);
deserialize(in, &out->size);
}
开发者ID:AbelChan,项目名称:Cocos2dxGAFPlayer,代码行数:5,代码来源:PrimitiveDeserializer.cpp
示例5: deserialize
bool deserialize(const std::string& filename, value_type& value) {
JsonReader reader;
JsonNode root = reader.Parse(filename.c_str());
return deserialize(root, value);
}
开发者ID:dtbinh,项目名称:darkmatter,代码行数:5,代码来源:Serializer.hpp
示例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
开发者ID:Berulacks,项目名称:stk-code,代码行数:94,代码来源:device_manager.cpp
示例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>();
}
}
开发者ID:JoshBramlett,项目名称:RDGE,代码行数:76,代码来源:tiled.hpp
示例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;
}
开发者ID:biddyweb,项目名称:HPCC-Platform,代码行数:79,代码来源:fttransform.cpp
示例9: deserialize
void Property::deserializeValue(XmlDeserializer& s) {
serializeValue_ = true;
deserialize(s);
serializeValue_ = false;
}
开发者ID:molsimmsu,项目名称:3mview,代码行数:5,代码来源:property.cpp
示例10: deserialize
void CInitMessage_Map::Deserialize(const unsigned char *p)
{
p += header.Deserialize(p);
p += deserialize(p, this->MapPath);
p += deserialize32(p, &this->MapUID);
}
开发者ID:Clemenshemmerling,项目名称:Stratagus,代码行数:6,代码来源:net_message.cpp
示例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);
}
开发者ID:richieyan,项目名称:amf-cpp,代码行数:5,代码来源:dictionary.cpp
示例12: deserialize
Box::Box(class BinaryInput& b) {
deserialize(b);
}
开发者ID:Gigelf,项目名称:Infinity_Core,代码行数:3,代码来源:Box.cpp
示例13: deserialize
NestedInteger deserialize(string s)
{
return deserialize(s, 0, s.length() - 1);
}
开发者ID:earnestzhao,项目名称:LeetCode,代码行数:4,代码来源:LeetCode_385_Recurse.cpp
示例14: deserialize
Vector4::Vector4(BinaryInput& b) {
deserialize(b);
}
开发者ID:elfprince13,项目名称:G3D10,代码行数:3,代码来源:Vector4.cpp
示例15: deserialize
/*
* Deserialisierungs-Konstruktor von @p LobbyPlayerInfo.
*
* @author FloSoft
*/
LobbyPlayerInfo::LobbyPlayerInfo(const unsigned playerid, Serializer* ser)
{
deserialize(ser);
}
开发者ID:uqs,项目名称:liblobby,代码行数:9,代码来源:LobbyPlayerInfo.cpp
示例16: BITCOIN_ASSERT
block_header_type block_result::header() const
{
BITCOIN_ASSERT(slab_);
return deserialize(slab_);
}
开发者ID:u20024804,项目名称:libbitcoin-blockchain,代码行数:5,代码来源:block_database.cpp
示例17: process_request
STATIC
int process_request(fqueue_element_t *qe_l)
{
int rv;
const char *name;
int name_len;
const char *uri;
int uri_len;
const char *hdrdata;
int hdrdata_len;
const char *nstokendata;
int nstokendata_len;
namespace_token_t nstoken;
const namespace_config_t *nsc = 0;
pseudo_con_t *pcon = 0;
const char *http_flag;
int http_flag_len;
pcon = alloc_pseudo_con_t();
if (!pcon) {
DBG("alloc_pseudo_con_t() failed, rv=%d", rv);
rv = 1;
goto exit;
}
rv = get_attr_fqueue_element(qe_l, T_ATTR_URI, 0, &name, &name_len,
&uri, &uri_len);
if (rv) {
DBG("get_attr_fqueue_element(T_ATTR_URI) failed, rv=%d", rv);
rv = 2;
goto exit;
}
if (uri_len >= (MAX_URI_SIZE - MAX_URI_HDR_SIZE)) {
DBG("uri_len(%d) >= (MAX_URI_SIZE-MAX_URI_HDR_SIZE)(%d)",
uri_len, MAX_URI_SIZE-MAX_URI_HDR_SIZE);
rv = 3;
goto exit;
}
rv = get_nvattr_fqueue_element_by_name(qe_l, "http_header", 11,
&hdrdata, &hdrdata_len);
if (!rv) {
rv = deserialize(hdrdata, hdrdata_len, &pcon->con.con.http.hdr, 0, 0);
if (rv) {
DBG("deserialize() failed, rv=%d", rv);
rv = 4;
goto exit;
}
} else {
DBG("get_nvattr_fqueue_element_by_name() "
"for \"http_header\" failed, rv=%d", rv);
}
nstokendata = 0;
rv = get_nvattr_fqueue_element_by_name(qe_l, "namespace_token", 15,
&nstokendata, &nstokendata_len);
if (nstokendata) {
nstoken.u.token = (uint64_t)atol_len(nstokendata, nstokendata_len);
nsc = namespace_to_config(nstoken);
}
if (!nsc) {
TSTR(uri, uri_len, p_uri);
DBG("Invalid namespace token(gen=%d val=%d) "
"for URI=%s, request dropped",
nstoken.u.token_data.gen, nstoken.u.token_data.val, p_uri);
rv = 5;
goto exit;
}
pcon->con.con.http.ns_token = nstoken;
http_flag = 0;
rv = get_nvattr_fqueue_element_by_name(qe_l, "http_flag", 9,
&http_flag, &http_flag_len);
if (http_flag) {
if (!strncasecmp(http_flag, "FORWARD_PROXY", http_flag_len)) {
pcon->con.con.http.flag |= HRF_FORWARD_PROXY;
} else if (!strncasecmp(http_flag, "VIRTUAL_DOMAIN_REVERSE_PROXY",
http_flag_len)) {
pcon->flags |= PC_FL_VIRTUAL_DOMAIN_REVERSE_PROXY;
} else if (!strncasecmp(http_flag, "TRASPARENT_REVERSE_PROXY",
http_flag_len)) {
pcon->flags |= PC_FL_TRANSPARENT_REVERSE_PROXY;
}
}
rv = start_http_get_task(uri, uri_len, pcon);
if (rv) {
TSTR(uri, uri_len, p_uri);
DBG("send_http_request() failed uri=%s, rv=%d", p_uri, rv);
rv = 6;
goto exit;
}
//.........这里部分代码省略.........
开发者ID:skizhak,项目名称:open-media-flow-controller,代码行数:101,代码来源:get_manager.c
示例18: dump
void item::load_info( const std::string &data )
{
std::istringstream dump(data);
char check=dump.peek();
if ( check == ' ' ) {
// sigh..
check=data[1];
}
if ( check == '{' ) {
JsonIn jsin(dump);
try {
deserialize(jsin);
} catch( const JsonError &jsonerr ) {
debugmsg("Bad item json\n%s", jsonerr.c_str() );
}
return;
}
unset_flags();
clear_vars();
std::string idtmp, ammotmp, item_tag, mode;
int lettmp, damtmp, acttmp, corp, tag_count;
int owned; // Ignoring an obsolete member.
dump >> lettmp >> idtmp >> charges >> damtmp >> tag_count;
for( int i = 0; i < tag_count; ++i )
{
dump >> item_tag;
if( itag2ivar(item_tag, item_vars ) == false ) {
item_tags.insert( item_tag );
}
}
dump >> burnt >> poison >> ammotmp >> owned >> bday >>
mode >> acttmp >> corp >> mission_id >> player_id;
corpse = NULL;
getline(dump, corpse_name);
if( corpse_name == " ''" ) {
corpse_name = "";
} else {
size_t pos = corpse_name.find_first_of( "@@" );
while (pos != std::string::npos) {
corpse_name.replace( pos, 2, "\n" );
pos = corpse_name.find_first_of( "@@" );
}
corpse_name = corpse_name.substr( 2, corpse_name.size() - 3 ); // s/^ '(.*)'$/\1/
}
gun_set_mode( mode );
if( idtmp == "UPS_on" ) {
idtmp = "UPS_off";
} else if( idtmp == "adv_UPS_on" ) {
idtmp = "adv_UPS_off" ;
}
convert( idtmp );
invlet = char(lettmp);
set_damage( damtmp );
active = false;
if (acttmp == 1) {
active = true;
}
}
开发者ID:AlecWhite,项目名称:Cataclysm-DDA,代码行数:62,代码来源:savegame_legacy.cpp
示例19: CertificateOfMembership
CertificateOfMembership(const Buffer<C> &b,unsigned int startAt = 0)
throw(std::out_of_range,std::invalid_argument)
{
deserialize(b,startAt);
}
开发者ID:BrendanBenshoof,项目名称:ZeroTierOne,代码行数:5,代码来源:CertificateOfMembership.hpp
示例20: m_type
Any::Any(TextInput& t) : m_type(NONE), m_data(NULL) {
deserialize(t);
}
开发者ID:lev1976g,项目名称:easywow,代码行数:3,代码来源:Any.cpp
注:本文中的deserialize函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论