1 /* 2 Copyright (C) 2006 Nikolas Zimmermann <wildfox (at) kde.org> 3 2006 Apple Computer Inc. 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Library General Public 7 License as published by the Free Software Foundation; either 8 version 2 of the License, or (at your option) any later version. 9 10 This library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Library General Public License for more details. 14 15 You should have received a copy of the GNU Library General Public License 16 along with this library; see the file COPYING.LIB. If not, write to 17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 Boston, MA 02110-1301, USA. 19 */ 20 21 #ifndef SVGListTraits_h 22 #define SVGListTraits_h 23 24 #if ENABLE(SVG) 25 26 #include <wtf/RefPtr.h> 27 28 namespace WebCore { 29 30 template<typename Item> struct UsesDefaultInitializer { static const bool value = true; }; 31 template<> struct UsesDefaultInitializer<double> { static const bool value = false; }; 32 template<> struct UsesDefaultInitializer<float> { static const bool value = false; }; 33 34 template<bool usesDefaultInitializer, typename Item> 35 struct SVGListTraits { }; 36 37 template<typename ItemPtr> 38 struct SVGListTraits<true, ItemPtr*> { 39 static ItemPtr* nullItem() { return 0; } 40 static bool isNull(ItemPtr* it) { return !it; } 41 }; 42 43 template<typename ItemPtr> 44 struct SVGListTraits<true, RefPtr<ItemPtr> > { 45 static RefPtr<ItemPtr> nullItem() { return 0; } 46 static bool isNull(const RefPtr<ItemPtr>& it) { return !it; } 47 }; 48 49 template<typename Item> 50 struct SVGListTraits<true, Item> { 51 static Item nullItem() { return Item(); } 52 static bool isNull(Item it) { return !it; } 53 }; 54 55 template<> 56 struct SVGListTraits<false, double> { 57 static double nullItem() { return 0.0; } 58 static bool isNull(double) { return false; } 59 }; 60 61 template<> 62 struct SVGListTraits<false, float> { 63 static float nullItem() { return 0; } 64 static bool isNull(float) { return false; } 65 }; 66 67 68 } // namespace WebCore 69 70 #endif // SVG_SUPPORT 71 #endif // SVGListTraits_h 72 73 // vim:ts=4:noet 74