本文整理汇总了C++中serialize函数的典型用法代码示例。如果您正苦于以下问题:C++ serialize函数的具体用法?C++ serialize怎么用?C++ serialize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了serialize函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1:
FoodData& SingleFoodImpl::serialize(FoodData& fdata) const
{
*(fdata.add_singlefoods()) = serialize();
return fdata;
}
开发者ID:tylermchenry,项目名称:nutrition_tracker,代码行数:5,代码来源:single_food_impl.cpp
示例2: 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
示例3: serialize
void serialize(const char *id, varchar<S> &x)
{
serialize(id, serializer::to_varchar_base(x));
}
开发者ID:zussel,项目名称:oos,代码行数:4,代码来源:serializer.hpp
示例4: serialize
void Property::serializeValue(XmlSerializer& s) {
serializeValue_ = true;
serialize(s);
serializeValue_ = false;
}
开发者ID:molsimmsu,项目名称:3mview,代码行数:5,代码来源:property.cpp
示例5: serialize
void org::mpisws::p2p::transport::simpleidentity::InetSocketAddressSerializer::serialize(::java::lang::Object* i, ::rice::p2p::commonapi::rawserialization::OutputBuffer* b)
{
serialize(dynamic_cast< ::java::net::InetSocketAddress* >(i), b);
}
开发者ID:subhash1-0,项目名称:thirstyCrow,代码行数:4,代码来源:InetSocketAddressSerializer.cpp
示例6: serialize
// shortcut
long HashTableX::serialize ( SafeBuf *sb ) {
long nb = serialize ( sb->getBuf() , sb->getAvail() );
// update sb
sb->incrementLength ( nb );
return nb;
}
开发者ID:RevBooyah,项目名称:open-source-search-engine,代码行数:7,代码来源:HashTableX.cpp
示例7: msg
void SystemComponent::sendRoutes(std::string const &routes) {
Buffer<> buf;
messages::RoutesFromServer::MessageSerialization msg(routes);
serialize(buf, msg);
m_getParent().packMessage(buf, routesOut.getMessageType());
}
开发者ID:6DB,项目名称:OSVR-Core,代码行数:6,代码来源:SystemComponent.cpp
示例8: _tmain
//.........这里部分代码省略.........
std::wstring wOutputPath(argv[2]);
CreateDirectory(wOutputPath.c_str(), nullptr);
bool skipEmptyNodes = false;
std::wstring animStackName;
for (int i = 3; i < argc; ++i){
std::wstring warg = argv[i];
if (warg == L"/skipemptynodes") {
skipEmptyNodes = true;
}
else if (warg.find(L"/fps:") == 0){
if (warg == L"/fps:60"){
GlobalSettings::Current().AnimationsTimeMode = FbxTime::EMode::eFrames60;
}
else if (warg == L"/fps:30"){
GlobalSettings::Current().AnimationsTimeMode = FbxTime::EMode::eFrames30;
}
else if (warg == L"/fps:24"){
GlobalSettings::Current().AnimationsTimeMode = FbxTime::EMode::eFrames24;
}
else{
std::wcerr << L"Unrecognized fps parameter" << std::endl;
return -2;
}
}
else if (warg.find(L"/animstack:") == 0) {
animStackName = warg.substr(11);
if (animStackName.size()>0 && animStackName[0] == L'\"') {
animStackName.erase(0, 1);
}
if (animStackName.size() > 0 && animStackName[animStackName.size() - 1] == L'\"') {
animStackName.erase(animStackName.size() - 1, 1);
}
}
}
FbxSceneLoader sceneLoader(wstringToUtf8(wInputPath));
auto animStackCount = sceneLoader.getScene()->GetSrcObjectCount<FbxAnimStack>();
if (animStackName.size() == 0) {
GlobalSettings::Current().AnimStackIndex = 0;
}
else {
for (auto ix = 0; ix < animStackCount; ++ix) {
auto animStack = sceneLoader.getScene()->GetSrcObject<FbxAnimStack>(ix);
if (utf8ToWstring(animStack->GetName()) == animStackName) {
GlobalSettings::Current().AnimStackIndex = ix;
}
}
}
std::wcout << L"Animation stacks : " << std::endl;
for (auto ix = 0; ix < animStackCount; ++ix) {
auto animStack = sceneLoader.getScene()->GetSrcObject<FbxAnimStack>(ix);
if (ix == GlobalSettings::Current().AnimStackIndex) {
std::wcout << L"[X] ";
sceneLoader.getScene()->SetCurrentAnimationStack(animStack);
}
else {
std::wcout << L"[ ] ";
}
std::wcout << utf8ToWstring(animStack->GetName());
auto ts=animStack->GetLocalTimeSpan();
auto start = ts.GetStart();
auto stop = ts.GetStop();
std::wcout << L"(" << start.GetMilliSeconds() << L" - " << stop.GetMilliSeconds() << L")" << std::endl;
}
auto root = sceneLoader.rootNode();
BabylonScene babScene(*root, skipEmptyNodes);
for (auto& mat : babScene.materials()){
exportTexture(mat.ambientTexture, wOutputPath);
exportTexture(mat.diffuseTexture, wOutputPath);
exportTexture(mat.specularTexture, wOutputPath);
exportTexture(mat.emissiveTexture, wOutputPath);
exportTexture(mat.reflectionTexture, wOutputPath);
exportTexture(mat.bumpTexture, wOutputPath);
}
auto json = babScene.toJson();
if (L'\\' != *wOutputPath.crbegin()) {
wOutputPath.append(L"\\");
}
wOutputPath.append(wInputFileName);
auto lastDot = wOutputPath.find_last_of(L'.');
wOutputPath.erase(lastDot);
wOutputPath.append(L".babylon");
DeleteFile(wOutputPath.c_str());
std::ofstream stream(wOutputPath);
json.serialize(stream);
stream.flush();
return 0;
}
开发者ID:injir,项目名称:nodeApp,代码行数:101,代码来源:FbxExporter.cpp
示例9: serialize
std::string ConnectionDescription::toString() const
{
std::ostringstream description;
serialize( description );
return description.str();
}
开发者ID:4Second2None,项目名称:Collage,代码行数:6,代码来源:connectionDescription.cpp
示例10: serialize
void QZebraScopeSerializer::serialize(const AdcBoardReport& data)
{
serialize(data.powerStatus);
serialize(data.fdReport);
serialize(data.tdReport);
}
开发者ID:Quenii,项目名称:adcevm,代码行数:6,代码来源:qzebrascopeserializer.cpp
示例11: serialize
void btRigidBody::serializeSingleObject(class btSerializer* serializer) const
{
btChunk* chunk = serializer->allocate(calculateSerializeBufferSize(),1);
const char* structType = serialize(chunk->m_oldPtr, serializer);
serializer->finalizeChunk(chunk,structType,BT_RIGIDBODY_CODE,(void*)this);
}
开发者ID:g-pechorin,项目名称:bullet2stripped,代码行数:6,代码来源:btRigidBody.cpp
示例12: ofs
void ModelManager::serialize(const std::string& filename)
{
std::ofstream ofs(filename.c_str());
serialize::TextOutArchive textOutArchive(ofs);
serialize(textOutArchive);
}
开发者ID:TrentSterling,项目名称:glr,代码行数:6,代码来源:ModelManager.cpp
示例13: operator
ArchiveType & operator()(T && arg)
{
serialize(std::forward<T> (arg));
return *pointArchive;
}
开发者ID:Panda06,项目名称:yasli,代码行数:5,代码来源:yasli.hpp
示例14: serialize
template<class X> void serialize(std::iostream &fs, serialization_context &context, X *&x)
{
fs << "pointer ";
serialize(fs, context, *x);
}
开发者ID:Bvangoor,项目名称:Be-Tree,代码行数:5,代码来源:swap_space.hpp
示例15: serialize
size_t CNetworkChat::Serialize(unsigned char *buf) const
{
unsigned char *p = buf;
p += serialize(p, this->Text);
return p - buf;
}
开发者ID:Clemenshemmerling,项目名称:Stratagus,代码行数:6,代码来源:net_message.cpp
示例16: do_mysql_comms
static void
do_mysql_comms(int to_server, int from_server)
{
struct sql_request req;
static char *buffer = 0;
static int buflen = 0;
static char *serial;
Timer_ID id;
Var args;
Var result;
set_server_cmdline("(MOO mysql-client slave)");
my_handle = moomysql_open_connection(SQLHOST, SQLUSER, SQLPASS, SQLDB, SQLPORT, 0);
for (;;) {
oklog("MYSQL CHILD: ready to read!\n");
if (robust_read(from_server, &req, sizeof(req)) != sizeof(req))
end_sql();
oklog("MYSQL CHILD read!\n");
if (req.length) {
ensure_buffer(&buffer, &buflen, req.length + 1);
if (robust_read(from_server, buffer, req.length)
!= req.length)
end_sql();
buffer[req.length] = '\0';
oklog("MYSQL CHILD got stuff!\n");
args = deserialize(buffer);
}
id = set_timer(req.timeout, timeout_proc, 0);
if (req.kind == SQLREQ_DO_QUERY) {
oklog("MYSQL CHILD: doing query '%s'\n", args.v.list[1].v.str);
result = moomysql_send_query(my_handle, args.v.list[1].v.str);
oklog("got result: %s\n", value2str(result));
serial = serialize(result);
oklog("MYSQL CHILD: serialized!\n");
req.length = strlen(serial);
oklog("MYSQL CHILD: strlenned!\n");
} else if (req.kind == SQLREQ_GET_ROW) {
result = moomysql_next_row(my_handle);
serial = serialize(result);
req.length = strlen(serial);
} else {
req.kind = SQLREQ_ERROR;
req.length = 0;
}
oklog("MYSQL CHILD: writing..\n");
write(to_server, &req, sizeof(req));
oklog("MYSQL CHILD: wrote req..\n");
if (req.length) {
write(to_server, serial, req.length);
oklog("MYSQL CHILD: wrote serial..\n");
free(serial);
oklog("MYSQL CHILD: freed serial!\n");
}
}
}
开发者ID:Jarvak,项目名称:HellCore,代码行数:68,代码来源:mysql_child.c
示例17: response
string Server::createResponse(Status status, string description){
Response response(status, description);
cout<<"Response: "<<response.toString()<<endl;
return serialize(response);
}
开发者ID:Macielos,项目名称:tin-project,代码行数:5,代码来源:Server.cpp
示例18: serialize
void org::mpisws::p2p::testing::transportlayer::peerreview::MyInetSocketAddress_1::serialize(::java::lang::Object* i, ::rice::p2p::commonapi::rawserialization::OutputBuffer* buf)
{
serialize(dynamic_cast< MyInetSocketAddress* >(i), buf);
}
开发者ID:subhash1-0,项目名称:thirstyCrow,代码行数:4,代码来源:MyInetSocketAddress_1.cpp
示例19: serialize
void PostscriptIO::write (const std::string& fname)
{
// We may need to gather a ParallelMesh to output it, making that
// const qualifier in our constructor a dirty lie
MeshSerializer serialize(const_cast<MeshBase&>(this->mesh()), !_is_parallel_format);
if (libMesh::processor_id() == 0)
{
// Get a constant reference to the mesh.
const MeshBase& mesh = MeshOutput<MeshBase>::mesh();
// Only works in 2D
libmesh_assert_equal_to (mesh.mesh_dimension(), 2);
// Create output file stream.
// _out is now a private member of the class.
_out.open(fname.c_str());
// Make sure it opened correctly
if (!_out.good())
libmesh_file_error(fname.c_str());
// The mesh bounding box gives us info about what the
// Postscript bounding box should be.
MeshTools::BoundingBox bbox = MeshTools::bounding_box(mesh);
// Add a little extra padding to the "true" bounding box so
// that we can still see the boundary
const Real percent_padding = 0.01;
const Real dx=bbox.second(0)-bbox.first(0); libmesh_assert_greater (dx, 0.0);
const Real dy=bbox.second(1)-bbox.first(1); libmesh_assert_greater (dy, 0.0);
const Real x_min = bbox.first(0) - percent_padding*dx;
const Real y_min = bbox.first(1) - percent_padding*dy;
const Real x_max = bbox.second(0) + percent_padding*dx;
const Real y_max = bbox.second(1) + percent_padding*dy;
// Width of the output as given in postscript units.
// This usually is given by the strange unit 1/72 inch.
// A width of 300 represents a size of roughly 10 cm.
const Real width = 300;
_scale = width / (x_max-x_min);
_offset(0) = x_min;
_offset(1) = y_min;
// Header writing stuff stolen from Deal.II
std::time_t time1= std::time (0);
std::tm *time = std::localtime(&time1);
_out << "%!PS-Adobe-2.0 EPSF-1.2" << '\n'
//<< "%!PS-Adobe-1.0" << '\n' // Lars' PS version
<< "%%Filename: " << fname << '\n'
<< "%%Title: LibMesh Output" << '\n'
<< "%%Creator: LibMesh: A C++ finite element library" << '\n'
<< "%%Creation Date: "
<< time->tm_year+1900 << "/"
<< time->tm_mon+1 << "/"
<< time->tm_mday << " - "
<< time->tm_hour << ":"
<< std::setw(2) << time->tm_min << ":"
<< std::setw(2) << time->tm_sec << '\n'
<< "%%BoundingBox: "
// lower left corner
<< "0 0 "
// upper right corner
<< static_cast<unsigned int>( rint((x_max-x_min) * _scale ))
<< ' '
<< static_cast<unsigned int>( rint((y_max-y_min) * _scale ))
<< '\n';
// define some abbreviations to keep
// the output small:
// m=move turtle to
// l=define a line
// s=set rgb color
// sg=set gray value
// lx=close the line and plot the line
// lf=close the line and fill the interior
_out << "/m {moveto} bind def" << '\n'
<< "/l {lineto} bind def" << '\n'
<< "/s {setrgbcolor} bind def" << '\n'
<< "/sg {setgray} bind def" << '\n'
<< "/cs {curveto stroke} bind def" << '\n'
<< "/lx {lineto closepath stroke} bind def" << '\n'
<< "/lf {lineto closepath fill} bind def" << '\n';
_out << "%%EndProlog" << '\n';
// << '\n';
// Set line width in the postscript file.
_out << line_width << " setlinewidth" << '\n';
// Set line cap and join options
_out << "1 setlinecap" << '\n';
_out << "1 setlinejoin" << '\n';
// allow only five digits for output (instead of the default
// six); this should suffice even for fine grids, but reduces
// the file size significantly
_out << std::setprecision (5);
//.........这里部分代码省略.........
开发者ID:paulovieira,项目名称:libmesh,代码行数:101,代码来源:postscript_io.C
示例20: switch
// Public functions
Variant WidgetSaver::serialize(WidgetVirtual* w, std::map<std::string, WidgetVirtual*>& association, int& unknownIndex)
{
Variant rootVariant; rootVariant.createMap();
// write type
switch (w->type)
{
case WidgetVirtual::VIRTUAL: rootVariant.insert("type", Variant("VIRTUAL")); break;
case WidgetVirtual::BOARD: rootVariant.insert("type", Variant("BOARD")); break;
case WidgetVirtual::IMAGE: rootVariant.insert("type", Variant("IMAGE")); break;
case WidgetVirtual::LABEL: rootVariant.insert("type", Variant("LABEL")); break;
case WidgetVirtual::CONSOLE: rootVariant.insert("type", Variant("CONSOLE")); break;
case WidgetVirtual::RADIO_BUTTON: rootVariant.insert("type", Variant("RADIO_BUTTON"));break;
default: rootVariant.insert("type", Variant("UNKNOWN")); break;
}
// write configuration
rootVariant.insert("config", Variant((int)w->configuration));
// write sizes
if (w->sizes[WidgetVirtual::DEFAULT] == w->sizes[WidgetVirtual::HOVER] && w->sizes[WidgetVirtual::DEFAULT] == w->sizes[WidgetVirtual::ACTIVE] && w->sizes[WidgetVirtual::DEFAULT] == w->sizes[WidgetVirtual::CURRENT])
rootVariant.insert("sizeAll", ToolBox::getFromVec2(w->sizes[WidgetVirtual::DEFAULT]));
else
{
rootVariant.insert("sizeDefault", ToolBox::getFromVec2(w->sizes[WidgetVirtual::DEFAULT]));
rootVariant.insert("sizeHover", ToolBox::getFromVec2(w->sizes[WidgetVirtual::HOVER]));
rootVariant.insert("sizeActive", ToolBox::getFromVec2(w->sizes[WidgetVirtual::ACTIVE]));
rootVariant.insert("sizeCurrent", ToolBox::getFromVec2(w->sizes[WidgetVirtual::CURRENT]));
}
// write positions
if (w->positions[WidgetVirtual::DEFAULT] == w->positions[WidgetVirtual::HOVER] && w->positions[WidgetVirtual::DEFAULT] == w->positions[WidgetVirtual::ACTIVE] && w->positions[WidgetVirtual::DEFAULT] == w->positions[WidgetVirtual::CURRENT])
rootVariant.insert("positionAll", ToolBox::getFromVec3(w->positions[WidgetVirtual::DEFAULT]));
else
{
rootVariant.insert("positionDefault", ToolBox::getFromVec3(w->positions[WidgetVirtual::DEFAULT]));
rootVariant.insert("positionHover", ToolBox::getFromVec3(w->positions[WidgetVirtual::HOVER]));
rootVariant.insert("positionActive", ToolBox::getFromVec3(w->positions[WidgetVirtual::ACTIVE]));
rootVariant.insert("positionCurrent", ToolBox::getFromVec3(w->positions[WidgetVirtual::CURRENT]));
}
// write colors
if (w->colors[WidgetVirtual::DEFAULT] == w->colors[WidgetVirtual::HOVER] && w->colors[WidgetVirtual::DEFAULT] == w->colors[WidgetVirtual::ACTIVE] && w->colors[WidgetVirtual::DEFAULT] == w->colors[WidgetVirtual::CURRENT])
rootVariant.insert("colorAll", ToolBox::getFromVec4(w->colors[WidgetVirtual::DEFAULT]));
else
{
rootVariant.insert("colorDefault", ToolBox::getFromVec4(w->colors[WidgetVirtual::DEFAULT]));
rootVariant.insert("colorHover", ToolBox::getFromVec4(w->colors[WidgetVirtual::HOVER]));
rootVariant.insert("colorActive", ToolBox::getFromVec4(w->colors[WidgetVirtual::ACTIVE]));
rootVariant.insert("colorCurrent", ToolBox::getFromVec4(w->colors[WidgetVirtual::CURRENT]));
}
// write shader and texture name
if (w->shader && w->shader->name != "defaultWidget")
rootVariant.insert("shader", Variant(w->shader->name));
if (w->texture)
rootVariant.insert("texture", Variant(w->texture->name));
// derivate type
switch (w->type)
{
case WidgetVirtual::BOARD:
serializeBoard(static_cast<WidgetBoard*>(w), rootVariant);
break;
case WidgetVirtual::IMAGE:
serializeImage(static_cast<WidgetImage*>(w), rootVariant);
break;
case WidgetVirtual::LABEL:
serializeLabel(static_cast<WidgetLabel*>(w), rootVariant);
break;
case WidgetVirtual::CONSOLE:
serializeConsole(static_cast<WidgetConsole*>(w), rootVariant);
break;
case WidgetVirtual::RADIO_BUTTON:
serializeRadioButton(static_cast<WidgetRadioButton*>(w), rootVariant);
break;
default: break;
}
// children
if (!w->children.empty())
{
rootVariant.insert("children", Variant::MapType());
for (unsigned int i = 0; i < w->children.size(); ++i)
{
std::string name = "unknown_" + std::to_string(++unknownIndex);
for (std::map<std::string, WidgetVirtual*>::iterator it = association.begin(); it != association.end(); ++it)
{
if (w->children[i] == it->second)
{
name = it->first;
break;
}
}
Variant child = serialize(w->children[i], association, unknownIndex);
rootVariant.getMap()["children"].insert(name, child);
}
}
//.........这里部分代码省略.........
开发者ID:a-laine,项目名称:GolemFactory,代码行数:101,代码来源:WidgetSaver.cpp
注:本文中的serialize函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论