当前位置: 首页>>代码示例>>C++>>正文


C++ SerializerElement::ConsiderAsArrayOf方法代码示例

本文整理汇总了C++中SerializerElement::ConsiderAsArrayOf方法的典型用法代码示例。如果您正苦于以下问题:C++ SerializerElement::ConsiderAsArrayOf方法的具体用法?C++ SerializerElement::ConsiderAsArrayOf怎么用?C++ SerializerElement::ConsiderAsArrayOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SerializerElement的用法示例。


在下文中一共展示了SerializerElement::ConsiderAsArrayOf方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: UnserializeFrom

void ObjectGroup::UnserializeFrom(std::vector < gd::ObjectGroup > & list, const SerializerElement & element)
{
    element.ConsiderAsArrayOf("group", "Groupe");
    for (unsigned int i = 0; i < element.GetChildrenCount(); ++i)
    {
        SerializerElement & groupElement = element.GetChild(i);
        gd::ObjectGroup objectGroup;

        objectGroup.SetName(groupElement.GetStringAttribute("name", "", "nom"));

        //Compatibility with GD <= 3.3
        if ( groupElement.HasChild("Objet") )
        {
            for (unsigned int j = 0; j < groupElement.GetChildrenCount("Objet"); ++j)
                objectGroup.AddObject(groupElement.GetChild("Objet", j).GetStringAttribute("nom"));
        }
        //End of compatibility code
        else
        {
            SerializerElement & objectsElement = groupElement.GetChild("objects");
            objectsElement.ConsiderAsArrayOf("object");
            for (unsigned int j = 0; j < objectsElement.GetChildrenCount(); ++j)
                objectGroup.AddObject(objectsElement.GetChild(j).GetStringAttribute("name"));
        }

        list.push_back( objectGroup );
    }
}
开发者ID:cubemoon,项目名称:GD,代码行数:28,代码来源:ObjectGroup.cpp

示例2: SerializeObjectsTo

void ClassWithObjects::SerializeObjectsTo(SerializerElement & element) const
{
    element.ConsiderAsArrayOf("object");
    for ( std::size_t j = 0;j < initialObjects.size();j++ )
    {
        initialObjects[j]->SerializeTo(element.AddChild("object"));
    }

}
开发者ID:alcemirfernandes,项目名称:GD,代码行数:9,代码来源:ClassWithObjects.cpp

示例3: SerializeEventsTo

void EventsListSerialization::SerializeEventsTo(const EventsList & list, SerializerElement & events)
{
    events.ConsiderAsArrayOf("event");
    for ( unsigned int j = 0;j < list.size();j++ )
    {
        const gd::BaseEvent & event = list.GetEvent(j);
        SerializerElement & eventElem = events.AddChild("event");

        eventElem.SetAttribute( "disabled", event.IsDisabled());
        eventElem.SetAttribute( "folded", event.folded);
        eventElem.AddChild("type").SetValue(event.GetType());

        event.SerializeTo(eventElem);
    }
}
开发者ID:bran921007,项目名称:GD,代码行数:15,代码来源:Serialization.cpp

示例4: SerializeTo

void ObjectGroup::SerializeTo(const std::vector < gd::ObjectGroup > & list, SerializerElement & element)
{
    element.ConsiderAsArrayOf("group");
    for ( unsigned int j = 0;j < list.size();j++ )
    {
        SerializerElement & groupElement = element.AddChild("group");

        groupElement.SetAttribute("name", list[j].GetName());

        SerializerElement & objectsElement = groupElement.AddChild("objects");
        objectsElement.ConsiderAsArrayOf("object");
        vector < string > allObjects = list[j].GetAllObjectsNames();
        for ( unsigned int k = 0;k < allObjects.size();k++ )
            objectsElement.AddChild("object").SetAttribute( "name", allObjects[k] );
    }
}
开发者ID:cubemoon,项目名称:GD,代码行数:16,代码来源:ObjectGroup.cpp

示例5: OpenConditions

