Beispiel #1
0
awl::backends::x11::visual::object_unique_ptr
awl::backends::x11::visual::default_(
	awl::backends::x11::display &_display,
	awl::backends::x11::screen const _screen
)
{
	Visual *const visual(
		::XDefaultVisual(
			_display.get(),
			_screen.get()
		)
	);

	FCPPT_ASSERT_POST(
		visual,
		awl::exception
	);

	return
		awl::backends::x11::visual::object_unique_ptr(
			fcppt::make_unique_ptr<
				awl::backends::x11::visual::wrapped
			>(
				awl::backends::x11::visual::create_info(
					_display,
					*visual
				)
			)
		);
}
Beispiel #2
0
ALCcontext *
sge::openal::funcs::alc_create_context(
    ALCdevice &_device
)
{
    std::array<
    ALCint,
    1u
    > const attributes = {{
            0
        }
    };

    ALCcontext *const result(
        ::alcCreateContext(
            &_device,
            attributes.data()
        )
    );

    SGE_OPENAL_CHECK_ALC_STATE(
        _device,
        FCPPT_TEXT("alcCreateContext failed"),
        sge::audio::exception
    )

    FCPPT_ASSERT_POST(
        result,
        sge::audio::exception
    );

    return
        result;
}
Beispiel #3
0
fcppt::string
fcppt::filesystem::file_to_string(
	boost::filesystem::path const &_path
)
{
	fcppt::io::ifstream stream(
		_path
	);

	if(
		!stream.is_open()
	)
		throw fcppt::filesystem::exception(
			FCPPT_TEXT("Unable to open file ")
			+ fcppt::filesystem::path_to_string(
				_path
			)
		);

	boost::uintmax_t const size(
		boost::filesystem::file_size(
			_path
		)
	);

	if(
		!check_size<
			fcppt::string::size_type
		>(
			size
		)
	)
		throw fcppt::filesystem::exception(
			fcppt::filesystem::path_to_string(
				_path
			)
			+ FCPPT_TEXT(" is too large for a string to store!")
		);

	fcppt::string ret;

	ret.reserve(
		fcppt::cast::size<
			fcppt::string::size_type
		>(
			size
		)
	);

	ret.assign(
		std::istreambuf_iterator<
			fcppt::char_type
		>(
			stream
		),
		std::istreambuf_iterator<
			fcppt::char_type
		>()
	);

	FCPPT_ASSERT_POST(
		stream.eof(),
		fcppt::assert_::exception
	);

	return
		ret;
}