Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/external/ogreceguirenderer/OgreCEGUIResourceProvider.cpp @ 9382

Last change on this file since 9382 was 8367, checked in by rgrieder, 14 years ago

by Adi: Fix for GCC 4.6. The actual problem is in CEGUIString.h, but we cannot really fix that ;)

  • Property svn:eol-style set to native
File size: 3.8 KB
Line 
1/************************************************************************
2        filename:       OgreCEGUIResourceProvider.cpp
3        created:        8/7/2004
4        author:         James '_mental_' O'Sullivan
5
6        purpose:        Implements the Resource Provider common functionality
7*************************************************************************/
8/*************************************************************************
9    Crazy Eddie's GUI System (http://www.cegui.org.uk)
10    Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
11
12    This library is free software; you can redistribute it and/or
13    modify it under the terms of the GNU Lesser General Public
14    License as published by the Free Software Foundation; either
15    version 2.1 of the License, or (at your option) any later version.
16
17    This library is distributed in the hope that it will be useful,
18    but WITHOUT ANY WARRANTY; without even the implied warranty of
19    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20    Lesser General Public License for more details.
21
22    You should have received a copy of the GNU Lesser General Public
23    License along with this library; if not, write to the Free Software
24    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25*************************************************************************/
26
27// Workaround for GCC 4.6
28#include <cstddef>
29
30#include "OgreCEGUIResourceProvider.h"
31
32#include <CEGUIExceptions.h>
33#include <OgreArchiveManager.h>
34
35
36// Start of CEGUI namespace section
37namespace CEGUI
38{
39    OgreCEGUIResourceProvider::OgreCEGUIResourceProvider() : ResourceProvider()
40    {
41        // set deafult resource group for Ogre
42        d_defaultResourceGroup = Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME.c_str();
43    }
44
45//    void OgreResourceProvider::loadInputSourceContainer(const String& filename, InputSourceContainer& output)
46//   {
47//        Ogre::DataStreamPtr input = Ogre::ResourceGroupManager::getSingleton().openResource(filename.c_str());
48//
49//              if (input.isNull())
50//              {
51//                      throw InvalidRequestException((utf8*)
52//                              "Scheme::Scheme - Filename supplied for Scheme loading must be valid");
53//              }
54//
55//       XERCES_CPP_NAMESPACE_USE
56//        size_t buffsz = input->size();
57//        unsigned char* mem = reinterpret_cast<unsigned char*>(XMLPlatformUtils::fgArrayMemoryManager->allocate(buffsz));
58//        memcpy(mem, input.getPointer()->getAsString().c_str(), buffsz);
59//        InputSource* mInputSource = new MemBufInputSource(mem, buffsz, filename.c_str(), true);
60//        input.setNull();
61//
62//       output.setData(mInputSource);
63//    }
64
65    void OgreCEGUIResourceProvider::loadRawDataContainer(const String& filename, RawDataContainer& output,  const String& resourceGroup)
66    {
67        String orpGroup;
68        if (resourceGroup.empty())
69            orpGroup = d_defaultResourceGroup.empty() ? Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME.c_str() : d_defaultResourceGroup;
70        else
71            orpGroup = resourceGroup;
72
73        Ogre::DataStreamPtr input =
74            Ogre::ResourceGroupManager::getSingleton().openResource(filename.c_str(), orpGroup.c_str());
75
76                if (input.isNull())
77                {
78            throw InvalidRequestException((utf8*)
79                "OgreCEGUIResourceProvider::loadRawDataContainer - Unable to open resource file '" + filename + (utf8*)"' in resource group '" + orpGroup + (utf8*)"'.");
80        }
81
82                Ogre::String buf = input->getAsString();
83                const size_t memBuffSize = buf.length();
84
85        unsigned char* mem = new unsigned char[memBuffSize];
86        memcpy(mem, buf.c_str(), memBuffSize);
87
88        output.setData(mem);
89        output.setSize(memBuffSize);
90    }
91
92        void OgreCEGUIResourceProvider::unloadRawDataContainer(RawDataContainer& data)
93        {
94                if (data.getDataPtr())
95                {
96                        delete[] data.getDataPtr();
97                        data.setData(0);
98                        data.setSize(0);
99                }
100        }
101} // End of  CEGUI namespace section
Note: See TracBrowser for help on using the repository browser.