void to_view_test()
{
   const boost::container::string s = "some text";
   boost::string_view sv(s.to_view<boost::string_view>());
   BOOST_TEST(s.data() == sv.data() && s.size() == sv.size());
   boost::string_view sv2;
   sv2 = s.to_view<boost::string_view>();
   BOOST_TEST(s.data() == sv2.data() && s.size() == sv2.size());
   const boost::string_view csv(s.to_view<boost::string_view>());
   BOOST_TEST(s.data() == csv.data() && s.size() == csv.size());
}
示例#2
0
std::string get_directory_listing( boost::string_view folder ) {
	namespace fs = boost::filesystem;
	fs::path p { folder.to_string( ) };
	std::ostringstream ss;
	try {
		if( exists( p ) ) {
			if( fs::is_regular_file( p ) ) {
				ss <<p <<" size is " <<fs::file_size( p ) <<"\r\n";
			} else if( fs::is_directory( p ) ) {
				ss <<p <<" is a directory containing:\n";
				std::copy( fs::directory_iterator( p ), fs::directory_iterator( ), std::ostream_iterator<fs::directory_entry>( ss, "\r\n" ) );
			} else {
				ss <<p <<" exists, but is neither a regular file nor a directory\n";
			}
		} else {
			ss <<p <<" does not exist\n";
		}
	}

	catch( const fs::filesystem_error& ex ) {
		ss <<"ERROR: " <<ex.what( ) <<'\n';
	}

	return ss.str( );
}
示例#3
0
 inline auto get_text_extent_point(::HDC const hDC, boost::string_view const str) {
     SIZE size;
     GetTextExtentPoint32(hDC, str.data(), str.size(), &size);
     return size;
 }