diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-02-11 12:14:00 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-02-11 12:14:00 (GMT) |
commit | 0efa7c32aaf21a29b42b5926cc116007056843be (patch) | |
tree | 882f663a5dd0e65694bf6077b71086dd77fd7ff8 /3rdParty/Boost/boost/date_time/strings_from_facet.hpp | |
parent | 1d20eabbc32274b491b4c2bedf73d19933d97bfd (diff) | |
download | swift-contrib-0efa7c32aaf21a29b42b5926cc116007056843be.zip swift-contrib-0efa7c32aaf21a29b42b5926cc116007056843be.tar.bz2 |
Moved some modules into separate git modules.
Diffstat (limited to '3rdParty/Boost/boost/date_time/strings_from_facet.hpp')
m--------- | 3rdParty/Boost | 0 | ||||
-rw-r--r-- | 3rdParty/Boost/boost/date_time/strings_from_facet.hpp | 125 |
2 files changed, 0 insertions, 125 deletions
diff --git a/3rdParty/Boost b/3rdParty/Boost new file mode 160000 +Subproject 3bbdbc8cf1996f23d9a366da8bac0f97be6ad79 diff --git a/3rdParty/Boost/boost/date_time/strings_from_facet.hpp b/3rdParty/Boost/boost/date_time/strings_from_facet.hpp deleted file mode 100644 index 2bc26fb..0000000 --- a/3rdParty/Boost/boost/date_time/strings_from_facet.hpp +++ /dev/null @@ -1,125 +0,0 @@ -#ifndef DATE_TIME_STRINGS_FROM_FACET__HPP___ -#define DATE_TIME_STRINGS_FROM_FACET__HPP___ - -/* Copyright (c) 2004 CrystalClear Software, Inc. - * Use, modification and distribution is subject to the - * Boost Software License, Version 1.0. (See accompanying - * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) - * Author: Jeff Garland - * $Date: 2009-02-01 06:29:43 -0500 (Sun, 01 Feb 2009) $ - */ - -#include <sstream> -#include <string> -#include <vector> -#include <locale> - -namespace boost { namespace date_time { - -//! This function gathers up all the month strings from a std::locale -/*! Using the time_put facet, this function creates a collection of - * all the month strings from a locale. This is handy when building - * custom date parsers or formatters that need to be localized. - * - *@param charT The type of char to use when gathering typically char - * or wchar_t. - *@param locale The locale to use when gathering the strings - *@param short_strings True(default) to gather short strings, - * false for long strings. - *@return A vector of strings containing the strings in order. eg: - * Jan, Feb, Mar, etc. - */ -template<typename charT> -std::vector<std::basic_string<charT> > -gather_month_strings(const std::locale& locale, bool short_strings=true) -{ - typedef std::basic_string<charT> string_type; - typedef std::vector<string_type> collection_type; - typedef std::basic_ostringstream<charT> ostream_type; - typedef std::ostreambuf_iterator<charT> ostream_iter_type; - typedef std::basic_ostringstream<charT> stringstream_type; - typedef std::time_put<charT> time_put_facet_type; - charT short_fmt[3] = { '%', 'b' }; - charT long_fmt[3] = { '%', 'B' }; - collection_type months; - string_type outfmt(short_fmt); - if (!short_strings) { - outfmt = long_fmt; - } - { - //grab the needed strings by using the locale to - //output each month - const charT* p_outfmt = outfmt.c_str(), *p_outfmt_end = p_outfmt + outfmt.size(); - for (int m=0; m < 12; m++) { - tm tm_value; - tm_value.tm_mon = m; - stringstream_type ss; - ostream_iter_type oitr(ss); - std::use_facet<time_put_facet_type>(locale).put(oitr, ss, ss.fill(), - &tm_value, - p_outfmt, - p_outfmt_end); - months.push_back(ss.str()); - } - } - return months; -} - -//! This function gathers up all the weekday strings from a std::locale -/*! Using the time_put facet, this function creates a collection of - * all the weekday strings from a locale starting with the string for - * 'Sunday'. This is handy when building custom date parsers or - * formatters that need to be localized. - * - *@param charT The type of char to use when gathering typically char - * or wchar_t. - *@param locale The locale to use when gathering the strings - *@param short_strings True(default) to gather short strings, - * false for long strings. - *@return A vector of strings containing the weekdays in order. eg: - * Sun, Mon, Tue, Wed, Thu, Fri, Sat - */ -template<typename charT> -std::vector<std::basic_string<charT> > -gather_weekday_strings(const std::locale& locale, bool short_strings=true) -{ - typedef std::basic_string<charT> string_type; - typedef std::vector<string_type> collection_type; - typedef std::basic_ostringstream<charT> ostream_type; - typedef std::ostreambuf_iterator<charT> ostream_iter_type; - typedef std::basic_ostringstream<charT> stringstream_type; - typedef std::time_put<charT> time_put_facet_type; - charT short_fmt[3] = { '%', 'a' }; - charT long_fmt[3] = { '%', 'A' }; - - collection_type weekdays; - - - string_type outfmt(short_fmt); - if (!short_strings) { - outfmt = long_fmt; - } - { - //grab the needed strings by using the locale to - //output each month / weekday - const charT* p_outfmt = outfmt.c_str(), *p_outfmt_end = p_outfmt + outfmt.size(); - for (int i=0; i < 7; i++) { - tm tm_value; - tm_value.tm_wday = i; - stringstream_type ss; - ostream_iter_type oitr(ss); - std::use_facet<time_put_facet_type>(locale).put(oitr, ss, ss.fill(), - &tm_value, - p_outfmt, - p_outfmt_end); - - weekdays.push_back(ss.str()); - } - } - return weekdays; -} - -} } //namespace - - -#endif |