Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1766 for code/branches/core3


Ignore:
Timestamp:
Sep 11, 2008, 12:25:11 AM (16 years ago)
Author:
rgrieder
Message:

test files, no real content.

Location:
code/branches/core3/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core3/src/orxonox/Orxonox.cc

    r1658 r1766  
    7777#include "Settings.h"
    7878
     79#define TestConv(nr, Type1, var1, Type2, res) \
     80    Type1 var##nr##1##var1; \
     81    Type2 var##nr##2; \
     82    assert(ConvertValue(&var##nr##2, var##nr##1)); \
     83    COUT(0) << "Converting " << #var1 << " (" << #Type1 << ") to " << var##nr##2 << " (" #Type2 << ")." << std::endl; \
     84    assert(res == var##nr##2)
     85
     86template <>
     87struct ConverterExplicit<orxonox::Radian, const char*>
     88{
     89    static bool convert(orxonox::Radian* output, const char* input)
     90    {
     91        float temp;
     92        convertValue(&temp, input);
     93        *output = temp;
     94    }
     95};
     96
    7997
    8098// FIXME: is this really file scope?
     
    189207#endif
    190208    Factory::createClassHierarchy();
     209
     210    Radian nmbr;
     211    float res;
     212    //const char* nmbr;
     213    //const char* str;
     214    convertValue(&res, nmbr);
     215    //const unsigned int blah = 4;
     216    //convertValue(nmbr, blah);
     217    //convertValue(&str, 4.0f);
     218
     219
     220    using ::operator<<;
     221    using std::string;
     222    int a = 3;
     223    Radian asdf;
     224    COUT(3) << asdf;
     225
     226    TestConv(1, int, (3), float, 3.0);
     227    TestConv(2, int, (3), string, "3");
     228    TestConv(3, string, ("3.0"), float, 3.0f);
     229    TestConv(4, char, ('a'), string, "a");
     230    TestConv(5, string, ("df"), char, 'd');
     231    TestConv(6, Vector2, (3,4), string, "3,4");
     232    TestConv(7, const char*, ("4.3"), float, 4.3f);
     233    TestConv(8, const char*, ("4,3"), Vector2, Vector2(4,3));
     234    TestConv(9, const char*, ("4.4"), Radian, Radian(4.4));
     235    TestConv(100, int, (3), const char*, "3");
     236    TestConv(101, Vector3, (1, 2, 3), float, 3.0);
     237
     238    std::ostringstream out;
    191239
    192240    std::string mode;
  • code/branches/core3/src/orxonox/Orxonox.h

    r1563 r1766  
    3535#ifndef _Orxonox_H__
    3636#define _Orxonox_H__
     37inline bool explicitConversion(float* output, const double input)
     38{
     39    *output = 2*input;
     40    return true;
     41}
    3742
    3843#include "OrxonoxPrereqs.h"
  • code/branches/core3/src/orxonox/OrxonoxStableHeaders.h

    r1721 r1766  
    3535#define _OrxonoxStableHeaders_H__
    3636
    37 #include "util/OrxonoxPlatform.h"
     37#include "OrxonoxPrereqs.h"
    3838
    3939#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
  • code/branches/core3/src/util/ArgReader.cc

    r1535 r1766  
    3434#include "ArgReader.h"
    3535#include "SubString.h"
     36#include <ostream>
     37#include <iostream>
     38
     39class FooBar
     40{
     41    //friend class ArgReader;
     42public:
     43    operator long long() const
     44    {
     45        return 0;
     46    }
     47    float float_;
     48    static FooBar& createFooBar();
     49private:
     50    //FooBar();
     51    //FooBar(const FooBar& instance);
     52    //~FooBar();
     53};
     54
     55inline std::ostream& operator<<(std::ostream& outstream, const FooBar& fb)
     56{
     57    return outstream << fb.float_;
     58}
     59inline std::istream& operator>>(std::istream& instream,  const FooBar& fb);
     60//inline bool explicitConversion(const char** output, const FooBar input)
     61//{
     62//    return true;
     63//}
     64
     65#include "Convert.h"
     66
     67template<>
     68struct ConverterExplicit<const char*, FooBar>
     69{
     70    static bool convert(const char** output, const FooBar input)
     71    {
     72        return true;
     73    }
     74};
     75
     76#include "MultiType.h"
    3677
    3778ArgReader::ArgReader(int argc, char **argv)
     
    4081  errorString_ = "";
    4182  CmdLineArg arg;
     83
     84  int a = ImplicitConversion<FooBar, const char*>::exists;
     85  int val1;
     86  long long val2 = conversion_cast<long long>(val1);
     87  //val2 = val1;
     88  //convertValue(&val2, val1);
     89  //explicitConversion(&FooBar(), val1);
     90
     91  //using namespace1::fooBar1;
     92  //fooBar1();
     93  //int val1;
     94  //char val2;
     95  //explicitConversion(&val1, val2);
     96
     97  std::istringstream asdf;
     98  //asdf >> val2;
    4299
    43100  int i = 1;
  • code/branches/core3/src/util/Convert.h

    r1754 r1766  
    483483///////////////////////////////////////
    484484
    485 // delegate conversion from const char* via std::string
     485// delegate conversion from const char* to std::string
    486486template <class ToType>
    487487struct ConverterExplicit<ToType, const char*>
    488488{
    489     // convert from const char* via std::string
    490489    static bool convert(ToType* output, const char* input)
    491490    {
    492         return conversion::ConverterSS<ToType, std::string, 0>::convert(output, input);
     491        return ConverterExplicit<ToType, std::string>::convert(output, input);
    493492    }
    494493};
     
    499498    static bool convert(std::string* output, const char input)
    500499    {
    501         *output = std::string(input, 1);
     500        *output = std::string(1, input);
    502501        return true;
    503502    }
     
    507506    static bool convert(std::string* output, const unsigned char input)
    508507    {
    509         *output = std::string(input, 1);
     508        *output = std::string(1, input);
    510509        return true;
    511510    }
  • code/branches/core3/src/util/Math.cc

    r1746 r1766  
    2727 */
    2828
     29#include "Math.h"
     30
    2931#include <OgrePlane.h>
    30 
    31 #include "Math.h"
    3232#include "Convert.h"
    3333
  • code/branches/core3/src/util/Math.h

    r1745 r1766  
    5555}
    5656
    57 _UtilExport std::ostream& operator<<(std::ostream& out, const orxonox::Radian& radian);
     57_UtilExport std::ostream& operator<<(std::ostream& out, const Ogre::Radian& radian);
    5858_UtilExport std::istream& operator>>(std::istream& in, orxonox::Radian& radian);
    5959_UtilExport std::ostream& operator<<(std::ostream& out, const orxonox::Degree& degree);
     
    128128    return false;
    129129}
     130
     131//// ColourValue to std::string
     132//inline bool explicitConversion(std::string* output, const orxonox::ColourValue& input)
     133//{
     134//    std::ostringstream ostream;
     135//    if (ostream << input.r << "," << input.g << "," << input.b << "," << input.a)
     136//    {
     137//        (*output) = ostream.str();
     138//        return true;
     139//    }
     140//    return false;
     141//}
    130142
    131143// std::string to Vector2
  • code/branches/core3/src/util/OutputHandler.h

    r1725 r1766  
    201201    }
    202202}
     203//template<class T>
     204//orxonox::OutputHandler& operator<<(orxonox::OutputHandler& out, const T& output)
     205//{
     206//    if (orxonox::OutputHandler::getSoftDebugLevel(orxonox::OutputHandler::LD_Console) >= out.getOutputLevel())
     207//        std::cout << output;
     208//
     209//    if (orxonox::OutputHandler::getSoftDebugLevel(orxonox::OutputHandler::LD_Logfile) >= out.getOutputLevel())
     210//    {
     211//        out.getLogfile() << output;
     212//        out.getLogfile().flush();
     213//    }
     214//
     215//    if (orxonox::OutputHandler::getSoftDebugLevel(orxonox::OutputHandler::LD_Shell) >= out.getOutputLevel())
     216//        (*out.getOutputBuffer()) << output;
     217//
     218//    return out;
     219//}
    203220
    204221#endif /* _OutputHandler_H__ */
Note: See TracChangeset for help on using the changeset viewer.