38 #ifndef OME_BIOFORMATS_METADATAMAP_H
39 #define OME_BIOFORMATS_METADATAMAP_H
99 typedef boost::mpl::vector<std::string,
103 typedef boost::mpl::vector<uint8_t,
113 typedef boost::mpl::vector<float,
134 typedef boost::mpl::transform_view<basic_types_view, make_vector<boost::mpl::_1> >::type
list_types_view;
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;
191 const value_type& value)
193 iterator i =
find(key);
196 map_type::value_type newvalue(key, value);
209 template <
typename T>
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_iterator i = map.
begin();
449 map_type::value_type v(prefix + i->first, i->second);
496 return discriminating_map.begin();
507 return discriminating_map.begin();
518 return discriminating_map.end();
529 return discriminating_map.end();
540 return discriminating_map.rbegin();
548 const_reverse_iterator
551 return discriminating_map.rbegin();
562 return discriminating_map.rend();
570 const_reverse_iterator
573 return discriminating_map.rend();
589 return discriminating_map[key];
677 return discriminating_map.size();
688 return discriminating_map.empty();
699 return discriminating_map.clear();
730 template <
typename T>
734 for (
typename std::vector<T>::const_iterator i = c.begin();
739 if (i + 1 != c.end())
749 template <
typename T>
789 template <
typename T>
793 typename std::vector<T>::size_type idx = 1;
795 int sf =
static_cast<int>(std::log10(static_cast<float>(c.size()))) + 1;
796 for (
typename std::vector<T>::const_iterator i = c.begin();
800 os << key <<
" #" << std::setw(sf) << std::setfill(
'0') << std::right << idx <<
" = " << *i <<
'\n';
812 template <
typename T>
816 os << key <<
" = " << v <<
'\n';
852 template <
typename T>
856 typename std::vector<T>::size_type idx = 1;
858 int sf =
static_cast<int>(std::log10(static_cast<float>(c.size()))) + 1;
859 for (
typename std::vector<T>::const_iterator i = c.begin();
863 std::ostringstream os;
864 os << key <<
" #" << std::setw(sf) << std::setfill(
'0') << std::right << idx;
865 map.
set(os.str(), *i);
877 template <
typename T>
900 MetadataMap::get<MetadataMap::value_type>(
const key_type& key)
902 map_type::iterator i = discriminating_map.find(key);
903 if (i == discriminating_map.end())
904 throw boost::bad_get();
922 MetadataMap::get<MetadataMap::value_type>(
const key_type& key)
const
924 map_type::const_iterator i = discriminating_map.find(key);
925 if (i == discriminating_map.end())
926 throw boost::bad_get();
958 template<
class charT,
class traits>
959 inline basic_ostream<charT,traits>&
960 operator<< (basic_ostream<charT,traits>& os,
961 const ::ome::bioformats::MetadataMap::value_type& vt)
974 template<
class charT,
class traits>
975 inline basic_ostream<charT,traits>&
976 operator<< (basic_ostream<charT,traits>& os,
977 const ::ome::bioformats::MetadataMap& map)
990 #endif // OME_BIOFORMATS_METADATAMAP_H
Visitor template for output of MetadataMap values to an ostream.
Definition: MetadataMap.h:760
MetadataMapOStreamVisitor(std::ostream &os, const MetadataMap::key_type &key)
Constructor.
Definition: MetadataMap.h:773
Variant type limit workaround.
Open Microscopy Environment C++ implementation.
Definition: CoreMetadata.cpp:40
void operator()(const std::vector< T > &c) const
Output a vector value of arbitrary type.
Definition: MetadataMap.h:791
const MetadataMap::key_type & key
The key of the value being output.
Definition: MetadataMap.h:765
std::ostream & os
The stream to output to.
Definition: MetadataMap.h:763