C:/irrlicht/IrrLib/IrrLibBase.cpp

Go to the documentation of this file.
00001 /*
00002     Irrlicht Library Wrapper
00003     Created by:
00004         Nathan Adams
00005         Denzel Morris
00006     Copyright (C) 2007
00007 
00008     This software is licensed under the GNU/GPL.
00009     This software may not be used for commerical purposes.
00010 */
00011 
00012 #include <iostream>
00013 #include <irrlicht.h>
00014 #include "IrrLibBase.h"
00015 #include <strings.h>
00016 #include <sstream>
00017 
00018 using namespace irr;
00019 using namespace core;
00020 using namespace scene;
00021 using namespace video;
00022 using namespace io;
00023 using namespace gui;
00024 
00025 using namespace std;
00026 
00027 /*
00028 * Code from http://articles.techrepublic.com.com/5100-22-5079969.html#
00029 *
00030 
00031 struct str_stream
00032 {
00033     std::stringstream & underlying_stream() const
00034     { return m_streamOut; }
00035 
00036     operator std::string() const
00037     {
00038         return m_streamOut.str();
00039     }
00040 private:
00041     mutable std::stringstream m_streamOut;
00042 };
00043 
00044 template< class type>
00045 inline const str_stream & operator<< ( const str_stream & out, const type & value)
00046 {
00047     out.underlying_stream() << value;
00048     return out;
00049 
00050 }
00051 
00052 template<class type> std::string to_string( const type & value)
00053 {
00054     std::ostringstream streamOut;
00055 
00056     streamOut << value;
00057 
00058     return streamOut.str();
00059 }
00060 
00061 * End code copy
00062 */
00063 
00064 void IrrLibBase::SetDriver(IVideoDriver* driver) //can be overloaded
00065 {
00066         this->driver = driver;
00067 }
00068 
00069 void IrrLibBase::SetSmgr(ISceneManager* smgr)
00070 {
00071         this->smgr = smgr;
00072 }
00073 
00074 std::string IrrLibBase::wchar_to_stdstring (const wchar_t* wc)
00075 {
00076     //cout << "Starting conversion";
00077     //wcstombs(tmp, in, 255);
00078     char c[255];
00079     for(int t = 0; wc[t] != '\0'; t++)
00080         c[t] = (char)wc[t];
00081 
00082     /*for(int t = 0; c[t] != '\0'; t++)
00083         wc[t] = c[t];*/
00084 
00085     std::stringstream ss;
00086         ss << c;
00087         //cout << "Conversion OK";
00088         return ss.str();
00089 }
00090 
00091 std::string IrrLibBase::int_to_string (int t)
00092 {
00093         std::stringstream ss;
00094         ss << t;
00095         return ss.str();
00096 }
00097 
00098 std::string IrrLibBase::stringw_to_stdstring(irr::core::stringw sw)
00099 {
00100     std::stringstream ss;
00101         ss << sw.c_str();
00102         return ss.str();
00103 }
00104 irr::core::stringw IrrLibBase::stdstring_to_stringw(std::string ss)
00105 {
00106         stringw tmpw(ss.c_str());
00107         return tmpw;
00108 }
00109 
00110 void IrrLibBase::SetDevice(irr::IrrlichtDevice *device)
00111 {
00112         this->device = device;
00113 }
00114 
00115 void IrrLibBase::init()
00116 {
00117 
00118 }
00119 
00120 /*irr::core::stringw int_to_stringw(int t)
00121 {
00122         std::stringstream ss;
00123         ss << t;
00124         //stringw ret(ss.str());
00125         return ret;
00126 }*/

Generated on Thu Dec 27 18:25:19 2007 for IrrLib by  doxygen 1.5.4