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;
143 typedef boost::mpl::insert_range<empty_types, boost::mpl::end<empty_types>::type, all_types_view>::type
discriminated_types;
150 typedef boost::make_variant_over<discriminated_types>::type
value_type;
194 const value_type& value)
196 iterator i =
find(key);
199 map_type::value_type newvalue(key, value);
212 template <
typename T>
217 value_type v = value;
231 template <
typename T>
236 typedef typename std::vector<T> list_type;
240 list_type& list(get<list_type>(key));
241 list.push_back(value);
243 catch (boost::bad_get& e)
246 new_list.push_back(value);
261 get(
const key_type& key,
262 value_type& value)
const
264 const_iterator i =
find(key);
283 template <
typename T>
285 get(
const key_type& key,
293 catch (boost::bad_get& e)
310 template <
typename T>
312 get(
const key_type& key)
314 return boost::get<T>(get<value_type>(key));
328 template <
typename T>
330 get(
const key_type& key)
const
332 return boost::get<T>(get<value_type>(key));
344 return discriminating_map.find(key);
354 find(
const key_type& key)
const
356 return discriminating_map.find(key);
372 std::pair<iterator, bool>
375 return discriminating_map.insert(value);
386 discriminating_map.erase(key);
397 discriminating_map.erase(pos);
410 template <
typename T>
427 std::vector<key_type>
430 std::vector<key_type> ret;
431 std::transform(
begin(),
end(), std::back_inserter(ret),
getkey());
432 std::sort(ret.begin(), ret.end());
446 const std::string& prefix)
448 for (const_iterator i = map.
begin();
452 map_type::value_type v(prefix + i->first, i->second);
499 return discriminating_map.begin();
510 return discriminating_map.begin();
521 return discriminating_map.end();
532 return discriminating_map.end();
543 return discriminating_map.rbegin();
551 const_reverse_iterator
554 return discriminating_map.rbegin();
565 return discriminating_map.rend();
573 const_reverse_iterator
576 return discriminating_map.rend();
592 return discriminating_map[key];
680 return discriminating_map.size();
691 return discriminating_map.empty();
702 return discriminating_map.clear();
733 template <
typename T>
737 for (
typename std::vector<T>::const_iterator i = c.begin();
742 if (i + 1 != c.end())
752 template <
typename T>
792 template <
typename T>
796 typename std::vector<T>::size_type idx = 1;
798 int sf =
static_cast<int>(std::log10(static_cast<float>(c.size()))) + 1;
799 for (
typename std::vector<T>::const_iterator i = c.begin();
803 os << key <<
" #" << std::setw(sf) << std::setfill(
'0') << std::right << idx <<
" = " << *i <<
'\n';
815 template <
typename T>
819 os << key <<
" = " << v <<
'\n';
855 template <
typename T>
859 typename std::vector<T>::size_type idx = 1;
861 int sf =
static_cast<int>(std::log10(static_cast<float>(c.size()))) + 1;
862 for (
typename std::vector<T>::const_iterator i = c.begin();
866 std::ostringstream os;
867 os << key <<
" #" << std::setw(sf) << std::setfill(
'0') << std::right << idx;
868 map.
set(os.str(), *i);
880 template <
typename T>
903 MetadataMap::get<MetadataMap::value_type>(
const key_type& key)
905 map_type::iterator i = discriminating_map.find(key);
906 if (i == discriminating_map.end())
907 throw boost::bad_get();
925 MetadataMap::get<MetadataMap::value_type>(
const key_type& key)
const
927 map_type::const_iterator i = discriminating_map.find(key);
928 if (i == discriminating_map.end())
929 throw boost::bad_get();
961 template<
class charT,
class traits>
962 inline basic_ostream<charT,traits>&
963 operator<< (basic_ostream<charT,traits>& os,
964 const ::ome::bioformats::MetadataMap::value_type& vt)
977 template<
class charT,
class traits>
978 inline basic_ostream<charT,traits>&
979 operator<< (basic_ostream<charT,traits>& os,
980 const ::ome::bioformats::MetadataMap& map)
993 #endif // OME_BIOFORMATS_METADATAMAP_H
Visitor template for output of MetadataMap values to an ostream.
Definition: MetadataMap.h:763
MetadataMapOStreamVisitor(std::ostream &os, const MetadataMap::key_type &key)
Constructor.
Definition: MetadataMap.h:776
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:794
const MetadataMap::key_type & key
The key of the value being output.
Definition: MetadataMap.h:768
std::ostream & os
The stream to output to.
Definition: MetadataMap.h:766