1#if !defined(HIDDEN_FROM_DOC)
2#if !defined _SB_CONST_CHAR_MAP_H_
3#define _SB_CONST_CHAR_MAP_H_
26#include <Inventor/STL/map>
27#include <Inventor/STL/functional>
48 bool operator() (
const char* str1,
const char* str2)
const
52 return strcmp(str1, str2) < 0;
57 typedef typename std::map<const char*, T , StrCompare> UniformMap;
58 typedef typename UniformMap::value_type value_type;
59 typedef typename UniformMap::iterator iterator;
60 typedef typename UniformMap::const_iterator const_iterator;
63 const_iterator begin()
const
64 {
return m_uniforms.begin(); }
68 {
return m_uniforms.begin(); }
71 const_iterator end()
const
72 {
return m_uniforms.end(); }
76 {
return m_uniforms.end(); }
80 {
return m_uniforms.empty(); }
84 {
return m_uniforms.size(); }
87 iterator find(
const char* key)
88 {
return m_uniforms.find(key); }
91 const_iterator find(
const char* key)
const
92 {
return m_uniforms.find(key); }
95 iterator erase (iterator it)
97 free((
void*)it->first);
98 return m_uniforms.erase(it);
104 iterator it = m_uniforms.begin();
105 while(it!=m_uniforms.end())
107 free((
void*)it->first);
114 T& operator[] (
const char* name )
116 iterator it = find(name);
120 return m_uniforms[_strdup(name)];
122 return m_uniforms[strdup(name)];
126 return ((*it).second);
130 SbConstCharMap<T>& operator=(
const SbConstCharMap<T>& copyFrom)
135 iterator insertedIt = begin();
136 const_iterator it = copyFrom.begin();
137 while(it!=copyFrom.end())
140 insertedIt = m_uniforms.insert(insertedIt,value_type(_strdup((*it).first),(*it).second));
142 insertedIt = m_uniforms.insert(insertedIt,value_type(strdup((*it).first),(*it).second));
150 friend int operator !=(
const SbConstCharMap<T>& map1,
const SbConstCharMap<T>& map2)
151 {
return !(map1==map2); }
154 friend int operator ==(
const SbConstCharMap<T>& map1,
const SbConstCharMap<T>& map2)
156 if ( map1.size() != map2.size() )
159 const const_iterator itEnd1 = map1.end();
160 const_iterator it1 = map1.begin();
161 const_iterator it2 = map2.begin();
162 for (; it1 != itEnd1; ++it1, ++it2)
164 if ( it1->second != it2->second )
169 else if ( strcmp(it1->first, it2->first) != 0 )
177 UniformMap m_uniforms;