string_convert.hpp 1002 B

1234567891011121314151617181920212223242526272829303132
  1. #ifndef _STRING_CONVERT_HPP___
  2. #define _STRING_CONVERT_HPP___
  3. /* Copyright (c) 2005 CrystalClear Software, Inc.
  4. * Subject to the Boost Software License, Version 1.0. (See accompanying
  5. * file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
  6. * Author: Jeff Garland, Bart Garst
  7. * $Date$
  8. */
  9. #include "boost/date_time/compiler_config.hpp"
  10. #include <string>
  11. namespace boost {
  12. namespace date_time {
  13. //! Converts a string from one value_type to another
  14. /*! Converts a wstring to a string (or a string to wstring). If both template parameters
  15. * are of same type, a copy of the input string is returned. */
  16. template<class InputT, class OutputT>
  17. inline
  18. std::basic_string<OutputT> convert_string_type(const std::basic_string<InputT>& inp_str)
  19. {
  20. typedef std::basic_string<OutputT> output_type;
  21. output_type result;
  22. result.insert(result.begin(), inp_str.begin(), inp_str.end());
  23. return result;
  24. }
  25. }} // namespace boost::date_time
  26. #endif // _STRING_CONVERT_HPP___