Crazy Eddie's GUI System  0.8.4
PropertyHelper.h
00001 /***********************************************************************
00002         created:        21/11/2010
00003         author:         Martin Preisler (reworked from code by Paul D Turner)
00004         
00005         purpose:        Interface to the PropertyHelper class
00006 *************************************************************************/
00007 /***************************************************************************
00008  *   Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
00009  *
00010  *   Permission is hereby granted, free of charge, to any person obtaining
00011  *   a copy of this software and associated documentation files (the
00012  *   "Software"), to deal in the Software without restriction, including
00013  *   without limitation the rights to use, copy, modify, merge, publish,
00014  *   distribute, sublicense, and/or sell copies of the Software, and to
00015  *   permit persons to whom the Software is furnished to do so, subject to
00016  *   the following conditions:
00017  *
00018  *   The above copyright notice and this permission notice shall be
00019  *   included in all copies or substantial portions of the Software.
00020  *
00021  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00022  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00023  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00024  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
00025  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00026  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00027  *   OTHER DEALINGS IN THE SOFTWARE.
00028  ***************************************************************************/
00029 #ifndef _CEGUIPropertyHelper_h_
00030 #define _CEGUIPropertyHelper_h_
00031 
00032 #include "CEGUI/String.h"
00033 #include "CEGUI/Size.h"
00034 #include "CEGUI/Vector.h"
00035 #include "CEGUI/Quaternion.h"
00036 #include "CEGUI/Colour.h"
00037 #include "CEGUI/ColourRect.h"
00038 #include "CEGUI/UDim.h"
00039 #include "CEGUI/Rect.h"
00040 
00041 
00042 #include <cstdio>
00043 
00044 #include <sstream>
00045 
00046 #if defined(_MSC_VER)
00047 #       pragma warning(push)
00048 #       pragma warning(disable : 4996)
00049 #endif
00050 
00051 #ifdef _MSC_VER
00052 #define snprintf _snprintf
00053 #endif
00054 
00055 
00056 namespace CEGUI
00057 {
00058 
00069 template<typename T>
00070 class PropertyHelper;
00071 
00072 // this redirects PropertyHelper<const T> to PropertyHelper<T>
00073 template<typename T>
00074 class PropertyHelper<const T>
00075 {
00076 public:
00077     typedef typename PropertyHelper<T>::return_type return_type;
00078     typedef typename PropertyHelper<T>::safe_method_return_type safe_method_return_type;
00079     typedef typename PropertyHelper<T>::pass_type pass_type;
00080     typedef typename PropertyHelper<T>::string_return_type string_return_type;
00081 
00082     static inline const String& getDataTypeName()
00083     {
00084         return PropertyHelper<T>::getDataTypeName();
00085     }
00086 
00087     static inline return_type fromString(const String& str)
00088     {
00089         return PropertyHelper<T>::fromString(str);
00090     }
00091 
00092     static inline String toString(pass_type val)
00093     {
00094         return PropertyHelper<T>::toString(val);
00095     }
00096 };
00097 
00098 // this redirects PropertyHelper<const T&> to PropertyHelper<T>
00099 template<typename T>
00100 class PropertyHelper<const T&>
00101 {
00102 public:
00103     typedef typename PropertyHelper<T>::return_type return_type;
00104     typedef typename PropertyHelper<T>::safe_method_return_type safe_method_return_type;
00105     typedef typename PropertyHelper<T>::pass_type pass_type;
00106     typedef typename PropertyHelper<T>::string_return_type string_return_type;
00107 
00108     static inline const String& getDataTypeName()
00109     {
00110         return PropertyHelper<T>::getDataTypeName();
00111     }
00112 
00113     static inline return_type fromString(const String& str)
00114     {
00115         return PropertyHelper<T>::fromString(str);
00116     }
00117 
00118     static inline String toString(pass_type val)
00119     {
00120         return PropertyHelper<T>::toString(val);
00121     }
00122 };
00123 
00124 // this redirects PropertyHelper<const T*> to PropertyHelper<T*>
00125 template<typename T>
00126 class PropertyHelper<const T*>
00127 {
00128 public:
00129     typedef typename PropertyHelper<T*>::return_type return_type;
00130     typedef typename PropertyHelper<T*>::safe_method_return_type safe_method_return_type;
00131     typedef typename PropertyHelper<T*>::pass_type pass_type;
00132     typedef typename PropertyHelper<T*>::string_return_type string_return_type;
00133 
00134     static inline const String& getDataTypeName()
00135     {
00136         return PropertyHelper<T>::getDataTypeName();
00137     }
00138 
00139     static inline return_type fromString(const String& str)
00140     {
00141         return PropertyHelper<T*>::fromString(str);
00142     }
00143 
00144     static inline String toString(pass_type val)
00145     {
00146         return PropertyHelper<T*>::toString(val);
00147     }
00148 };
00149 
00150 template<>
00151 class PropertyHelper<String>
00152 {
00153 public:
00154     typedef const String& return_type;
00155     typedef String safe_method_return_type;
00156     typedef const String& pass_type;
00157     typedef const String& string_return_type;
00158 
00159     static const String& getDataTypeName()
00160     {
00161         static String type("String");
00162 
00163         return type;
00164     }
00165 
00166     static inline return_type fromString(const String& str)
00167     {
00168         return str;
00169     }
00170 
00171     static inline string_return_type toString(pass_type val)
00172     {
00173         return val;
00174     }
00175 };
00176 
00177 template<>
00178 class PropertyHelper<float>
00179 {
00180 public:
00181     typedef float return_type;
00182     typedef return_type safe_method_return_type;
00183     typedef const float pass_type;
00184     typedef String string_return_type;
00185     
00186     static const String& getDataTypeName()
00187     {
00188         static String type("float");
00189 
00190         return type;
00191     }
00192 
00193     static inline return_type fromString(const String& str)
00194     {
00195         float val = 0;
00196         sscanf(str.c_str(), " %g", &val);
00197         
00198         return val;
00199     }
00200 
00201     static inline string_return_type toString(pass_type val)
00202     {
00203         char buff[64];
00204         snprintf(buff, sizeof(buff), "%g", val);
00205 
00206         return String(buff);
00207     }
00208 };
00209 template<>
00210 class PropertyHelper<double>
00211 {
00212 public:
00213     typedef double return_type;
00214     typedef return_type safe_method_return_type;
00215     typedef const double pass_type;
00216     typedef String string_return_type;
00217     
00218     static const String& getDataTypeName()
00219     {
00220         static String type("double");
00221 
00222         return type;
00223     }
00224 
00225     static inline return_type fromString(const String& str)
00226     {
00227         double val = 0;
00228         sscanf(str.c_str(), " %lg", &val);
00229         
00230         return val;
00231     }
00232 
00233     static inline string_return_type toString(pass_type val)
00234     {
00235         char buff[64];
00236         snprintf(buff, sizeof(buff), "%g", val);
00237 
00238         return String(buff);
00239     }
00240 };
00241 
00242 template<>
00243 class PropertyHelper<int>
00244 {
00245 public:
00246     typedef int return_type;
00247     typedef return_type safe_method_return_type;
00248     typedef const int pass_type;
00249     typedef String string_return_type;
00250     
00251     static const String& getDataTypeName()
00252     {
00253         static String type("int");
00254 
00255         return type;
00256     }
00257 
00258     static inline return_type fromString(const String& str)
00259     {
00260         int val = 0;
00261         sscanf(str.c_str(), " %d", &val);
00262 
00263         return val;
00264     }
00265 
00266     static inline string_return_type toString(pass_type val)
00267     {
00268         char buff[64];
00269         snprintf(buff, sizeof(buff), "%d", val);
00270 
00271         return String(buff);
00272     }
00273 };
00274 
00275 template<>
00276 class PropertyHelper<uint>
00277 {
00278 public:
00279     typedef uint return_type;
00280     typedef return_type safe_method_return_type;
00281     typedef const uint pass_type;
00282     typedef String string_return_type;
00283     
00284     static const String& getDataTypeName()
00285     {
00286         static String type("uint");
00287 
00288         return type;
00289     }
00290 
00291     static return_type fromString(const String& str)
00292     {
00293         uint val = 0;
00294         sscanf(str.c_str(), " %u", &val);
00295 
00296         return val;
00297     }
00298 
00299     static string_return_type toString(pass_type val)
00300     {
00301         char buff[64];
00302         snprintf(buff, sizeof(buff), "%u", val);
00303 
00304         return String(buff);
00305     }
00306 };
00307 
00308 template<>
00309 class PropertyHelper<uint64>
00310 {
00311 public:
00312     typedef uint64 return_type;
00313     typedef return_type safe_method_return_type;
00314     typedef const uint64 pass_type;
00315     typedef String string_return_type;
00316     
00317     static const String& getDataTypeName()
00318     {
00319         static String type("uint64");
00320 
00321         return type;
00322     }
00323 
00324     static return_type fromString(const String& str)
00325     {
00326         uint64 val = 0;
00327         sscanf(str.c_str(), " %llu", &val);
00328 
00329         return val;
00330     }
00331 
00332     static string_return_type toString(pass_type val)
00333     {
00334         char buff[64];
00335         snprintf(buff, sizeof(buff), "%llu", val);
00336 
00337         return String(buff);
00338     }
00339 };
00340 
00341 #if CEGUI_STRING_CLASS != CEGUI_STRING_CLASS_UNICODE
00342 
00343 template<>
00344 class PropertyHelper<String::value_type>
00345 {
00346 public:
00347     typedef String::value_type return_type;
00348     typedef return_type safe_method_return_type;
00349     typedef const String::value_type pass_type;
00350     typedef String string_return_type;
00351     
00352     static const String& getDataTypeName()
00353     {
00354         static String type("char");
00355 
00356         return type;
00357     }
00358 
00359     static return_type fromString(const String& str)
00360     {
00361         return str[0];
00362     }
00363 
00364     static string_return_type toString(pass_type val)
00365     {
00366         return String("") + val;
00367     }
00368 };
00369 
00370 #endif
00371 
00372 template<>
00373 class PropertyHelper<unsigned long>
00374 {
00375 public:
00376     typedef unsigned long return_type;
00377     typedef return_type safe_method_return_type;
00378     typedef const unsigned long pass_type;
00379     typedef String string_return_type;
00380     
00381     static const String& getDataTypeName()
00382     {
00383         static String type("unsigned long");
00384 
00385         return type;
00386     }
00387 
00388     static return_type fromString(const String& str)
00389     {
00390         unsigned long val = 0;
00391         sscanf(str.c_str(), " %lu", &val);
00392 
00393         return val;
00394     }
00395 
00396     static string_return_type toString(pass_type val)
00397     {
00398         char buff[64];
00399         snprintf(buff, sizeof(buff), "%lu", val);
00400 
00401         return String(buff);
00402     }
00403 };
00404 
00405 template<> 
00406 class CEGUIEXPORT PropertyHelper<bool>
00407 {
00408 public:
00409     typedef bool return_type;
00410     typedef return_type safe_method_return_type;
00411     typedef const bool pass_type;
00412     typedef const String& string_return_type;
00413     
00414     static const String& getDataTypeName()
00415     {
00416         static String type("bool");
00417 
00418         return type;
00419     }
00420 
00421     static return_type fromString(const String& str)
00422     {
00423         return (str == True || str == "True");
00424     }
00425 
00426     static string_return_type toString(pass_type val)
00427     {
00428         return val ? True : False;
00429     }
00430 
00432     static const CEGUI::String True;
00433     static const CEGUI::String False;
00434 };
00435 
00436 
00437 
00438 template<> 
00439 class CEGUIEXPORT PropertyHelper<AspectMode>
00440 {
00441 public:
00442     typedef AspectMode return_type;
00443     typedef return_type safe_method_return_type;
00444     typedef AspectMode pass_type;
00445     typedef String string_return_type;
00446 
00447     static const String& getDataTypeName()
00448     {
00449         static String type("AspectMode");
00450 
00451         return type;
00452     }
00453 
00454     static return_type fromString(const String& str)
00455     {
00456         if (str == Shrink)
00457         {
00458             return AM_SHRINK;
00459         }
00460         else if (str == Expand)
00461         {
00462             return AM_EXPAND;
00463         }
00464         else
00465         {
00466             return AM_IGNORE;
00467         }
00468     }
00469 
00470     static string_return_type toString(pass_type val)
00471     {
00472         if (val == AM_IGNORE)
00473         {
00474             return Ignore;
00475         }
00476         else if (val == AM_SHRINK)
00477         {
00478             return Shrink;
00479         }
00480         else if (val == AM_EXPAND)
00481         {
00482             return Expand;
00483         }
00484         else
00485         {
00486             assert(false && "Invalid aspect mode");
00487             return Ignore;
00488         }
00489     }
00490 
00492     static const CEGUI::String Shrink;
00493     static const CEGUI::String Expand;
00494     static const CEGUI::String Ignore;
00495 };
00496 
00497 template<>
00498 class PropertyHelper<Sizef >
00499 {
00500 public:
00501     typedef Sizef return_type;
00502     typedef return_type safe_method_return_type;
00503     typedef const Sizef& pass_type;
00504     typedef String string_return_type;
00505 
00506     static const String& getDataTypeName()
00507     {
00508         static String type("Sizef");
00509 
00510         return type;
00511     }
00512 
00513     static return_type fromString(const String& str)
00514     {
00515         Sizef val(0, 0);
00516         sscanf(str.c_str(), " w:%g h:%g", &val.d_width, &val.d_height);
00517 
00518         return val;
00519     }
00520 
00521     static string_return_type toString(pass_type val)
00522     {
00523         char buff[128];
00524         snprintf(buff, sizeof(buff), "w:%g h:%g", val.d_width, val.d_height);
00525 
00526         return String(buff);
00527     }
00528 };
00529 
00530 template<>
00531 class PropertyHelper<Vector2f >
00532 {
00533 public:
00534     typedef Vector2f return_type;
00535     typedef return_type safe_method_return_type;
00536     typedef const Vector2f& pass_type;
00537     typedef String string_return_type;
00538 
00539     static const String& getDataTypeName()
00540     {
00541         static String type("Vector2f");
00542 
00543         return type;
00544     }
00545 
00546     static return_type fromString(const String& str)
00547     {
00548         Vector2f val(0, 0) ;
00549         sscanf(str.c_str(), " x:%g y:%g", &val.d_x, &val.d_y);
00550 
00551         return val;
00552     }
00553 
00554     static string_return_type toString(pass_type val)
00555     {
00556         char buff[128];
00557         snprintf(buff, sizeof(buff), "x:%g y:%g", val.d_x, val.d_y);
00558 
00559         return String(buff);
00560     }
00561 };
00562 
00563 template<>
00564 class PropertyHelper<Vector3f >
00565 {
00566 public:
00567     typedef Vector3f return_type;
00568     typedef return_type safe_method_return_type;
00569     typedef const Vector3f& pass_type;
00570     typedef String string_return_type;
00571     
00572     static const String& getDataTypeName()
00573     {
00574         static String type("Vector3f");
00575 
00576         return type;
00577     }
00578 
00579     static return_type fromString(const String& str)
00580     {
00581         Vector3f val(0, 0, 0);
00582         sscanf(str.c_str(), " x:%g y:%g z:%g", &val.d_x, &val.d_y, &val.d_z);
00583 
00584         return val;
00585     }
00586 
00587     static string_return_type toString(pass_type val)
00588     {
00589         char buff[128];
00590         snprintf(buff, sizeof(buff), "x:%g y:%g z:%g", val.d_x, val.d_y, val.d_z);
00591 
00592         return String(buff);
00593     }
00594 };
00595 
00596 template<>
00597 class PropertyHelper<Quaternion>
00598 {
00599 public:
00600     typedef Quaternion return_type;
00601     typedef return_type safe_method_return_type;
00602     typedef const Quaternion& pass_type;
00603     typedef String string_return_type;
00604     
00605     static const String& getDataTypeName()
00606     {
00607         static String type("Quaternion");
00608 
00609         return type;
00610     }
00611 
00612     static return_type fromString(const String& str)
00613     {
00614         if (strchr(str.c_str(), 'w') || strchr(str.c_str(), 'W'))
00615         {
00616             Quaternion val(1, 0, 0, 0);
00617             sscanf(str.c_str(), " w:%g x:%g y:%g z:%g", &val.d_w, &val.d_x, &val.d_y, &val.d_z);
00618 
00619             return val;
00620         }
00621         else
00622         {
00623             float x, y, z;
00624             sscanf(str.c_str(), " x:%g y:%g z:%g", &x, &y, &z);
00625             return Quaternion::eulerAnglesDegrees(x, y, z);
00626         }
00627     }
00628 
00629     static string_return_type toString(pass_type val)
00630     {
00631         char buff[128];
00632         snprintf(buff, sizeof(buff), "w:%g x:%g y:%g z:%g", val.d_w, val.d_x, val.d_y, val.d_z);
00633 
00634         return String(buff);
00635     }
00636 };
00637 
00638 template<>
00639 class PropertyHelper<Rectf >
00640 {
00641 public:
00642     typedef Rectf return_type;
00643     typedef return_type safe_method_return_type;
00644     typedef const Rectf& pass_type;
00645     typedef String string_return_type;
00646     
00647     static const String& getDataTypeName()
00648     {
00649         static String type("Rectf");
00650 
00651         return type;
00652     }
00653 
00654     static return_type fromString(const String& str)
00655     {
00656         Rectf val(0, 0, 0, 0);
00657         sscanf(str.c_str(), " l:%g t:%g r:%g b:%g", &val.d_min.d_x, &val.d_min.d_y, &val.d_max.d_x, &val.d_max.d_y);
00658 
00659         return val;
00660     }
00661 
00662     static string_return_type toString(pass_type val)
00663     {
00664         char buff[256];
00665         snprintf(buff, sizeof(buff), "l:%g t:%g r:%g b:%g",
00666                  val.d_min.d_x, val.d_min.d_y, val.d_max.d_x, val.d_max.d_y);
00667 
00668         return String(buff);
00669     }
00670 };
00671 
00672 template<>
00673 class CEGUIEXPORT PropertyHelper<Image*>
00674 {
00675 public:
00676     typedef const Image* return_type;
00677     typedef return_type safe_method_return_type;
00678     typedef const Image* const pass_type;
00679     typedef String string_return_type;
00680     
00681     static const String& getDataTypeName()
00682     {
00683         static String type("Image");
00684 
00685         return type;
00686     }
00687 
00688     static return_type fromString(const String& str);
00689 
00690     static string_return_type toString(pass_type val);
00691 };
00692 
00693 template<>
00694 class PropertyHelper<Colour>
00695 {
00696 public:
00697     typedef Colour return_type;
00698     typedef return_type safe_method_return_type;
00699     typedef const Colour& pass_type;
00700     typedef String string_return_type;
00701     
00702     static const String& getDataTypeName()
00703     {
00704         static String type("Colour");
00705 
00706         return type;
00707     }
00708 
00709     static return_type fromString(const String& str)
00710     {
00711         argb_t val = 0xFF000000;
00712         sscanf(str.c_str(), " %8X", &val);
00713 
00714         return Colour(val);
00715     }
00716 
00717     static string_return_type toString(pass_type val)
00718     {
00719         char buff[16];
00720         sprintf(buff, "%.8X", val.getARGB());
00721 
00722         return String(buff);
00723     }
00724 };
00725 
00726 template<>
00727 class PropertyHelper<ColourRect>
00728 {
00729 public:
00730     typedef ColourRect return_type;
00731     typedef return_type safe_method_return_type;
00732     typedef const ColourRect& pass_type;
00733     typedef String string_return_type;
00734     
00735     static const String& getDataTypeName()
00736     {
00737         static String type("ColourRect");
00738 
00739         return type;
00740     }
00741 
00742     static return_type fromString(const String& str)
00743     {
00744         if (str.length() == 8)
00745         {
00746             argb_t all = 0xFF000000;
00747             sscanf(str.c_str(), "%8X", &all);
00748             return ColourRect(all);
00749         }
00750 
00751         argb_t topLeft = 0xFF000000, topRight = 0xFF000000, bottomLeft = 0xFF000000, bottomRight = 0xFF000000;
00752         sscanf(str.c_str(), "tl:%8X tr:%8X bl:%8X br:%8X", &topLeft, &topRight, &bottomLeft, &bottomRight);
00753 
00754         return ColourRect(topLeft, topRight, bottomLeft, bottomRight);
00755     }
00756 
00757     static string_return_type toString(pass_type val)
00758     {
00759         char buff[64];
00760         sprintf(buff, "tl:%.8X tr:%.8X bl:%.8X br:%.8X", val.d_top_left.getARGB(), val.d_top_right.getARGB(), val.d_bottom_left.getARGB(), val.d_bottom_right.getARGB());
00761 
00762         return String(buff);
00763     }
00764 };
00765 
00766 template<>
00767 class PropertyHelper<UDim>
00768 {
00769 public:
00770     typedef UDim return_type;
00771     typedef return_type safe_method_return_type;
00772     typedef const UDim& pass_type;
00773     typedef String string_return_type;
00774     
00775     static const String& getDataTypeName()
00776     {
00777         static String type("UDim");
00778 
00779         return type;
00780     }
00781 
00782     static return_type fromString(const String& str)
00783     {
00784         UDim ud;
00785         sscanf(str.c_str(), " { %g , %g }", &ud.d_scale, &ud.d_offset);
00786 
00787         return ud;
00788     }
00789 
00790     static string_return_type toString(pass_type val)
00791     {
00792         char buff[128];
00793         snprintf(buff, sizeof(buff), "{%g,%g}", val.d_scale, val.d_offset);
00794 
00795         return String(buff);
00796     }
00797 };
00798 
00799 template<>
00800 class PropertyHelper<UVector2>
00801 {
00802 public:
00803     typedef UVector2 return_type;
00804     typedef return_type safe_method_return_type;
00805     typedef const UVector2& pass_type;
00806     typedef String string_return_type;
00807     
00808     static const String& getDataTypeName()
00809     {
00810         static String type("UVector2");
00811 
00812         return type;
00813     }
00814 
00815     static return_type fromString(const String& str)
00816     {
00817         UVector2 uv;
00818         sscanf(str.c_str(), " { { %g , %g } , { %g , %g } }",
00819                &uv.d_x.d_scale, &uv.d_x.d_offset,
00820                &uv.d_y.d_scale, &uv.d_y.d_offset);
00821 
00822         return uv;
00823     }
00824 
00825     static string_return_type toString(pass_type val)
00826     {
00827         char buff[256];
00828         snprintf(buff, sizeof(buff), "{{%g,%g},{%g,%g}}",
00829                  val.d_x.d_scale, val.d_x.d_offset, val.d_y.d_scale, val.d_y.d_offset);
00830 
00831         return String(buff);
00832     }
00833 };
00834 
00835 template<>
00836 class PropertyHelper<USize>
00837 {
00838 public:
00839     typedef USize return_type;
00840     typedef return_type safe_method_return_type;
00841     typedef const USize& pass_type;
00842     typedef String string_return_type;
00843     
00844     static const String& getDataTypeName()
00845     {
00846         static String type("USize");
00847 
00848         return type;
00849     }
00850 
00851     static return_type fromString(const String& str)
00852     {
00853         USize uv;
00854         sscanf(str.c_str(), " { { %g , %g } , { %g , %g } }",
00855                &uv.d_width.d_scale, &uv.d_width.d_offset,
00856                &uv.d_height.d_scale, &uv.d_height.d_offset);
00857 
00858         return uv;
00859     }
00860 
00861     static string_return_type toString(pass_type val)
00862     {
00863         char buff[256];
00864         snprintf(buff, sizeof(buff), "{{%g,%g},{%g,%g}}",
00865                  val.d_width.d_scale, val.d_width.d_offset, val.d_height.d_scale, val.d_height.d_offset);
00866 
00867         return String(buff);
00868     }
00869 };
00870 
00871 template<>
00872 class PropertyHelper<URect>
00873 {
00874 public:
00875     typedef URect return_type;
00876     typedef return_type safe_method_return_type;
00877     typedef const URect& pass_type;
00878     typedef String string_return_type;
00879     
00880     static const String& getDataTypeName()
00881     {
00882         static String type("URect");
00883 
00884         return type;
00885     }
00886 
00887     static return_type fromString(const String& str)
00888     {
00889         URect ur;
00890         sscanf(
00891             str.c_str(),
00892             " { { %g , %g } , { %g , %g } , { %g , %g } , { %g , %g } }",
00893             &ur.d_min.d_x.d_scale, &ur.d_min.d_x.d_offset,
00894             &ur.d_min.d_y.d_scale, &ur.d_min.d_y.d_offset,
00895             &ur.d_max.d_x.d_scale, &ur.d_max.d_x.d_offset,
00896             &ur.d_max.d_y.d_scale, &ur.d_max.d_y.d_offset
00897         );
00898 
00899         return ur;
00900     }
00901 
00902     static string_return_type toString(pass_type val)
00903     {
00904         char buff[512];
00905         snprintf(buff, sizeof(buff), "{{%g,%g},{%g,%g},{%g,%g},{%g,%g}}",
00906                  val.d_min.d_x.d_scale, val.d_min.d_x.d_offset,
00907                  val.d_min.d_y.d_scale, val.d_min.d_y.d_offset,
00908                  val.d_max.d_x.d_scale, val.d_max.d_x.d_offset,
00909                  val.d_max.d_y.d_scale, val.d_max.d_y.d_offset);
00910 
00911         return String(buff);
00912     }
00913 };
00914 
00915 template<>
00916 class PropertyHelper<UBox>
00917 {
00918 public:
00919     typedef UBox return_type;
00920     typedef return_type safe_method_return_type;
00921     typedef const UBox& pass_type;
00922     typedef String string_return_type;
00923     
00924     static const String& getDataTypeName()
00925     {
00926         static String type("UBox");
00927 
00928         return type;
00929     }
00930 
00931     static return_type fromString(const String& str)
00932     {
00933         UBox ret;
00934         sscanf(
00935             str.c_str(),
00936             " { top: { %g , %g } , left: { %g , %g } , bottom: { %g , %g } , right: { %g , %g } }",
00937             &ret.d_top.d_scale, &ret.d_top.d_offset,
00938             &ret.d_left.d_scale, &ret.d_left.d_offset,
00939             &ret.d_bottom.d_scale, &ret.d_bottom.d_offset,
00940             &ret.d_right.d_scale, &ret.d_right.d_offset
00941         );
00942 
00943         return ret;
00944     }
00945 
00946     static string_return_type toString(pass_type val)
00947     {
00948         char buff[512];
00949         snprintf(buff, sizeof(buff), "{top:{%g,%g},left:{%g,%g},bottom:{%g,%g},right:{%g,%g}}",
00950                  val.d_top.d_scale, val.d_top.d_offset,
00951                  val.d_left.d_scale, val.d_left.d_offset,
00952                  val.d_bottom.d_scale, val.d_bottom.d_offset,
00953                  val.d_right.d_scale, val.d_right.d_offset);
00954 
00955         return String(buff);
00956     }
00957 };
00958 
00959 
00960 template<>
00961 class CEGUIEXPORT PropertyHelper<Font*>
00962 {
00963 public:
00964     typedef const Font* return_type;
00965     typedef return_type safe_method_return_type;
00966     typedef const Font* const pass_type;
00967     typedef String string_return_type;
00968     
00969     static const String& getDataTypeName()
00970     {
00971         static String type("Font");
00972 
00973         return type;
00974     }
00975 
00976     static return_type fromString(const String& str);
00977     static string_return_type toString(pass_type val);
00978 };
00979 
00980 }
00981 
00982 #if defined(_MSC_VER)
00983 #       pragma warning(pop)
00984 #endif
00985 
00986 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends