00001 00024 #include "config.h" 00025 #include "libnebular.hpp" 00026 00027 #ifndef LIBNEBULAR_TEMPLATES_HPP_ 00028 #define LIBNEBULAR_TEMPLATES_HPP_ 00029 00030 namespace libnebular{ 00031 00032 template <typename R> void PicturePropContainer::get(const String &key, R &value) const{ 00033 value = castFromPropString<R>( 00034 get<String>(key) 00035 ); 00036 } 00037 template <typename R> void PicturePropContainer::set(const String &key, const R &value){ 00038 set<String>( 00039 key, 00040 castToPropString(value) 00041 ); 00042 } 00043 template <typename R> const R PicturePropContainer::get(const String &key) const{ 00044 return castFromPropString<R>( 00045 get<String>(key) 00046 ); 00047 } 00048 00049 template <typename Value> 00050 void PicturePropContainer::swap(const String &keyA, const String &keyB){ 00051 bool isSetA = isSet(keyA), 00052 isSetB = isSet(keyB); 00053 00054 if(isSetA && isSetB){ 00055 Value valueA = get<Value>(keyA); 00056 Value valueB = get<Value>(keyB); 00057 set(keyA, valueB); 00058 set(keyB, valueA); 00059 }else if(isSetA){ 00060 set( 00061 keyB, 00062 get<Value>(keyA) 00063 ); 00064 unSet(keyA); 00065 }else if(isSetB){ 00066 set( 00067 keyA, 00068 get<Value>(keyB) 00069 ); 00070 unSet(keyB); 00071 } 00072 } 00073 00074 template <typename Value> 00075 void PicturePropContainer::copyFromIfSet(const String &key, const PicturePropContainer &src){ 00076 if(src.isSet(key)){ 00077 set( 00078 key, 00079 src.get<Value>(key) 00080 ); 00081 } 00082 } 00083 00084 00085 } 00086 00087 #endif // LIBNEBULAR_TEMPLATES_HPP_