00001 #pragma once 00002 00003 #ifndef STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 00004 #define STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 00005 00006 00007 #include <vector> 00008 #include <list> 00009 #include <map> 00010 00011 namespace YAML 00012 { 00013 template <typename T> 00014 inline Emitter& operator << (Emitter& emitter, const std::vector <T>& v) { 00015 typedef typename std::vector <T> vec; 00016 emitter << BeginSeq; 00017 for(typename vec::const_iterator it=v.begin();it!=v.end();++it) 00018 emitter << *it; 00019 emitter << EndSeq; 00020 return emitter; 00021 } 00022 00023 template <typename T> 00024 inline Emitter& operator << (Emitter& emitter, const std::list <T>& v) { 00025 typedef typename std::list <T> list; 00026 emitter << BeginSeq; 00027 for(typename list::const_iterator it=v.begin();it!=v.end();++it) 00028 emitter << *it; 00029 emitter << EndSeq; 00030 return emitter; 00031 } 00032 00033 template <typename K, typename V> 00034 inline Emitter& operator << (Emitter& emitter, const std::map <K, V>& m) { 00035 typedef typename std::map <K, V> map; 00036 emitter << BeginMap; 00037 for(typename map::const_iterator it=m.begin();it!=m.end();++it) 00038 emitter << Key << it->first << Value << it->second; 00039 emitter << EndMap; 00040 return emitter; 00041 } 00042 } 00043 00044 #endif // STLEMITTER_H_62B23520_7C8E_11DE_8A39_0800200C9A66