Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00026
00027 #ifndef ICL_CORE_KEY_VALUE_DIRECTORY_HPP_INCLUDED
00028 #define ICL_CORE_KEY_VALUE_DIRECTORY_HPP_INCLUDED
00029
00030 #include "icl_core/KeyValueDirectory.h"
00031
00032 namespace icl_core {
00033
00034 template <typename T>
00035 KeyValueDirectoryIterator<T> KeyValueDirectory<T>::find(const String& query) const
00036 {
00037 return KeyValueDirectoryIterator<T> (query, this);
00038 }
00039
00040 template <typename T>
00041 bool KeyValueDirectory<T>::get(const String& key, typename ConvertToRef<T>::ToRef value) const
00042 {
00043 typename KeyValueMap::const_iterator find_it = m_items.find(key);
00044 if (find_it != m_items.end())
00045 {
00046 value = find_it->second;
00047 return true;
00048 }
00049 else
00050 {
00051 return false;
00052 }
00053 }
00054
00055 template <typename T>
00056 bool KeyValueDirectory<T>::hasKey(const String &key) const
00057 {
00058 typename KeyValueMap::const_iterator find_it = m_items.find(key);
00059 return find_it != m_items.end();
00060 }
00061
00062 template <typename T>
00063 bool KeyValueDirectory<T>::insert(const String& key, typename ConvertToRef<T>::ToConstRef value)
00064 {
00065 typename KeyValueMap::const_iterator find_it = m_items.find(key);
00066 m_items[key] = value;
00067 return find_it == m_items.end();
00068 }
00069
00070 template <typename T>
00071 KeyValueDirectoryIterator<T>::KeyValueDirectoryIterator(const String& query,
00072 const KeyValueDirectory<T> *directory)
00073 : m_directory(directory),
00074 m_query(query)
00075 {
00076 reset();
00077 }
00078
00079 template <typename T>
00080 String KeyValueDirectoryIterator<T>::key() const
00081 {
00082 return m_current_entry->first;
00083 }
00084
00085 template <typename T>
00086 String KeyValueDirectoryIterator<T>::matchGroup(size_t index) const
00087 {
00088 if (index < m_current_results.size())
00089 {
00090 return m_current_results[int(index)];
00091 }
00092 else
00093 {
00094 return "";
00095 }
00096 }
00097
00098 template <typename T>
00099 bool KeyValueDirectoryIterator<T>::next()
00100 {
00101
00102
00103 if (m_reset == true)
00104 {
00105 m_reset = false;
00106 m_current_entry = m_directory->m_items.begin();
00107 }
00108
00109 else
00110 {
00111 ++m_current_entry;
00112 }
00113
00114
00115 while (m_current_entry != m_directory->m_items.end() &&
00116 !::boost::regex_match(m_current_entry->first, m_current_results, m_query))
00117 {
00118 ++m_current_entry;
00119 }
00120
00121
00122 return m_current_entry != m_directory->m_items.end();
00123 }
00124
00125 template <typename T>
00126 void KeyValueDirectoryIterator<T>::reset()
00127 {
00128 m_reset = true;
00129 }
00130
00131 template <typename T>
00132 typename ConvertToRef<T>::ToConstRef KeyValueDirectoryIterator<T>::value() const
00133 {
00134 return m_current_entry->second;
00135 }
00136
00138 #ifdef _IC_BUILDER_DEPRECATED_STYLE_
00139
00140 template <typename T>
00141 ICL_CORE_VC_DEPRECATE_STYLE KeyValueDirectoryIterator<T> KeyValueDirectory<T>::Find(const String& query) const
00142 {
00143 return find(query);
00144 }
00145
00146 template <typename T>
00147 ICL_CORE_VC_DEPRECATE_STYLE bool KeyValueDirectory<T>::Get(const String& key,
00148 typename ConvertToRef<T>::ToRef value) const
00149 {
00150 return get(key, value);
00151 }
00152
00153 template <typename T>
00154 ICL_CORE_VC_DEPRECATE_STYLE bool KeyValueDirectory<T>::HasKey(const String &key) const
00155 {
00156 return hasKey(key);
00157 }
00158
00159 template <typename T>
00160 ICL_CORE_VC_DEPRECATE_STYLE bool KeyValueDirectory<T>::Insert(const String& key,
00161 typename ConvertToRef<T>::ToConstRef value)
00162 {
00163 return insert(key, value);
00164 }
00165
00166 template <typename T>
00167 ICL_CORE_VC_DEPRECATE_STYLE String KeyValueDirectoryIterator<T>::Key() const
00168 {
00169 return key();
00170 }
00171
00172 template <typename T>
00173 ICL_CORE_VC_DEPRECATE_STYLE String KeyValueDirectoryIterator<T>::MatchGroup(size_t index) const
00174 {
00175 return matchGroup(index);
00176 }
00177
00178 template <typename T>
00179 ICL_CORE_VC_DEPRECATE_STYLE bool KeyValueDirectoryIterator<T>::Next()
00180 {
00181 return next();
00182 }
00183
00184 template <typename T>
00185 ICL_CORE_VC_DEPRECATE_STYLE void KeyValueDirectoryIterator<T>::Reset()
00186 {
00187 reset();
00188 }
00189
00190 template <typename T>
00191 ICL_CORE_VC_DEPRECATE_STYLE typename ConvertToRef<T>::ToConstRef KeyValueDirectoryIterator<T>::Value() const
00192 {
00193 return value();
00194 }
00195
00196 #endif
00197
00198
00199 }
00200
00201 #endif