void gd::EventsListSerialization::OpenConditions(gd::Project & project, gd::InstructionsList & conditions, const SerializerElement & elem)
{
    elem.ConsiderAsArrayOf("condition", "Condition");
    for(std::size_t i = 0; i<elem.GetChildrenCount(); ++i)
    {
        gd::Instruction instruction;
        const SerializerElement & conditionElem = elem.GetChild(i);

        instruction.SetType(conditionElem.GetChild("type", 0, "Type").GetStringAttribute("value")
                .FindAndReplace("Automatism", "Behavior")); //Compatibility with GD <= 4
        instruction.SetInverted(conditionElem.GetChild("type", 0, "Type").GetBoolAttribute("inverted", false, "Contraire"));

        //Read parameters
        vector < gd::Expression > parameters;

        //Compatibility with GD <= 3.3
        if (conditionElem.HasChild("Parametre")) {

            for (std::size_t j = 0;j<conditionElem.GetChildrenCount("Parametre");++j)
                parameters.push_back(gd::Expression(conditionElem.GetChild("Parametre", j).GetValue().GetString()));

        }
        //end of compatibility code
        else
        {
            const SerializerElement & parametersElem = conditionElem.GetChild("parameters");
            parametersElem.ConsiderAsArrayOf("parameter");
            for (std::size_t j = 0;j<parametersElem.GetChildrenCount();++j)
                parameters.push_back(gd::Expression(parametersElem.GetChild(j).GetValue().GetString()));
        }

        instruction.SetParameters( parameters );

        //Read sub conditions
        if ( conditionElem.HasChild("subConditions", "SubConditions") )
            OpenConditions(project, instruction.GetSubInstructions(), conditionElem.GetChild("subConditions", 0, "SubConditions" ));

        conditions.Insert( instruction );
    }

    if ( project.GetLastSaveGDMajorVersion() < 3 ||
         (project.GetLastSaveGDMajorVersion() == 3 && project.GetLastSaveGDMinorVersion() <= 1 ) )
        UpdateInstructionsFromGD31x(project, conditions, false);

    if ( project.GetLastSaveGDMajorVersion() < 3 )
        UpdateInstructionsFromGD2x(project, conditions, false);
}
开发者ID:alcemirfernandes,项目名称:GD,代码行数:47,代码来源:Serialization.cpp

示例6: OpenActions

void gd::EventsListSerialization::OpenActions(gd::Project & project, vector < gd::Instruction > & actions, const SerializerElement & elem)
{
    elem.ConsiderAsArrayOf("action", "Action");
    for(unsigned int i = 0; i<elem.GetChildrenCount(); ++i)
    {
        gd::Instruction instruction;
        const SerializerElement & actionElem = elem.GetChild(i);

        instruction.SetType( actionElem.GetChild("type", 0, "Type").GetStringAttribute("value") );

        //Read parameters
        vector < gd::Expression > parameters;

        //Compatibility with GD <= 3.3
        if (actionElem.HasChild("Parametre")) {

            for (unsigned int j = 0;j<actionElem.GetChildrenCount("Parametre");++j)
                parameters.push_back(gd::Expression(actionElem.GetChild("Parametre", j).GetValue().GetString()));

        }
        //end of compatibility code
        else
        {
            const SerializerElement & parametersElem = actionElem.GetChild("parameters");
            parametersElem.ConsiderAsArrayOf("parameter");
            for (unsigned int j = 0;j<parametersElem.GetChildrenCount();++j)
                parameters.push_back(gd::Expression(parametersElem.GetChild(j).GetValue().GetString()));
        }

        instruction.SetParameters( parameters );

        //Read sub actions
        if ( actionElem.HasChild("subActions", "SubActions") )
            OpenActions(project, instruction.GetSubInstructions(), actionElem.GetChild("subActions", 0, "SubActions" ));

        actions.push_back( instruction );
    }

    if ( project.GetLastSaveGDMajorVersion() < 3 ||
         (project.GetLastSaveGDMajorVersion() == 3 && project.GetLastSaveGDMinorVersion() <= 1 ) )
        UpdateInstructionsFromGD31x(project, actions, true);

    if ( project.GetLastSaveGDMajorVersion() < 3 )
        UpdateInstructionsFromGD2x(project, actions, true);
}
开发者ID:bran921007,项目名称:GD,代码行数:45,代码来源:Serialization.cpp

示例7: SaveConditions

