The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Namespaces | Macros | Functions
lexical_cast.hpp File Reference

New lexcical_cast header. More...

#include "global.hpp"
#include <cstdlib>
#include <string>
#include <sstream>
#include <boost/mpl/set.hpp>
#include <boost/type_traits.hpp>
#include <boost/utility/enable_if.hpp>
Include dependency graph for lexical_cast.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  implementation::tlexical_cast< To, From, ToEnable, FromEnable >
 Base class for the conversion. More...
 
struct  bad_lexical_cast
 Thrown when a lexical_cast fails. More...
 
struct  implementation::tlexical_cast< To, From, ToEnable, FromEnable >
 Base class for the conversion. More...
 
struct  implementation::tlexical_cast< std::string, From, void, typename boost::enable_if< boost::is_integral< typename boost::remove_pointer< From >::type > >::type >
 Specialized conversion class. More...
 
struct  implementation::tlexical_cast< long long, From, void, typename boost::enable_if< boost::mpl::has_key< boost::mpl::set< char *, const char * >, From > >::type >
 Specialized conversion class. More...
 
struct  implementation::tlexical_cast< long long, std::string >
 Specialized conversion class. More...
 
struct  implementation::tlexical_cast< To, From, typename boost::enable_if< boost::is_signed< To > >::type, typename boost::enable_if< boost::mpl::has_key< boost::mpl::set< char *, const char * >, From > >::type >
 Specialized conversion class. More...
 
struct  implementation::tlexical_cast< To, std::string, typename boost::enable_if< boost::is_signed< To > >::type >
 Specialized conversion class. More...
 
struct  implementation::tlexical_cast< unsigned long long, From, void, typename boost::enable_if< boost::mpl::has_key< boost::mpl::set< char *, const char * >, From > >::type >
 Specialized conversion class. More...
 
struct  implementation::tlexical_cast< unsigned long long, std::string >
 Specialized conversion class. More...
 
struct  implementation::tlexical_cast< To, From, typename boost::enable_if< boost::is_unsigned< To > >::type, typename boost::enable_if< boost::mpl::has_key< boost::mpl::set< char *, const char * >, From > >::type >
 Specialized conversion class. More...
 
struct  implementation::tlexical_cast< To, std::string, typename boost::enable_if< boost::is_unsigned< To > >::type >
 Specialized conversion class. More...
 

Namespaces

 implementation
 Contains the implementation details for lexical_cast and shouldn't be used directly.
 

Macros

#define LEXICAL_CAST_HPP_INCLUDED
 
#define DEBUG_THROW(id)
 Throws an exception for debugging. More...
 
#define LEXICAL_CAST_HPP_INCLUDED
 
#define DEBUG_THROW(id)   throw id;
 

Functions

template<typename To , typename From >
To lexical_cast (From value)
 Lexical cast converts one type to another. More...
 

Detailed Description

New lexcical_cast header.

For debugging you can include this header in a namespace (to honor ODR) and have a set of functions that throws exceptions instead of doing the real job. This is done for the unit tests but should normally not be done.

Definition in file lexical_cast.hpp.

Macro Definition Documentation

#define DEBUG_THROW (   id)    throw id;
#define DEBUG_THROW (   id)

Throws an exception for debugging.

Parameters
idThe unique name to identify the function.
Note
this name is a user defined string and should not be modified once used!

Definition at line 42 of file test_lexical_cast.cpp.

Referenced by implementation::tlexical_cast< To, From, ToEnable, FromEnable >::operator()(), implementation::tlexical_cast< std::string, From, void, typename boost::enable_if< boost::is_integral< typename boost::remove_pointer< From >::type > >::type >::operator()(), implementation::tlexical_cast< long long, From, void, typename boost::enable_if< boost::mpl::has_key< boost::mpl::set< char *, const char * >, From > >::type >::operator()(), implementation::tlexical_cast< long long, std::string >::operator()(), implementation::tlexical_cast< To, From, typename boost::enable_if< boost::is_signed< To > >::type, typename boost::enable_if< boost::mpl::has_key< boost::mpl::set< char *, const char * >, From > >::type >::operator()(), implementation::tlexical_cast< To, std::string, typename boost::enable_if< boost::is_signed< To > >::type >::operator()(), implementation::tlexical_cast< unsigned long long, From, void, typename boost::enable_if< boost::mpl::has_key< boost::mpl::set< char *, const char * >, From > >::type >::operator()(), implementation::tlexical_cast< unsigned long long, std::string >::operator()(), implementation::tlexical_cast< To, From, typename boost::enable_if< boost::is_unsigned< To > >::type, typename boost::enable_if< boost::mpl::has_key< boost::mpl::set< char *, const char * >, From > >::type >::operator()(), and implementation::tlexical_cast< To, std::string, typename boost::enable_if< boost::is_unsigned< To > >::type >::operator()().

#define LEXICAL_CAST_HPP_INCLUDED
#define LEXICAL_CAST_HPP_INCLUDED

Definition at line 30 of file test_lexical_cast.cpp.

Function Documentation

template<typename To , typename From >
To lexical_cast ( From  value)
inline

Lexical cast converts one type to another.

Template Parameters
ToThe type to convert to.
FromThe type to convert from.
Parameters
valueThe value to convert.
Returns
The converted value.

Definition at line 93 of file lexical_cast.hpp.

Referenced by config::apply_diff(), attack_type::apply_modification(), BOOST_AUTO_TEST_CASE(), gui2::tcampaign_selection::campaign_selected(), config::clear_diff_track(), create(), unit::describe_builtin_effect(), attack_type::describe_modification(), destroy(), events::console_handler::do_control(), events::console_handler::do_controller(), editor::editor_display::draw_sidebar(), gui2::tgame_load::evaluate_summary_string(), ai::find_component(), game_info::game_info(), gui2::teditor_generate_map::get_seed(), help::help_text_area::handle_jump_cfg(), campaignd::server::handle_request_campaign_list(), wesnothd::server::handle_termination(), gui2::tpreferences::initialize_members(), ai::manager::internal_evaluate_command(), gui2::tlua_interpreter::input_model::list_history(), modify(), ai::target_unit_goal::on_create(), ai::target_location_goal::on_create(), ai::protect_goal::on_create(), implementation::tlexical_cast< long long, std::string >::operator()(), implementation::tlexical_cast< To, std::string, typename boost::enable_if< boost::is_signed< To > >::type >::operator()(), implementation::tlexical_cast< unsigned long long, std::string >::operator()(), config::attribute_value::string_visitor::operator()(), implementation::tlexical_cast< To, std::string, typename boost::enable_if< boost::is_unsigned< To > >::type >::operator()(), font::parse_markup(), commandline_options::parse_resolution_(), commandline_options::parse_to_uint_string_string_tuples_(), commandline_options::parse_to_uint_string_tuples_(), mp::gamebrowser::populate_game_item(), gui2::tcampaign_selection::post_show(), gui2::tlabel_settings::pre_show(), progressive_< T >::progressive_(), network::receive_data(), gui2::sort(), string2rgb(), SYNCED_COMMAND_HANDLER_FUNCTION(), and ai::config_value_translator< T >::value_to_cfg().