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


C++ Attribute::AsWhole方法代码示例

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


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

示例1: ConstructFromXML

    void Entresol::ConstructFromXML(const String& EngineDataPath, const Mezzanine::ArchiveType ArchType, const String& InitializerFile)
    {
        //Add default manager factories
        AddAllEngineDefaultManagerFactories();
        //Set some sane Defaults for some values.
        this->ManualLoopBreak = false;

        // Create Ogre.
        SetupOgre();

        // Load the necessary plugins.
        SubSystemParticleFXPlugin = new Ogre::ParticleFXPlugin();
        Ogre::Root::getSingleton().installPlugin(SubSystemParticleFXPlugin);

        // Set up the data we'll be populating.
        XML::Attribute CurrAttrib;
        String GUIInit, ResourceInit, PluginsInit, LogFileName;
        String PluginExtension, PluginPath;

        // Create or set the resource manager.
        /// @todo This currently forces our default resource manager to be constructed, which isn't in line with our factory/initiailzation design.
        /// This should be addressed somehow.
        if(ResourceManager::SingletonValid())
            { AddManager(ResourceManager::GetSingletonPtr()); }
        else
            { AddManager(new ResourceManager(EngineDataPath, ArchType)); }

        // Open and load the initializer doc.
        ResourceManager* ResourceMan = GetResourceManager();
        /// @todo Replace this stack allocated stream for one initialized from the Resource Manager, after the system is ready.
        Resource::FileStream InitStream(InitializerFile,EngineDataPath);
        XML::Document InitDoc;
        XML::ParseResult DocResult = InitDoc.Load(InitStream);
        if( DocResult.Status != XML::StatusOk )
        {
            StringStream ExceptionStream;
            ExceptionStream << "Failed to parse XML file \"" << InitializerFile << "\".";
            MEZZ_EXCEPTION(Exception::SYNTAX_ERROR_EXCEPTION_XML,ExceptionStream.str());
        }
        XML::Node InitRoot = InitDoc.GetChild("InitializerRoot");
        if( InitRoot.Empty() )
        {
            StringStream ExceptionStream;
            ExceptionStream << "Failed to find expected Root node in \"" << InitializerFile << "\".";
            MEZZ_EXCEPTION(Exception::SYNTAX_ERROR_EXCEPTION_XML,ExceptionStream.str());
        }

        // Get the world settings and set them.
        XML::Node WorldSettings = InitRoot.GetChild("WorldSettings");
        for( XML::NodeIterator SetIt = WorldSettings.begin() ; SetIt != WorldSettings.end() ; ++SetIt )
        {
            String SecName = (*SetIt).Name();
            if( "FrameSettings" == SecName )
            {
                CurrAttrib = (*SetIt).GetAttribute("TargetFrameRate");
                if(CurrAttrib.Empty())
                {
                    CurrAttrib = (*SetIt).GetAttribute("TargetFrameTime");
                    if(!CurrAttrib.Empty())
                        SetTargetFrameTimeMicroseconds(CurrAttrib.AsWhole());
                }else{
                    this->SetTargetFrameRate(CurrAttrib.AsWhole());
                }
            }
            else
            {
                MEZZ_EXCEPTION(Exception::SYNTAX_ERROR_EXCEPTION_XML,String("Unknown WorldSetting ")+SecName);
            }

        }

        SetupLogging(LogFileName);

        // Get the other initializer files we'll be using, since we'll need the plugins initializer.
        XML::Node InitFiles = InitRoot.GetChild("OtherInitializers");
        for( XML::NodeIterator InitIt = InitFiles.begin() ; InitIt != InitFiles.end() ; ++InitIt )
        {
            String InitFileName = (*InitIt).Name();
            if( "PluginInit" == InitFileName )
            {
                CurrAttrib = (*InitIt).GetAttribute("FileName");
                if(!CurrAttrib.Empty())
                    PluginsInit = CurrAttrib.AsString();
            }
            else if( "ResourceInit" == InitFileName )
            {
                CurrAttrib = (*InitIt).GetAttribute("FileName");
                if(!CurrAttrib.Empty())
                    ResourceInit = CurrAttrib.AsString();
            }
            else if( "GUIInit" == InitFileName )
            {
                CurrAttrib = (*InitIt).GetAttribute("FileName");
                if(!CurrAttrib.Empty())
                    GUIInit = CurrAttrib.AsString();
            }
        }

        // Load additional resource groups
        /*if(!ResourceInit.empty())
//.........这里部分代码省略.........
开发者ID:zester,项目名称:Mezzanine,代码行数:101,代码来源:entresol.cpp

示例2: ProtoDeSerializeProperties

        void MultiImageLayer::ProtoDeSerializeProperties(const XML::Node& SelfRoot)
        {
            this->ImageLayer::ProtoDeSerializeProperties(SelfRoot);
            XML::Attribute CurrAttrib;
            XML::Node PropertiesNode = SelfRoot.GetChild( MultiImageLayer::GetSerializableName() + "Properties" );

            if( !PropertiesNode.Empty() ) {
                if(PropertiesNode.GetAttribute("Version").AsInt() == 1) {
                    XML::Node LayerImagesNode = PropertiesNode.GetChild( MultiImageLayer::GetSerializableName() + "Properties" );

                    CurrAttrib = LayerImagesNode.GetAttribute("NumImages");
                    if( !CurrAttrib.Empty() )
                        this->ReserveMultiImageData( CurrAttrib.AsWhole() );

                    /// @todo This loop expects the listed order in the XML to match the order in which they were serialized.  Within PugiXML at least this
                    /// shouldn't be a problem, however if Images start appearing out of order it may be worthwhile to investigate or add some ordering redundancy.
                    ImageDataIterator ImageIt = this->LayerImages.begin();
                    for( XML::NodeIterator ImageNodeIt = LayerImagesNode.begin() ; ImageNodeIt != LayerImagesNode.end() ; ++ImageNodeIt )
                    {
                        String SpriteName, SpriteAtlas;

                        if( ImageIt == this->LayerImages.end() ) {
                            MEZZ_EXCEPTION(ExceptionBase::PARAMETERS_RANGE_EXCEPTION,"Seriailzed value for \"NumImages\" is smaller than number of nodes to deserialize.  Verify serialized XML.");
                        }

                        CurrAttrib = (*ImageNodeIt).GetAttribute("SpriteName");
                        if( !CurrAttrib.Empty() )
                            SpriteName = CurrAttrib.AsString();

                        CurrAttrib = (*ImageNodeIt).GetAttribute("SpriteAtlas");
                        if( !CurrAttrib.Empty() )
                            SpriteAtlas = CurrAttrib.AsString();

                        (*ImageIt).LayerSprite = this->Parent->GetScreen()->GetSprite(SpriteName,SpriteAtlas);

                        XML::Node FillRectNode = (*ImageNodeIt).GetChild("FillRect").GetFirstChild();
                        if( !FillRectNode.Empty() )
                            (*ImageIt).FillRect.ProtoDeSerialize(FillRectNode);

                        XML::Node FillColoursNode = (*ImageNodeIt).GetChild("FillColours");
                        XML::Node TopLeftFillNode = FillColoursNode.GetChild("TopLeft").GetFirstChild();
                        if( !TopLeftFillNode.Empty() )
                            (*ImageIt).FillColours[UI::QC_TopLeft].ProtoDeSerialize(TopLeftFillNode);

                        XML::Node TopRightFillNode = FillColoursNode.GetChild("TopRight").GetFirstChild();
                        if( !TopRightFillNode.Empty() )
                            (*ImageIt).FillColours[UI::QC_TopRight].ProtoDeSerialize(TopRightFillNode);

                        XML::Node BottomLeftFillNode = FillColoursNode.GetChild("BottomLeft").GetFirstChild();
                        if( !BottomLeftFillNode.Empty() )
                            (*ImageIt).FillColours[UI::QC_BottomLeft].ProtoDeSerialize(BottomLeftFillNode);

                        XML::Node BottomRightFillNode = FillColoursNode.GetChild("BottomRight").GetFirstChild();
                        if( !BottomRightFillNode.Empty() )
                            (*ImageIt).FillColours[UI::QC_BottomRight].ProtoDeSerialize(BottomRightFillNode);

                        ++ImageIt;
                    }
                }else{
                    MEZZ_EXCEPTION(ExceptionBase::INVALID_VERSION_EXCEPTION,"Incompatible XML Version for " + (String("MultiImageData") + "Properties") + ": Not Version 1.");
                }
            }else{
                MEZZ_EXCEPTION(ExceptionBase::II_IDENTITY_NOT_FOUND_EXCEPTION,String("MultiImageData") + "Properties" + " was not found in the provided XML node, which was expected.");
            }
        }
开发者ID:,项目名称:,代码行数:65,代码来源:


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