void gd::EventsListSerialization::SaveConditions(const vector < gd::Instruction > & list, SerializerElement & conditions)
{
    conditions.ConsiderAsArrayOf("condition");
    for ( unsigned int k = 0;k < list.size();k++ )
    {
        SerializerElement & condition = conditions.AddChild("condition");
        condition.AddChild("type")
            .SetAttribute("value", list[k].GetType())
            .SetAttribute("inverted", list[k].IsInverted());

        //Parameters
        SerializerElement & parameters = condition.AddChild("parameters");
        parameters.ConsiderAsArrayOf("parameter");
        for ( unsigned int l = 0;l < list[k].GetParameters().size();l++ )
            parameters.AddChild("parameter").SetValue(list[k].GetParameter(l).GetPlainString());

        //Sub instructions
        SerializerElement & subConditions = condition.AddChild("subConditions");
        SaveConditions(list[k].GetSubInstructions(), subConditions);
    }
}
开发者ID:bran921007,项目名称:GD,代码行数:21,代码来源:Serialization.cpp

示例8: UnserializeObjectsFrom

void ClassWithObjects::UnserializeObjectsFrom(gd::Project & project, const SerializerElement & element)
{
    initialObjects.clear();
    element.ConsiderAsArrayOf("object", "Objet");
    for (std::size_t i = 0; i < element.GetChildrenCount(); ++i)
    {
        const SerializerElement & objectElement = element.GetChild(i);

        gd::String type = objectElement.GetStringAttribute("type");
        std::shared_ptr<gd::Object> newObject =
            project.CreateObject(type, objectElement.GetStringAttribute("name", "", "nom"));

        if ( newObject != std::shared_ptr<gd::Object>() )
        {
            newObject->UnserializeFrom(project, objectElement);
            initialObjects.push_back( newObject );
        }
        else
            std::cout << "WARNING: Unknown object type \"" << type << "\"" << std::endl;
    }
}
开发者ID:alcemirfernandes,项目名称:GD,代码行数:21,代码来源:ClassWithObjects.cpp

示例9: SaveActions

void gd::EventsListSerialization::SaveActions(const gd::InstructionsList & list, SerializerElement & actions)
{
    actions.ConsiderAsArrayOf("action");
    for ( std::size_t k = 0;k < list.size();k++ )
    {
        SerializerElement & action = actions.AddChild("action");
        action.AddChild("type")
            .SetAttribute("value", list[k].GetType())
            .SetAttribute("inverted", list[k].IsInverted());

        //Parameters
        SerializerElement & parameters = action.AddChild("parameters");
        parameters.ConsiderAsArrayOf("parameter");
        for ( std::size_t l = 0;l < list[k].GetParameters().size();l++ )
            parameters.AddChild("parameter").SetValue(list[k].GetParameter(l).GetPlainString());

        //Sub instructions
        SerializerElement & subActions = action.AddChild("subActions");
        SaveActions(list[k].GetSubInstructions(), subActions);
    }
}
开发者ID:alcemirfernandes,项目名称:GD,代码行数:21,代码来源:Serialization.cpp

示例10: UnserializeEventsFrom

void EventsListSerialization::UnserializeEventsFrom(gd::Project & project, EventsList & list, const SerializerElement & events)
{
    events.ConsiderAsArrayOf("event", "Event");
    for(unsigned int i = 0; i<events.GetChildrenCount(); ++i)
    {
        SerializerElement & eventElem = events.GetChild(i);
        std::string type = eventElem.GetChild("type", 0, "Type").GetValue().GetString();
        gd::BaseEventSPtr event = project.CreateEvent(type);
        if ( event != std::shared_ptr<gd::BaseEvent>())
            event->UnserializeFrom(project, eventElem);
        else
        {
            std::cout << "WARNING: Unknown event of type " << type << std::endl;
            event = std::shared_ptr<gd::BaseEvent>(new EmptyEvent);
        }

        event->SetDisabled(eventElem.GetBoolAttribute("disabled"));
        event->folded = eventElem.GetBoolAttribute("folded");

        list.InsertEvent(event, list.GetEventsCount());
    }
}
开发者ID:bran921007,项目名称:GD,代码行数:22,代码来源:Serialization.cpp


注:本文中的SerializerElement::ConsiderAsArrayOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。