|
||||
File indexing completed on 2025-01-18 09:52:43
0001 // (C) Copyright Gennadiy Rozental 2001. 0002 // Distributed under the Boost Software License, Version 1.0. 0003 // (See accompanying file LICENSE_1_0.txt or copy at 0004 // http://www.boost.org/LICENSE_1_0.txt) 0005 0006 // See http://www.boost.org/libs/test for the library home page. 0007 // 0008 // File : $RCSfile$ 0009 // 0010 // Version : $Revision$ 0011 // 0012 // Description : trivial utility to cast to/from strings 0013 // *************************************************************************** 0014 0015 #ifndef BOOST_TEST_UTILS_STRING_CAST_HPP 0016 #define BOOST_TEST_UTILS_STRING_CAST_HPP 0017 0018 // Boost.Test 0019 #include <boost/test/utils/basic_cstring/basic_cstring.hpp> 0020 0021 // STL 0022 #include <sstream> 0023 0024 #include <boost/test/detail/suppress_warnings.hpp> 0025 0026 //____________________________________________________________________________// 0027 0028 namespace boost { 0029 namespace unit_test { 0030 namespace utils { 0031 0032 // ************************************************************************** // 0033 // ************** string_cast ************** // 0034 // ************************************************************************** // 0035 0036 template<typename T> 0037 inline std::string 0038 string_cast( T const& t ) 0039 { 0040 std::ostringstream buff; 0041 buff << t; 0042 return buff.str(); 0043 } 0044 0045 //____________________________________________________________________________// 0046 0047 // ************************************************************************** // 0048 // ************** string_as ************** // 0049 // ************************************************************************** // 0050 0051 template<typename T> 0052 inline bool 0053 string_as( const_string str, T& res ) 0054 { 0055 std::istringstream buff( std::string( str.begin(), str.end() ) ); 0056 buff >> res; 0057 0058 return !buff.fail() && buff.eof(); 0059 } 0060 0061 //____________________________________________________________________________// 0062 0063 } // namespace utils 0064 } // namespace unit_test 0065 } // namespace boost 0066 0067 #include <boost/test/detail/enable_warnings.hpp> 0068 0069 #endif // BOOST_TEST_UTILS_STRING_CAST_HPP
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |