std::unique_ptr<IObject> deserializeSimpleScrollableAreaSkin(Deserializer& deserializer) { DESERIALIZE(std::shared_ptr<IRelativeBox>, box); DESERIALIZE(bool, horScrollBarEnabled); DESERIALIZE(bool, vertScrollBarEnabled); DESERIALIZE(float, scrollBarWidth); DESERIALIZE(float, scrollStep); DESERIALIZE(GLColor, backgroundColor); DESERIALIZE(float, borderWidth); DESERIALIZE(GLColor, borderColor); DESERIALIZE(bool, useGradient); DESERIALIZE(GLColor, fillColor); DESERIALIZE(float, arrowPadding); DESERIALIZE(GLColor, arrowColor); std::unique_ptr<SimpleScrollableAreaSkin> result(new SimpleScrollableAreaSkin(box)); result->setScrollBarEnabled(Direction::Horizontal, horScrollBarEnabled); result->setScrollBarEnabled(Direction::Vertical, vertScrollBarEnabled); result->setScrollBarWidth(scrollBarWidth); result->setScrollStep(scrollStep); result->setBackgroundColor(backgroundColor); result->setBorderWidth(borderWidth); result->setBorderColor(borderColor); result->setUseGradient(useGradient); result->setFillColor(fillColor); result->setArrowPadding(arrowPadding); result->setArrowColor(arrowColor); return std::move(result); }
std::unique_ptr<IObject> deserializeAnimatedButtonSkin(Deserializer& deserializer) { DESERIALIZE(std::shared_ptr<IRelativeBox>, box); DESERIALIZE(std::shared_ptr<IRelativeGeometry>, geometry); std::unique_ptr<AnimatedButtonSkin> result(new AnimatedButtonSkin(box, geometry)); deserializeAnimatedObjectElements(deserializer, result.get()); return std::move(result); }
std::unique_ptr<IObject> deserializeColorComponentChange(Deserializer& deserializer) { DESERIALIZE(std::string, objName); DESERIALIZE(ColorComponent::Type, colorComponentType); ColorType::Enum colorType = ColorType::Inline; if (deserializer.hasMember("colorType")) { deserializer >> "colorType" >> colorType; }
std::unique_ptr<IObject> deserializeIncrementalChange(Deserializer& deserializer) { DESERIALIZE(std::string, propertyName); DESERIALIZE(T, delta); DESERIALIZE(Time, period); DESERIALIZE(ChangeFunc::Type, changeFunc); return std::unique_ptr<IncrementalChange<T>>(new IncrementalChange<T>( propertyName, delta, period, changeFunc)); }
std::unique_ptr<IObject> deserializeAngleChange(Deserializer& deserializer) { DESERIALIZE(std::string, objName); DESERIALIZE(float, angle); DESERIALIZE(Time, period); DESERIALIZE(ChangeFunc::Type, changeFunc); DESERIALIZE(bool, relativeRotation); return std::make_unique<AngleChange>( objName, angle, period, changeFunc, relativeRotation); }
std::unique_ptr<IObject> deserializeBackgrounded(Deserializer& deserializer) { DESERIALIZE(std::shared_ptr<IRelativeOffset>, position); DESERIALIZE(std::shared_ptr<IObject>, obj); DESERIALIZE(std::shared_ptr<IObject>, background); std::unique_ptr<Backgrounded> result(new Backgrounded(position)); result->setMainObject(obj); result->setBackground(background); return std::move(result); }
std::unique_ptr<IObject> deserializeButton(Deserializer& deserializer) { DESERIALIZE(std::shared_ptr<IRelativeOffset>, position); DESERIALIZE(std::shared_ptr<ButtonSkin>, skin); auto result = std::make_unique<Button>(skin, position); if (deserializer.hasMember("toolTip")) { DESERIALIZE(std::shared_ptr<ToolTip>, toolTip); result->setToolTip(toolTip); } return result; }
std::unique_ptr<IObject> deserializeScaleChange(Deserializer& deserializer) { DESERIALIZE(std::string, objName); DESERIALIZE(ScaleChange::Type, scalingType); DESERIALIZE(float, scale); DESERIALIZE(Time, period); DESERIALIZE(ChangeFunc::Type, changeFunc); DESERIALIZE(bool, relativeScaling); return std::make_unique<ScaleChange>( objName, scalingType, scale, period, changeFunc, relativeScaling); }
std::unique_ptr<IObject> deserializeAnimatedTextBoxSkin(Deserializer& deserializer) { DESERIALIZE(std::shared_ptr<IRelativeBox>, box); DESERIALIZE(std::shared_ptr<EditableLabel>, label); DESERIALIZE(std::shared_ptr<TextBoxCursor>, cursor); DESERIALIZE(std::shared_ptr<IRelativeGeometry>, geometry); DESERIALIZE_OPT(Time, shiftPeriod, 0); std::unique_ptr<AnimatedTextBoxSkin> result(new AnimatedTextBoxSkin(box, label, cursor, geometry)); result->setShiftPeriod(shiftPeriod); deserializeAnimatedObjectElements(deserializer, result.get()); return std::move(result); }
std::unique_ptr<IObject> deserializeLinearLayout(Deserializer& deserializer) { DESERIALIZE(std::shared_ptr<IRelativeOffset>, position); DESERIALIZE(std::shared_ptr<LinearLayoutSkin>, skin); DESERIALIZE(std::vector<std::shared_ptr<IObject>>, list); std::unique_ptr<LinearLayout> result(new LinearLayout(skin, position)); for (auto it = list.begin(); it != list.end(); ++it) result->addObject(*it); if (deserializer.hasMember("skipInvisibleElements")) { DESERIALIZE(bool, skipInvisibleElements); result->setSkipInvisibleElements(skipInvisibleElements); } return std::move(result); }
int main( void ) { // Setup an object MyObject obj; obj.id = "An identifier!"; obj.rotation = 0.1234f; obj.x = 5; obj.y = 10; // Dump contents of our object SERIALIZE( MyObject, obj, stdout ); // Get some space so that we can place a string in here obj.id = (string)malloc( sizeof( char ) * 100 ); getchar( ); { FILE *fp = fopen( "SerializedMyObject.txt", "r" ); printf( "Deserializing from SerializedMyObject.txt:\n" ); printf( "Press enter to deserialize...\n" ); getchar( ); DESERIALIZE( MyObject, obj, fp ); SERIALIZE( MyObject, obj, stdout ); } getchar( ); free( obj.id ); return 0; }
std::unique_ptr<IObject> deserializeAdvancedMove(Deserializer& deserializer) { DESERIALIZE(std::string, objName); DESERIALIZE(Coord::Type, coordType); DESERIALIZE(float, pixelCoord); DESERIALIZE(float, parentWidthRelativeCoord); DESERIALIZE(float, parentHeightRelativeCoord); DESERIALIZE(float, selfWidthRelativeCoord); DESERIALIZE(float, selfHeightRelativeCoord); DESERIALIZE(Time, period); DESERIALIZE(ChangeFunc::Type, changeFunc); DESERIALIZE(bool, relativeMove); return std::make_unique<AdvancedMove>( objName, coordType, pixelCoord, parentWidthRelativeCoord, parentHeightRelativeCoord, selfWidthRelativeCoord, selfHeightRelativeCoord, period, changeFunc, relativeMove); }
std::unique_ptr<IObject> deserializeCustomCheckBoxSkin(Deserializer& deserializer) { DESERIALIZE(std::shared_ptr<IRelativeBox>, box); DESERIALIZE(std::string, backgroundImageName); DESERIALIZE(GLColor, backgroundImageColor); DESERIALIZE(std::string, checkImageName); DESERIALIZE(float, checkImageWidth); DESERIALIZE(float, checkImageHeight); DESERIALIZE(GLColor, checkImageColor); auto result = std::make_unique<CustomCheckBoxSkin>(box); result->setBackgroundImageName(backgroundImageName); result->setBackgroundImageColor(backgroundImageColor); result->setCheckImageName(checkImageName); result->setCheckImageSizes(checkImageWidth, checkImageHeight); result->setCheckImageColor(checkImageColor); return std::move(result); }
std::unique_ptr<IObject> deserializeFramesChange(Deserializer& deserializer) { DESERIALIZE(std::string, atlasName); if (deserializer.hasMember("startFrameIndex")) { // old version DESERIALIZE(int, startFrameIndex); DESERIALIZE(int, lastFrameIndex); DESERIALIZE(Time, period); DESERIALIZE(int, repeatTimes); return std::make_unique<FramesChange>( atlasName, startFrameIndex, lastFrameIndex, period, repeatTimes); } else { // new version DESERIALIZE(std::vector<std::shared_ptr<Frame>>, frames); return std::make_unique<FramesChange>(atlasName, std::move(frames)); } }
std::unique_ptr<IObject> deserializeTransformedPositionElement(Deserializer& deserializer) { DESERIALIZE(Vec2, offset); DESERIALIZE(float, angle); DESERIALIZE(float, scaleX); DESERIALIZE(float, scaleY); return std::unique_ptr<PositionElement>(new PositionElement(scaleX, scaleY, angle, offset)); }
std::unique_ptr<IObject> deserializeCanvasLayout(Deserializer& deserializer) { typedef std::map<int, std::shared_ptr<IObject>> Objects; DESERIALIZE(std::shared_ptr<IRelativeBox>, box); DESERIALIZE(std::shared_ptr<IRelativeOffset>, position); DESERIALIZE_OPT(Adjustment::Enum, adjustment, Adjustment::None); std::unique_ptr<CanvasLayout> result(new CanvasLayout(box, position)); if (deserializer.hasMember("objects")) { DESERIALIZE(Objects, objects); result->insertObjects(objects); } else { DESERIALIZE(std::vector<std::shared_ptr<IObject>>, list); result->addObjects(list); } result->setAdjustment(adjustment); return std::move(result); }
bool TorusDeserializer::DeserializeToFrame(FramePtr frame, const TypeInfo& info, std::ostream& log) { if (info.TypeName != this->TokenName) { log << "[ERROR] " << TypeName << " deserializer passed an object not of type \"" << TokenName << "\". Object type was: \"" << info.TypeName.c_str() << "." << std::endl; return false; } Torus* torus = new Torus; ObjectPtr object = ObjectPtr(torus); bool is_static = true; bool errorbit = false; if (!GetReferenceFrame(torus->RefFrame, info, log)) errorbit = true; else is_static = torus->RefFrame.Velocity == ReferenceFrame::Default.Velocity; if (!GetPosition(torus->InitialPosition, is_static, info, log)) errorbit = true; if (!GetColour(torus->Colour, info, log)) errorbit = true; DESERIALIZE(RingRadius, "ring_radius", torus, info, log, errorbit); DESERIALIZE(Radius, "radius", torus, info, log, errorbit); if (!errorbit) { if (frame->Scene) frame->Scene->AddObject(object); } return !errorbit; }
status_t msg_recv (int fd, msg_t * msg) { mr_rarray_t rarray; memset (&rarray, 0, sizeof (rarray)); status_t status = buf_recv (fd, &rarray.MR_SIZE, sizeof (rarray.MR_SIZE)); if (ST_SUCCESS != status) return (ST_FAILURE); char data[rarray.MR_SIZE]; status = buf_recv (fd, data, rarray.MR_SIZE); if (ST_SUCCESS != status) return (ST_FAILURE); rarray.data.ptr = data; mr_status_t mr_status = DESERIALIZE (msg_t, &rarray, msg); return ((MR_SUCCESS == mr_status) ? ST_SUCCESS : ST_FAILURE); }
std::unique_ptr<IObject> deserializeSmoothChange(Deserializer& deserializer) { DESERIALIZE(std::string, propertyName); DESERIALIZE(T, startValue); DESERIALIZE(T, newValue); Time t; if (deserializer.hasMember("time")) { DESERIALIZE(TypedTime, time); t = time.value; } else { DESERIALIZE(Time, period); t = period; } DESERIALIZE(ChangeFunc::Type, changeFunc); DESERIALIZE(bool, moveToStart); std::unique_ptr<SmoothChange<T>> result(new SmoothChange<T>( propertyName, startValue, newValue, t, changeFunc)); result->setMoveToStart(moveToStart); return std::move(result); }
std::unique_ptr<IObject> deserializeOffsettedPositionElement(Deserializer& deserializer) { DESERIALIZE(Vec2, offset); return std::unique_ptr<PositionElement>(new PositionElement(1, 1, 0, offset)); }
std::unique_ptr<IObject> deserializeInstantShow(Deserializer& deserializer) { DESERIALIZE(std::string, objName); return std::make_unique<InstantShow>(objName); }
size_t ByteBuffer::DeserializeSize_t() { DESERIALIZE(size_t, x); return x; }
std::unique_ptr<IObject> deserializeRepeatingAnimation(Deserializer& deserializer) { DESERIALIZE(int, repeatTimes); DESERIALIZE(std::shared_ptr<IAnimation>, animation); return std::unique_ptr<IObject>(new RepeatingAnimation(repeatTimes, animation)); }
std::unique_ptr<IObject> deserializeRotatedPositionElement(Deserializer& deserializer) { DESERIALIZE(Vec2, offset); DESERIALIZE(float, angle); return std::unique_ptr<PositionElement>(new PositionElement(1, 1, angle, offset)); }
std::unique_ptr<IObject> deserializeParallelAnimation(Deserializer& deserializer) { DESERIALIZE(std::vector<std::shared_ptr<IAnimation>>, animations); return std::unique_ptr<IObject>(new ParallelAnimation(animations)); }
std::unique_ptr<IObject> deserializeInstantChange(Deserializer& deserializer) { DESERIALIZE(std::string, propertyName); DESERIALIZE(T, newValue); return std::unique_ptr<IObject>(new InstantChange<T>(propertyName, newValue)); }
std::unique_ptr<IObject> deserializeActionInAnimation(Deserializer& deserializer) { DESERIALIZE(std::shared_ptr<IAction>, action); return std::unique_ptr<IObject>(new ActionInAnimation(action)); }
time_t ByteBuffer::DeserializeTime_t() { DESERIALIZE(time_t, x); return x; }