Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1777 for code


Ignore:
Timestamp:
Sep 14, 2008, 1:03:48 PM (16 years ago)
Author:
rgrieder
Message:

svn save

Location:
code/branches/core3
Files:
1 added
8 edited

Legend:

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

    r1768 r1777  
    3434// Precompiled Headers
    3535#include "OrxonoxStableHeaders.h"
     36#include "util/MathConvert.h"
    3637#include "Orxonox.h"
    3738
     
    7778#include "Settings.h"
    7879
     80
    7981#define TestConv(nr, Type1, var1, Type2, res) \
    8082    Type1 var##nr##1##var1; \
     
    98100
    99101class FooBar { };
     102
     103inline bool explicitConversion(FooBar* output, std::string input)
     104{
     105    return true;
     106}
     107
     108//inline bool explicitConversion(std::string* output, const orxonox::Vector3& input)
     109//{
     110//    std::ostringstream ostream;
     111//    if (ostream << input.x << "," << input.y << "," << input.z)
     112//    {
     113//        (*output) = ostream.str();
     114//        return true;
     115//    }
     116//    return false;
     117//}
     118
    100119
    101120
     
    212231    Factory::createClassHierarchy();
    213232
    214     Radian nmbr;
    215     float res;
     233    std::string nmbr;
     234    char res('a');
    216235    //const char* nmbr;
    217236    //const char* str;
    218     convertValue(&res, nmbr);
     237    convertValue(&nmbr, res);
    219238    //const unsigned int blah = 4;
    220239    //convertValue(nmbr, blah);
     
    226245    FooBar asdf;
    227246    std::string asdf2;
     247    std::ostringstream oss;
     248    char blah(' ');
     249    oss << blah;
    228250    std::cout << asdf2;
    229251    ConvertValue(&asdf2, asdf);
     252    //if (conversionTests::OStreamOperator<FooBar>::exists)
     253    //    int asdfasdfasdf = 7;
    230254    //COUT(3) << asdf;
    231255
  • code/branches/core3/src/orxonox/Orxonox.h

    r1766 r1777  
    3535#ifndef _Orxonox_H__
    3636#define _Orxonox_H__
    37 inline bool explicitConversion(float* output, const double input)
    38 {
    39     *output = 2*input;
    40     return true;
    41 }
    4237
    4338#include "OrxonoxPrereqs.h"
  • code/branches/core3/src/util/ArgReader.cc

    r1768 r1777  
    8484  //std::cout << errorString_;
    8585
    86   int a = conversionTests::ImplicitConversion<FooBar, const char*>::exists;
    87   int val1;
    88   long long val2 = conversion_cast<long long>(val1);
     86  //const int a = conversionTests::ExplicitConversion<FooBar, const char*>::exists;
     87  //BOOST_STATIC_ASSERT(a == 0);
     88  //int val1;
     89  //long long val2 = 4LL;//conversion_cast<long long>(val1);
    8990  //val2 = val1;
    9091  //convertValue(&val2, val1);
     
    9798  //explicitConversion(&val1, val2);
    9899
    99   std::istringstream asdf;
     100  //std::istringstream asdf;
    100101  //asdf >> val2;
    101102
  • code/branches/core3/src/util/Convert.h

    r1768 r1777  
    2323 *      Benjamin Grauer
    2424 *      Fabian 'x3n' Landau
     25 *      Reto Grieder (direct conversion tests)
    2526 *   Co-authors:
    2627 *      ...
     
    2829
    2930/*!
    30     @file Convert.h
     31    @file
    3132    @brief Definition and Implementation of the Convert class.
    3233*/
    3334
    34 #ifndef _Convert_H__
    35 #define _Convert_H__
     35#ifndef _Converter_H__
     36#define _Converter_H__
    3637
    3738#include "UtilPrereqs.h"
     
    3940#include <string>
    4041#include <sstream>
    41 
    42 #include "Math.h"
     42#include <istream>
     43#include <ostream>
     44
    4345#include "Debug.h"
    4446
     
    4648// This is however exactly what convertValue does, so we need to suppress the warnings.
    4749// They only occur in when using the ImplicitConversion template.
    48 #if ORXONOX_COMPILER == ORXONOX_COMPILER_GCC
     50#if ORXONOX_COMPILER == ORXONOX_COMPILER_GNUC
    4951#  pragma GCC system_header
    5052#endif
     
    5355// Static detection for conversion functions //
    5456///////////////////////////////////////////////
    55 
    5657/* The idea to use the sizeof() operator on return functions to determine function existance
    5758   is described in 'Moder C++ design' by Alexandrescu (2001). */
     
    7172}
    7273
    73 namespace separate_namespace
     74namespace conversion_another_namespace
    7475{
    7576    // We want to keep the templates for the convert functions out of global namespace so that there
    7677    // are no ambiguities. These templates are never used anyway, they only serve to detect whether
    7778    // there is a global funciton for a specific conversion or not.
    78     // Now why not putting this in namespace 'conversionTests'?
    79     // I can not tell for sure, but I think there is a bug in msvc 8. It chooses this general template
    80     // (if it was in 'conversionTests') over a better fitting function in global namespace.
    81     // The solution is to use another namespace and then apply the 'using' directive in 'conversionTests'.
    82     // Unfortunately there is a (somewhat documented) bug in msvc 8 that exposes namespace members
    83     // globally when applying the 'using' directive in a namespace. And it so happens that the bug is
    84     // triggered in this file. This unwanted global exposure hopefully doesn't cause ambiguities.
    85     template <class AnyToType, class AnyFromType>
    86     conversionTests::VeryBigStruct explicitConversion(AnyToType* output, const AnyFromType input)
    87     {
    88         // We have to make sure noboy uses it , so a good compiler error would be nice.
    89         *output = (AnyToType)input; // Do not use this function!
    90         // gcc does some syntax checking anyway. So return a correct value that is not a temporary.
    91             return *(new conversionTests::VeryBigStruct());
    92     }
    93 
    94     // These operators simply accept anything but have lower priority than specialisations
    95     // or exact-match non-template functions.
    96     // They can be identified by the larger return value.
    97     // We put these in a seperate namespace to avoid conflicts with ambiguities.
    98     template <class Any>
    99     conversionTests::VeryBigStruct operator<<(std::ostream& outstream, const Any anything);
    100     template <class Any>
    101     conversionTests::VeryBigStruct operator>>(std::istream& instream,  const Any anything);
     79    // Why the seperate namespace? --> see 'using' statement at the end of conversionTests::
     80    //template <class AnyToType, class AnyFromType>
     81    //conversionTests::VeryBigStruct explicitConversion(AnyToType* output, const AnyFromType input);
     82    //template <class Any, int Dummy>
     83    //conversionTests::VeryBigStruct operator<<(std::ostream& outstream, const Any& anything);
     84    //template <class Any, int Dummy>
     85    //conversionTests::VeryBigStruct operator>>(std::istream& instream,  const Any& anything);
    10286}
    10387
    10488namespace conversionTests
    10589{
    106     // Part of the msvc hack. See above in the namespace for more explanations.
    107     using namespace separate_namespace;
     90// disable warnings about possible loss of data
     91#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
     92#  pragma warning(push)
     93#  pragma warning(disable:4244)
     94#endif
    10895
    10996    template <class FromType, class ToType>
     
    120107        static FromType object; // helper object to handle private c'tor and d'tor
    121108    public:
    122         // test(object) has only 'VerySmallStruct' return type iff the compiler doesn't choose test(...)
     109        // test(object) only has 'VerySmallStruct' return type iff the compiler doesn't choose test(...)
    123110        enum { exists = !(sizeof(test(object)) == sizeof(VeryBigStruct)) };
    124111    };
    125112
    126     template <class FromType, class ToType>
    127     class ExplicitConversion
    128     {
    129     private:
    130         ExplicitConversion(); ExplicitConversion(const ExplicitConversion&); ~ExplicitConversion();
    131         static FromType objectFromType; // helper object to handle private c'tor and d'tor
    132         static ToType   objectToType;   // helper object to handle private c'tor and d'tor
    133     public:
    134         enum { exists = !(sizeof(explicitConversion(&objectToType, objectFromType)) == sizeof(VeryBigStruct)) };
    135     };
    136 
    137     template <class Type>
    138     class IStringStreamOperator
    139     {
    140         IStringStreamOperator(); IStringStreamOperator(const IStringStreamOperator&); ~IStringStreamOperator();
    141         static std::istream istream_; // helper object to perform the '>>' operation
    142         static Type object;                 // helper object to handle private c'tor and d'tor
    143     public:
    144         enum { exists = !(sizeof(istream_ >> object) == sizeof(VeryBigStruct)) };
    145     };
    146 
    147     template <class Type>
    148     class OStringStreamOperator
    149     {
    150         OStringStreamOperator(); OStringStreamOperator(const OStringStreamOperator&); ~OStringStreamOperator();
    151         static std::ostream ostream_; // helper object to perform the '<<' operation
    152         static Type object;                 // helper object to handle private c'tor and d'tor
    153     public:
    154         enum { exists = !(sizeof(ostream_ << object) == sizeof(VeryBigStruct)) };
    155     };
    156 }
    157 
    158 /* Shortcuts because we usually don't have a namespace in util/ but need one here for the conversion tests*/
    159 
    160 /**
    161 @brief
    162     Checks for an implicit conversion FromType --> TyType.
    163     This also works for user defined conversion operators.
    164     Usage: ImplicitConversion<FromType, ToType>::exists
    165 */
    166 //template <class FromType, class ToType>
    167 //struct ImplicitConversion
    168 //{ enum { exists = conversionTests::asdf::ImplicitConversion<FromType, ToType>::exists }; };
    169 
    170 /**
    171 @brief
    172     Checks for an explicit conversion FromType --> TyType via 'explicConversion()' function.
    173     There has to e an exact type match for a success!
    174     Usage: ExplicitConversion<FromType, ToType>::exists
    175 */
    176 //template <class FromType, class ToType>
    177 //struct ExplicitConversion
    178 //{ enum { exists = conversionTests::asdf::ExplicitConversion<FromType, ToType>::exists }; };
    179 
    180 /**
    181 @brief
    182     Checks for an explicit conversion std::string --> TyType via >> operator.
    183     There has to e an exact type match for a success!
    184     Usage: IStringStreamConversion<FromType, ToType>::exists
    185 */
    186 //template <class Type>
    187 //struct IStringStreamOperator
    188 //{ enum { exists = conversionTests::asdf::IStringStreamOperator<Type>::exists }; };
    189 
    190 /**
    191 @brief
    192     Checks for an explicit conversion std::string --> TyType via << operator.
    193     There has to e an exact type match for a success!
    194     Usage: OStringStreamConversion<FromType, ToType>::exists
    195 */
    196 //template <class Type>
    197 //struct OStringStreamOperator
    198 //{ enum { exists = conversionTests::asdf::OStringStreamOperator<Type>::exists }; };
    199 
     113#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
     114#  pragma warning(pop)
     115#endif
     116
     117    //template <class FromType, class ToType>
     118    //class ExplicitConversion
     119    //{
     120    //private:
     121    //    ExplicitConversion(); ExplicitConversion(const ExplicitConversion&); ~ExplicitConversion();
     122    //    static FromType objectFromType; // helper object to handle private c'tor and d'tor
     123    //    static ToType   objectToType;   // helper object to handle private c'tor and d'tor
     124    //public:
     125    //    enum { exists = !(sizeof(explicitConversion(&objectToType, objectFromType)) == sizeof(VeryBigStruct)) };
     126    //};
     127
     128    //template <class Type>
     129    //class IStreamOperator
     130    //{
     131    //    IStreamOperator(); IStreamOperator(const IStreamOperator&); ~IStreamOperator();
     132    //    static std::istream istream_; // helper object to perform the '>>' operation
     133    //    static Type object;           // helper object to handle private c'tor and d'tor
     134    //public:
     135    //    enum { exists = !(sizeof(istream_ >> object) == sizeof(VeryBigStruct)) };
     136    //};
     137
     138    //template <class Type>
     139    //class OStreamOperator
     140    //{
     141    //    OStreamOperator(); OStreamOperator(const OStreamOperator&); ~OStreamOperator();
     142    //    static std::ostream ostream_; // helper object to perform the '<<' operation
     143    //    static Type object;           // helper object to handle private c'tor and d'tor
     144    //public:
     145    //    enum { exists = !(sizeof(ostream_ << object) == sizeof(VeryBigStruct)) };
     146    //};
     147
     148    // Somehow msvc and gcc don't like it when using function arguments that have a type
     149    // in a third namespace. The global namespace functions then get overridden by the
     150    // templates above. So we simply put the generic ones in a another namespace.
     151    // Note: DON'T place this statement before a class template. That would trigger
     152    //       a heavy bug (namespace leakage) in msvc 2005.
     153    //using namespace conversion_another_namespace;
     154}
    200155
    201156
     
    226181*/
    227182
    228 // Put everything in a namespace to avoid unnecessary exposure
    229 // Note that the textual order of the functions is in reverse.
     183namespace
     184{
     185    // little template that maps to ints to entire types (Alexandrescu 2001)
     186    template <int I>
     187    struct Int2Type { };
     188}
     189
     190
     191///////////////////
     192// No Conversion //
     193///////////////////
     194
    230195namespace conversion
    231196{
    232     // Maps bools to types in order to use function overloading instead of template specialisation (Alexandrescu 2001)
    233     template <bool WhetherOrNot>
    234     struct ImplicitPossible { };
    235     template <bool WhetherOrNot>
    236     struct ExplicitPossible { };
    237     template <bool WhetherOrNot>
    238     struct StringStreamPossible { };
    239 
    240 
    241     ///////////////////
    242     // No Conversion //
    243     ///////////////////
    244 
    245     // Default template, no Conversion possible
    246     template <class ToType, class FromType, int Dummy>
     197    // Default template for stringtream, no Conversion possible
     198    template <class ToType, class FromType>
    247199    struct ConverterSS
    248200    {
     
    254206        }
    255207    };
    256 
    257 
    258     ///////////////////
    259     // OStringStream //
    260     ///////////////////
    261 
    262     // Conversion via ostringstream
     208}
     209
     210
     211/////////////
     212// OStream //
     213/////////////
     214
     215namespace fallbackTemplates
     216{
     217    template <class Any>
     218    bool operator <<(std::ostream& outstream,  const Any& anything)
     219    {
     220        COUT(2) << "Could not convert value of type " << typeid(Any).name()
     221                << " to std::string" << std::endl;
     222        return false;
     223    }
     224}
     225
     226namespace conversion
     227{
     228    //using namespace fallbackTemplates;
     229    // template that evaluates whether OStringStream is possible for conversions to std::string
    263230    template <class FromType>
    264     inline bool convertOStringStream(std::string* output, const FromType& input)
    265     {
    266         std::ostringstream oss;
    267         if (oss << input)
    268         {
    269             (*output) = oss.str();
    270             return true;
    271         }
    272         else
    273             return false;
    274     }
    275 
    276     // template that evaluates whether OStringStream is possible for conversions to std::string
    277     template <class FromType, int Dummy>
    278     struct ConverterSS<std::string, FromType, Dummy>
    279     {
    280         // probe for '<<' stringstream operator
     231    struct ConverterSS<std::string, FromType>
     232    {
     233        // probe for '<<' ostream operator
    281234        static bool convert(std::string* output, const FromType& input)
    282235        {
    283             const bool probe = conversionTests::OStringStreamOperator<FromType>::exists;
    284             return convert(output, input, StringStreamPossible<probe>());
    285         }
    286         // Conversion with ostringstream possible
    287         static bool convert(std::string* output, const FromType& input, StringStreamPossible<true>)
    288         {
    289             return convertOStringStream(output, input);
    290         }
    291         // Conversion with ostringstream not possible
    292         static bool convert(std::string* output, const FromType& input, StringStreamPossible<false>)
    293         {
    294             COUT(2) << "Could not convert value of type " << typeid(FromType).name()
    295                     << " to std::string" << std::endl;
    296             return false;
     236            std::ostringstream oss;
     237            if (oss << input)
     238            {
     239                (*output) = oss.str();
     240                return true;
     241            }
     242            else
     243                return false;
    297244        }
    298245    };
    299246
    300 
    301     ///////////////////
    302     // IStringStream //
    303     ///////////////////
    304 
    305     // conversion from std::string via istringstream
     247}
     248
     249
     250/////////////
     251// IStream //
     252/////////////
     253
     254namespace fallbackTemplates
     255{
     256    template <class Any>
     257    bool operator >>(std::istream& instream,  const Any& anything)
     258    {
     259        COUT(2) << "Could not convert std::string value to type " << typeid(ToType).name() << std::endl;
     260        return false;
     261    }
     262}
     263
     264namespace conversion
     265{
     266    // template that evaluates whether IStringStream is possible for conversions from std::string
    306267    template <class ToType>
    307     inline bool convertIStringStream(ToType* output, const std::string& input)
    308     {
    309         std::istringstream iss(input);
    310         if (iss >> (*output))
    311         {
    312             return true;
    313         }
    314         else
    315             return false;
    316     }
    317 
    318     // template that evaluates whether IStringStream is possible for conversions from std::string
    319     template <class ToType, int Dummy>
    320     struct ConverterSS<ToType, std::string, Dummy>
    321     {
    322         // probe for '>>' stringstream operator
     268    struct ConverterSS<ToType, std::string>
     269    {
    323270        static bool convert(ToType* output, const std::string& input)
    324271        {
    325             const bool probe = conversionTests::IStringStreamOperator<ToType>::exists;
    326             return convert(output, input, StringStreamPossible<probe>());
    327         }
    328         // Conversion with istringstream possible
    329         static bool convert(ToType* output, const std::string& input, StringStreamPossible<true>)
    330         {
    331             return convertIStringStream(output, input);
    332         }
    333         // Conversion with istringstream not possible
    334         static bool convert(ToType* output, const std::string& input, StringStreamPossible<false>)
    335         {
    336             COUT(2) << "Could not convert std::string value to type " << typeid(ToType).name() << std::endl;
    337             return false;
     272            std::istringstream iss(input);
     273            if (iss >> (*output))
     274            {
     275                return true;
     276            }
     277            else
     278                return false;
    338279        }
    339280    };
    340281
    341 
    342     ///////////////////
    343     // Implicit Cast //
    344     ///////////////////
    345 
    346     // We can cast implicitely
     282    using namespace fallbackTemplates;
     283}
     284
     285
     286///////////////////
     287// Implicit Cast //
     288///////////////////
     289
     290// We can cast implicitely
     291template <class ToType, class FromType>
     292inline bool convertImplicitely(ToType* output, const FromType& input, ::Int2Type<true>)
     293{
     294    (*output) = static_cast<ToType>(input);
     295    return true;
     296}
     297// static cast no possible, try stringstream conversion next
     298template <class ToType, class FromType>
     299inline bool convertImplicitely(ToType* output, const FromType& input, ::Int2Type<false>)
     300{
     301    return conversion::ConverterSS<ToType, FromType>::convert(output, input);
     302}
     303
     304
     305/////////////////////////
     306// Explicit conversion //
     307/////////////////////////
     308
     309namespace fallbackTemplates
     310{
     311    // We want to keep the templates for the convert functions out of global namespace so that there
     312    // are no ambiguities. These templates are never used anyway, they only serve to detect whether
     313    // there is a global funciton for a specific conversion or not.
     314    // Note: Don't put these functions in a separate namespace and add a 'using' directive here.
     315    // For MS sake, just don't!
    347316    template <class ToType, class FromType>
    348     inline bool convert(ToType* output, const FromType& input, ImplicitPossible<true>)
    349     {
    350         (*output) = static_cast<ToType>(input);
    351         return true;
     317    bool explicitConversion(ToType* output, const FromType input)
     318    {
     319        // try implict conversion by probing first because we use '...' instead of a template
     320        const bool probe = conversionTests::ImplicitConversion<FromType, ToType>::exists;
     321        //using namespace conversion;
     322        return convertImplicitely(output, input, ::Int2Type<probe>());
    352323    }
    353 
    354     // No implicit cast, leave it up to << and >> via template spcialisation
    355     template <class ToType, class FromType>
    356     inline bool convert(ToType* output, const FromType& input, ImplicitPossible<false>)
    357     {
    358         return ConverterSS<ToType, FromType, 0>::convert(output, input);
    359     }
    360 
    361 
    362     /////////////////////////
    363     // Explicit Conversion //
    364     /////////////////////////
    365 
    366     // We can convert explicitely via function overloading
    367     template <class ToType, class FromType>
    368     inline bool convert(ToType* output, const FromType& input, ExplicitPossible<true>)
    369     {
    370         // This function can by anywhere globally!
    371         return explicitConversion(output, input);
    372     }
    373 
    374     // No explict conversion via explicitConversion(), try implicit cast
    375     template <class ToType, class FromType>
    376     inline bool convert(ToType* output, const FromType& input, ExplicitPossible<false>)
    377     {
    378         const bool probe = conversionTests::ImplicitConversion<FromType, ToType>::exists;
    379         return convert(output, input, ImplicitPossible<probe>());
    380     }
    381 }
    382 
    383 // We usually don't have a namespace in util/ but it would still be desirable to lock
    384 // everything internal away in namespace conversion.
    385 // However this template can be specialised everywhere.
    386 
    387 // Template that is used when no explicit template specialisation is available
    388 // try explicitConversion() function next.
     324}
     325
     326
     327/////////////////////
     328// Local Overwrite //
     329/////////////////////
     330
     331// Template that is used when no explicit template specialisation is available.
     332// Try explicitConversion() function next.
    389333template <class ToType, class FromType>
    390334struct ConverterExplicit
     
    392336    static bool convert(ToType* output, const FromType& input)
    393337    {
    394         // check for explicit conversion via function overloading
    395         const bool probe = conversionTests::ExplicitConversion<FromType, ToType>::exists;
    396         return conversion::convert(output, input, conversion::ExplicitPossible<probe>());
     338        using namespace fallbackTemplates;
     339        return explicitConversion(output, input);
    397340    }
    398341};
     
    474417
    475418
    476 ///////////////////////////////////////
    477 // Explicit Template Specialisations //
    478 ///////////////////////////////////////
     419////////////////////////////////
     420// Special string conversions //
     421////////////////////////////////
    479422
    480423// delegate conversion from const char* to std::string
    481424template <class ToType>
    482 struct ConverterExplicit<ToType, const char*>
    483 {
    484     static bool convert(ToType* output, const char* input)
    485     {
    486         return ConverterExplicit<ToType, std::string>::convert(output, input);
    487     }
    488 };
     425inline bool explicitConversion(ToType* output, const char* input)
     426{
     427    return ConverterExplicit<ToType, std::string>::convert(output, input);
     428}
    489429
    490430// These conversions would exhibit ambiguous << or >> operators when using stringstream
    491 template <> struct ConverterExplicit<std::string, char>
    492 {
    493     static bool convert(std::string* output, const char input)
    494     {
    495         *output = std::string(1, input);
    496         return true;
    497     }
    498 };
    499 template <> struct ConverterExplicit<std::string, unsigned char>
    500 {
    501     static bool convert(std::string* output, const unsigned char input)
    502     {
    503         *output = std::string(1, input);
    504         return true;
    505     }
    506 };
    507 template <> struct ConverterExplicit<char, std::string>
    508 {
    509     static bool convert(char* output, const std::string input)
    510     {
    511         if (input != "")
    512             *output = input[0];
    513         else
    514             *output = '\0';
    515         return true;
    516     }
    517 };
    518 template <> struct ConverterExplicit<unsigned char, std::string>
    519 {
    520     static bool convert(unsigned char* output, const std::string input)
    521     {
    522         if (input != "")
    523             *output = input[0];
    524         else
    525             *output = '\0';
    526         return true;
    527     }
    528 };
     431inline bool explicitConversion(std::string* output, const char input)
     432{
     433    *output = std::string(1, input);
     434    return true;
     435}
     436inline bool explicitConversion(std::string* output, const unsigned char input)
     437{
     438    *output = std::string(1, input);
     439    return true;
     440}
     441inline bool explicitConversion(char* output, const std::string input)
     442{
     443    if (input != "")
     444        *output = input[0];
     445    else
     446        *output = '\0';
     447    return true;
     448}
     449inline bool explicitConversion(unsigned char* output, const std::string input)
     450{
     451    if (input != "")
     452        *output = input[0];
     453    else
     454        *output = '\0';
     455    return true;
     456}
    529457
    530458#endif /* _Convert_H__ */
  • code/branches/core3/src/util/Math.cc

    r1766 r1777  
    3030
    3131#include <OgrePlane.h>
    32 #include "Convert.h"
     32#include "MathConvert.h"
    3333
    3434/**
  • code/branches/core3/src/util/Math.h

    r1768 r1777  
    6464_UtilExport orxonox::Vector2 get2DViewcoordinates(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition);
    6565_UtilExport orxonox::Vector3 getPredictedPosition(const orxonox::Vector3& myposition, float projectilespeed, const orxonox::Vector3& targetposition, const orxonox::Vector3& targetvelocity);
    66 
    67 /////////////////////////////////////
    68 // Conversion Functions of our own //
    69 /////////////////////////////////////
    70 
    71 // Vector2 to std::string
    72 //inline bool explicitConversion(std::string* output, const orxonox::Vector2& input)
    73 //{
    74 //    std::ostringstream ostream;
    75 //    if (ostream << input.x << "," << input.y)
    76 //    {
    77 //        (*output) = ostream.str();
    78 //        return true;
    79 //    }
    80 //    return false;
    81 //}
    82 
    83 // Vector3 to std::string
    84 inline bool explicitConversion(std::string* output, const orxonox::Vector3& input)
    85 {
    86     std::ostringstream ostream;
    87     if (ostream << input.x << "," << input.y << "," << input.z)
    88     {
    89         (*output) = ostream.str();
    90         return true;
    91     }
    92     return false;
    93 }
    94 
    95 // Vector4 to std::string
    96 inline bool explicitConversion(std::string* output, const orxonox::Vector4& input)
    97 {
    98     std::ostringstream ostream;
    99     if (ostream << input.x << "," << input.y << "," << input.z << "," << input.w)
    100     {
    101         (*output) = ostream.str();
    102         return true;
    103     }
    104     return false;
    105 }
    106 
    107 // Quaternion to std::string
    108 inline bool explicitConversion(std::string* output, const orxonox::Quaternion& input)
    109 {
    110     std::ostringstream ostream;
    111     if (ostream << input.w << "," << input.x << "," << input.y << "," << input.z)
    112     {
    113         (*output) = ostream.str();
    114         return true;
    115     }
    116     return false;
    117 }
    118 
    119 // ColourValue to std::string
    120 inline bool explicitConversion(std::string* output, const orxonox::ColourValue& input)
    121 {
    122     std::ostringstream ostream;
    123     if (ostream << input.r << "," << input.g << "," << input.b << "," << input.a)
    124     {
    125         (*output) = ostream.str();
    126         return true;
    127     }
    128     return false;
    129 }
    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 //}
    142 
    143 // std::string to Vector2
    144 _UtilExport bool explicitConversion(orxonox::Vector2* output, const std::string& input);
    145 // std::string to Vector3
    146 _UtilExport bool explicitConversion(orxonox::Vector3* output, const std::string& input);
    147 // std::string to Vector4
    148 _UtilExport bool explicitConversion(orxonox::Vector4* output, const std::string& input);
    149 // std::string to Quaternion
    150 _UtilExport bool explicitConversion(orxonox::Quaternion* output, const std::string& input);
    151 // std::string to ColourValue
    152 _UtilExport bool explicitConversion(orxonox::ColourValue* output, const std::string& input);
    15366
    15467template <typename T>
  • code/branches/core3/src/util/MultiTypeValue.h

    r1768 r1777  
    3131
    3232#include "UtilPrereqs.h"
    33 #include "Convert.h"
     33#include "MathConvert.h"
    3434#include "MultiType.h"
    3535
  • code/branches/core3/visual_studio/vc8/util.vcproj

    r1719 r1777  
    223223                        </File>
    224224                        <File
     225                                RelativePath="..\..\src\util\MathConvert.h"
     226                                >
     227                        </File>
     228                        <File
    225229                                RelativePath="..\..\src\util\MultiType.h"
    226230                                >
Note: See TracChangeset for help on using the changeset viewer.