123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- #ifndef DATETIME_SPECIAL_VALUE_FORMATTER_HPP___
- #define DATETIME_SPECIAL_VALUE_FORMATTER_HPP___
- #include <vector>
- #include <string>
- #include "boost/date_time/special_defs.hpp"
- namespace boost { namespace date_time {
-
-
- template <class CharT, class OutItrT = std::ostreambuf_iterator<CharT, std::char_traits<CharT> > >
- class special_values_formatter
- {
- public:
- typedef std::basic_string<CharT> string_type;
- typedef CharT char_type;
- typedef std::vector<string_type> collection_type;
- static const char_type default_special_value_names[3][17];
-
-
- special_values_formatter()
- {
- std::copy(&default_special_value_names[0],
- &default_special_value_names[3],
- std::back_inserter(m_special_value_names));
- }
-
-
- special_values_formatter(const char_type* const* begin, const char_type* const* end)
- {
- std::copy(begin, end, std::back_inserter(m_special_value_names));
- }
- special_values_formatter(typename collection_type::iterator beg, typename collection_type::iterator end)
- {
- std::copy(beg, end, std::back_inserter(m_special_value_names));
- }
- OutItrT put_special(OutItrT next,
- const boost::date_time::special_values& value) const
- {
-
- unsigned int index = value;
- if (index < m_special_value_names.size()) {
- std::copy(m_special_value_names[index].begin(),
- m_special_value_names[index].end(),
- next);
- }
- return next;
- }
- protected:
- collection_type m_special_value_names;
- };
-
-
- template <class CharT, class OutItrT>
- const typename special_values_formatter<CharT, OutItrT>::char_type special_values_formatter<CharT, OutItrT>::default_special_value_names[3][17] = {
- {'n','o','t','-','a','-','d','a','t','e','-','t','i','m','e'},
- {'-','i','n','f','i','n','i','t','y'},
- {'+','i','n','f','i','n','i','t','y'} };
- } }
- #endif
|