00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00024 #ifndef SH_METAIMPL_HPP
00025 #define SH_METAIMPL_HPP
00026
00027 #include "ShMeta.hpp"
00028
00029 namespace SH {
00030
00031 inline ShMeta::ShMeta(const ShMeta &other)
00032 : m_meta(0)
00033 {
00034 if(other.m_meta) {
00035 m_meta = new MetaMap();
00036 *m_meta = *other.m_meta;
00037 }
00038 }
00039
00040 inline ShMeta::~ShMeta()
00041 {
00042 if(m_meta) delete m_meta;
00043 }
00044
00045 inline std::string ShMeta::name() const
00046 {
00047 return meta("n");
00048 }
00049
00050 inline void ShMeta::name(const std::string& n)
00051 {
00052 meta("n", n);
00053 }
00054
00055 inline bool ShMeta::has_name() const
00056 {
00057 return !meta("n").empty();
00058 }
00059
00060 inline bool ShMeta::internal() const
00061 {
00062 return !meta("i").empty();
00063 }
00064
00065 inline void ShMeta::internal(bool i)
00066 {
00067 meta("i", i ? "1" : "");
00068 }
00069
00070 inline std::string ShMeta::title() const
00071 {
00072 return meta("t");
00073 }
00074
00075 inline void ShMeta::title(const std::string& t)
00076 {
00077 meta("t", t);
00078 }
00079
00080 inline std::string ShMeta::description() const
00081 {
00082 return meta("d");
00083 }
00084
00085 inline void ShMeta::description(const std::string& d)
00086 {
00087 meta("d", d);
00088 }
00089
00090 inline std::string ShMeta::meta(const std::string& key) const
00091 {
00092 if(!m_meta) return std::string();
00093
00094 MetaMap::const_iterator I = m_meta->find(key);
00095 if (I == m_meta->end()) return std::string();
00096 return I->second;
00097 }
00098
00099 inline void ShMeta::meta(const std::string& key, const std::string& value)
00100 {
00101 if(!m_meta) m_meta = new MetaMap();
00102 (*m_meta)[key] = value;
00103 }
00104
00105 inline bool ShMeta::has_meta(const std::string& key) const
00106 {
00107 return m_meta && (m_meta->find(key) != m_meta->end());
00108 }
00109
00110 }
00111
00112 #endif
00113