38 #ifndef OME_FILES_METADATAMAP_H 39 #define OME_FILES_METADATAMAP_H 99 typedef boost::mpl::vector<std::string,
103 typedef boost::mpl::vector<uint8_t,
113 typedef boost::mpl::vector<float,
137 typedef boost::mpl::joint_view<basic_types_view, list_types_view>
all_types_view;
140 typedef boost::mpl::insert_range<boost::mpl::vector0<>, boost::mpl::end<boost::mpl::vector0<>>
::type, all_types_view>::type
discriminated_types;
147 typedef boost::make_variant_over<discriminated_types>::type
value_type;
190 set(
const key_type& key,
191 const value_type& value)
193 iterator i =
find(key);
196 map_type::value_type newvalue(key, value);
209 template <
typename T>
211 set(
const key_type& key,
214 value_type v = value;
228 template <
typename T>
233 typedef typename std::vector<T> list_type;
237 list_type& list(get<list_type>(key));
238 list.push_back(value);
240 catch (
const boost::bad_get&)
243 new_list.push_back(value);
258 get(
const key_type& key,
259 value_type& value)
const 261 const_iterator i =
find(key);
280 template <
typename T>
282 get(
const key_type& key,
290 catch (
const boost::bad_get&)
307 template <
typename T>
309 get(
const key_type& key)
311 return boost::get<T>(get<value_type>(key));
325 template <
typename T>
327 get(
const key_type& key)
const 329 return boost::get<T>(get<value_type>(key));
341 return discriminating_map.find(key);
351 find(
const key_type& key)
const 353 return discriminating_map.find(key);
369 std::pair<iterator, bool>
372 return discriminating_map.insert(value);
383 discriminating_map.erase(key);
394 discriminating_map.erase(pos);
407 template <
typename T>
424 std::vector<key_type>
427 std::vector<key_type> ret;
428 std::transform(
begin(),
end(), std::back_inserter(ret),
getkey());
429 std::sort(ret.begin(), ret.end());
443 const std::string& prefix)
445 for (
const auto& m : map)
447 map_type::value_type v(prefix + m.first, m.second);
494 return discriminating_map.begin();
505 return discriminating_map.begin();
516 return discriminating_map.end();
527 return discriminating_map.end();
538 return discriminating_map.rbegin();
546 const_reverse_iterator
549 return discriminating_map.rbegin();
560 return discriminating_map.rend();
568 const_reverse_iterator
571 return discriminating_map.rend();
587 return discriminating_map[key];
675 return discriminating_map.size();
686 return discriminating_map.empty();
697 return discriminating_map.clear();
728 template <
typename T>
730 operator() (
const std::vector<T> & c)
const 732 for (
typename std::vector<T>::const_iterator i = c.begin();
737 if (i + 1 != c.end())
747 template <
typename T>
749 operator() (
const T& v)
const 787 template <
typename T>
789 operator() (
const std::vector<T> & c)
const 791 typename std::vector<T>::size_type idx = 1;
793 int sf =
static_cast<int>(std::log10(static_cast<float>(c.size()))) + 1;
794 for (
typename std::vector<T>::const_iterator i = c.begin();
798 os << key <<
" #" << std::setw(sf) << std::setfill(
'0') << std::right << idx <<
" = " << *i <<
'\n';
810 template <
typename T>
812 operator() (
const T& v)
const 814 os << key <<
" = " << v <<
'\n';
850 template <
typename T>
852 operator() (
const std::vector<T> & c)
const 854 typename std::vector<T>::size_type idx = 1;
856 int sf =
static_cast<int>(std::log10(static_cast<float>(c.size()))) + 1;
857 for (
typename std::vector<T>::const_iterator i = c.begin();
861 std::ostringstream os;
862 os << key <<
" #" << std::setw(sf) << std::setfill(
'0') << std::right << idx;
863 map.
set(os.str(), *i);
875 template <
typename T>
877 operator() (
const T& v)
const 898 MetadataMap::get<MetadataMap::value_type>(
const key_type& key)
902 throw boost::bad_get();
920 MetadataMap::get<MetadataMap::value_type>(
const key_type& key)
const 924 throw boost::bad_get();
954 template<
class charT,
class traits>
955 inline basic_ostream<charT,traits>&
956 operator<< (basic_ostream<charT,traits>& os,
957 const ::ome::files::MetadataMap::value_type& vt)
970 template<
class charT,
class traits>
971 inline basic_ostream<charT,traits>&
972 operator<< (basic_ostream<charT,traits>& os,
973 const ::ome::files::MetadataMap&
map)
975 for (
const auto& m :
map)
984 #endif // OME_FILES_METADATAMAP_H
Visitor template for output of MetadataMap values to an ostream.
Definition: MetadataMap.h:758
MetadataMapOStreamVisitor(std::ostream &os, const MetadataMap::key_type &key)
Constructor.
Definition: MetadataMap.h:771
Open Microscopy Environment C++.
const MetadataMap::key_type & key
The key of the value being output.
Definition: MetadataMap.h:763
std::ostream & os
The stream to output to.
Definition: MetadataMap.h:761