Formatting cleanup: moved const qualifiers before type names

This commit is contained in:
Charles Dang 2016-10-31 01:04:18 +11:00
parent 6e021ba746
commit 8c92a9ee8e
45 changed files with 134 additions and 134 deletions

View file

@ -672,7 +672,7 @@ int battle_context::choose_defender_weapon(const unit &attacker,
namespace {
void refresh_weapon_index(int& weap_index, std::string const& weap_id, attack_itors attacks)
void refresh_weapon_index(int& weap_index, const std::string& weap_id, attack_itors attacks)
{
if(attacks.empty()) {
//no attacks to choose from

View file

@ -142,7 +142,7 @@ static component *find_component(component *root, const std::string &path, path_
//match path elements in [modify_ai] tag
boost::regex re(R"""(([^\.^\[]+)(\[(\d*)\]|\[([^\]]+)\]|()))""");
int const sub_matches[] = {1,3,4};
const int sub_matches[] = {1,3,4};
boost::sregex_token_iterator i(path.begin(), path.end(), re, sub_matches);
boost::sregex_token_iterator j;

View file

@ -97,7 +97,7 @@ void arrow::reset()
notify_arrow_changed();
}
void arrow::set_color(std::string const& color)
void arrow::set_color(const std::string& color)
{
color_ = color;
if (valid_path(path_))
@ -106,10 +106,10 @@ void arrow::set_color(std::string const& color)
}
}
std::string const arrow::STYLE_STANDARD = "standard";
std::string const arrow::STYLE_HIGHLIGHTED = "highlighted";
std::string const arrow::STYLE_FOCUS = "focus";
std::string const arrow::STYLE_FOCUS_INVALID = "focus_invalid";
const std::string arrow::STYLE_STANDARD = "standard";
const std::string arrow::STYLE_HIGHLIGHTED = "highlighted";
const std::string arrow::STYLE_FOCUS = "focus";
const std::string arrow::STYLE_FOCUS_INVALID = "focus_invalid";
void arrow::set_style(const std::string& style)
{
@ -164,9 +164,9 @@ void arrow::update_symbols()
symbols_map_.clear();
invalidate_arrow_path(path_);
std::string const mods = "~RC(FF00FF>"+ color_ + ")"; //magenta to current color
const std::string mods = "~RC(FF00FF>"+ color_ + ")"; //magenta to current color
std::string const dirname = "arrows/";
const std::string dirname = "arrows/";
std::string prefix = "";
std::string suffix = "";
std::string image_filename = "";

View file

@ -48,7 +48,7 @@ public:
* image::locator modifiers parameter. Examples: red is "red" or "FF0000" or "255,0,0".
* Feel free to add another method that accepts an Uint32 as a parameter instead.
*/
virtual void set_color(std::string const& color);
virtual void set_color(const std::string& color);
virtual std::string get_color() const { return color_; }
@ -59,12 +59,12 @@ public:
* symbols instead of arrow graphics.
*/
std::string get_style() {return style_;}
void set_style(std::string const& style);
void set_style(const std::string& style);
///If you add more styles, you should look at move::update_arrow_style()
static std::string const STYLE_STANDARD;
static std::string const STYLE_HIGHLIGHTED;
static std::string const STYLE_FOCUS;
static std::string const STYLE_FOCUS_INVALID;
static const std::string STYLE_STANDARD;
static const std::string STYLE_HIGHLIGHTED;
static const std::string STYLE_FOCUS;
static const std::string STYLE_FOCUS_INVALID;
arrow_path_t const& get_path() const;
arrow_path_t const& get_previous_path() const;

View file

@ -297,7 +297,7 @@ namespace {
T operator()(int i) const { return static_cast<T>(i); }
T operator()(unsigned long long u) const { return static_cast<T>(u); }
T operator()(double d) const { return static_cast<T>(d); }
T operator()(std::string const &s) const { return lexical_cast_default<T>(s, def_); }
T operator()(const std::string& s) const { return lexical_cast_default<T>(s, def_); }
T operator()(t_string const &) const { return def_; }
private:
@ -346,7 +346,7 @@ public:
std::string operator()(int i) const { return lexical_cast<std::string>(i); }
std::string operator()(unsigned long long u) const { return lexical_cast<std::string>(u); }
std::string operator()(double d) const { return lexical_cast<std::string>(d); }
std::string operator()(std::string const &s) const { return s; }
std::string operator()(const std::string& s) const { return s; }
std::string operator()(t_string const &s) const { return s.str(); }
};

View file

@ -984,7 +984,7 @@ gui::button::TYPE display::string_to_button_type(std::string type)
static const std::string& get_direction(size_t n)
{
static std::string const dirs[6] = { "-n", "-ne", "-se", "-s", "-sw", "-nw" };
static const std::string dirs[6] = { "-n", "-ne", "-se", "-s", "-sw", "-nw" };
return dirs[n >= sizeof(dirs)/sizeof(*dirs) ? 0 : n];
}
@ -2770,7 +2770,7 @@ void display::draw_image_for_report(surface& img, SDL_Rect& rect)
* If a config is not supplied, it will be generated via
* reports::generate_report().
*/
void display::refresh_report(std::string const &report_name, const config * new_cfg)
void display::refresh_report(const std::string& report_name, const config * new_cfg)
{
const theme::status_item *item = theme_.get_status_item(report_name);
if (!item) {

View file

@ -411,7 +411,7 @@ public:
void invalidate_theme() { panelsDrawn_ = false; }
void refresh_report(std::string const &report_name, const config * new_cfg=nullptr);
void refresh_report(const std::string& report_name, const config * new_cfg=nullptr);
void draw_minimap_units();

View file

@ -102,8 +102,8 @@ bool looks_like_pbl(const std::string& file);
/** Basic disk I/O - read file. */
std::string read_file(const std::string &fname);
std::istream *istream_file(const std::string &fname, bool treat_failure_as_error = true);
std::ostream *ostream_file(std::string const &fname, bool create_directory = true);
std::istream *istream_file(const std::string& fname, bool treat_failure_as_error = true);
std::ostream *ostream_file(const std::string& fname, bool create_directory = true);
/** Throws io_exception if an error occurs. */
void write_file(const std::string& fname, const std::string& data);

View file

@ -796,7 +796,7 @@ std::istream *istream_file(const std::string &fname, bool treat_failure_as_error
}
}
std::ostream *ostream_file(std::string const &fname, bool create_directory)
std::ostream *ostream_file(const std::string& fname, bool create_directory)
{
LOG_FS << "streaming " << fname << " for writing.\n";
#if 1

View file

@ -557,7 +557,7 @@ void sdl_ttf::set_font_list(const std::vector<subset_descriptor>& fontlist)
}
//Splits the UTF-8 text into text_chunks using the same font.
std::vector<text_chunk> sdl_ttf::split_text(std::string const & utf8_text) {
std::vector<text_chunk> sdl_ttf::split_text(const std::string& utf8_text) {
text_chunk current_chunk(0);
std::vector<text_chunk> chunks;

View file

@ -70,7 +70,7 @@ void text_surface::bidi_cvt()
}
#endif
text_surface::text_surface(std::string const &str, int size,
text_surface::text_surface(const std::string& str, int size,
SDL_Color color, int style)
: hash_(0)
, font_size_(size)
@ -109,7 +109,7 @@ text_surface::text_surface(int size, SDL_Color color, int style) :
{
}
void text_surface::set_text(std::string const &str)
void text_surface::set_text(const std::string& str)
{
initialized_ = false;
w_ = -1;

View file

@ -33,9 +33,9 @@ namespace font {
class text_surface
{
public:
text_surface(std::string const &str, int size, SDL_Color color, int style);
text_surface(const std::string& str, int size, SDL_Color color, int style);
text_surface(int size, SDL_Color color, int style);
void set_text(std::string const &str);
void set_text(const std::string& str);
void measure() const;
size_t width() const;

View file

@ -143,7 +143,7 @@ namespace game_events {
* Removes an event handler, identified by its ID.
* Events with empty IDs cannot be removed.
*/
void t_event_handlers::remove_event_handler(std::string const & id)
void t_event_handlers::remove_event_handler(const std::string& id)
{
if ( id.empty() )
return;

View file

@ -60,7 +60,7 @@ namespace game_events {
/// Adds an event handler.
void add_event_handler(const config & cfg, manager & man, bool is_menu_item=false);
/// Removes an event handler, identified by its ID.
void remove_event_handler(std::string const & id);
void remove_event_handler(const std::string& id);
/// Gets an event handler, identified by its ID.
const handler_ptr get_event_handler_by_id(const std::string & id);

View file

@ -694,7 +694,7 @@ void ui::gamelist_updated(bool silent)
// it works for me anyways
const std::string registered_user_tag = "~";
std::string const imgpre = IMAGE_PREFIX + std::string("misc/status-");
const std::string imgpre = IMAGE_PREFIX + std::string("misc/status-");
std::vector<std::string> user_strings;
std::vector<std::string> menu_strings;

View file

@ -217,7 +217,7 @@ public:
private:
tmp_change_control::model& model_;
std::string const name_;
const std::string name_;
int side_number_;
};

View file

@ -513,7 +513,7 @@ std::vector<topic> generate_ability_topics(const bool sort_generated)
std::vector<t_string> const& desc_vec = *desc_vecs[i];
for(size_t j=0; j < abil_vec.size(); ++j) {
t_string const& abil_name = abil_vec[j];
std::string const abil_desc =
const std::string abil_desc =
j >= desc_vec.size() ? "" : desc_vec[j].str();
ability_description.insert(std::make_pair(abil_name, abil_desc));

View file

@ -72,7 +72,7 @@ public:
class text_topic_generator: public topic_generator {
std::string text_;
public:
text_topic_generator(std::string const &t): text_(t) {}
text_topic_generator(const std::string& t): text_(t) {}
virtual std::string operator()() const { return text_; }
};
@ -90,7 +90,7 @@ public:
{
}
topic_text(std::string const &t):
topic_text(const std::string& t):
parsed_text_(),
generator_(new text_topic_generator(t))
{

View file

@ -453,7 +453,7 @@ std::vector<config> command_executor::get_menu_images(display& disp, const std::
std::vector<config> result;
for(size_t i = 0; i < items.size(); ++i) {
std::string const& item = items[i];
const std::string& item = items[i];
const hotkey::HOTKEY_COMMAND hk = hotkey::get_id(item);
result.emplace_back();

View file

@ -122,7 +122,7 @@ language_list get_languages()
return known_languages;
}
static void wesnoth_setlocale(int category, std::string const &slocale,
static void wesnoth_setlocale(int category, const std::string& slocale,
std::vector<std::string> const *alternates)
{
std::string locale = slocale;

View file

@ -113,7 +113,7 @@ log_domain::log_domain(char const *name)
domain_ = &*domains->insert(logd(name, 1)).first;
}
bool set_log_domain_severity(std::string const &name, int severity)
bool set_log_domain_severity(const std::string& name, int severity)
{
std::string::size_type s = name.size();
if (name == "all") {
@ -133,11 +133,11 @@ bool set_log_domain_severity(std::string const &name, int severity)
}
return true;
}
bool set_log_domain_severity(std::string const &name, const logger &lg) {
bool set_log_domain_severity(const std::string& name, const logger &lg) {
return set_log_domain_severity(name, lg.get_severity());
}
bool get_log_domain_severity(std::string const &name, int &severity)
bool get_log_domain_severity(const std::string& name, int &severity)
{
domain_map::iterator it = domains->find(name);
if (it == domains->end())

View file

@ -102,9 +102,9 @@ public:
friend class logger;
};
bool set_log_domain_severity(std::string const &name, int severity);
bool set_log_domain_severity(std::string const &name, const logger &lg);
bool get_log_domain_severity(std::string const &name, int &severity);
bool set_log_domain_severity(const std::string& name, int severity);
bool set_log_domain_severity(const std::string& name, const logger &lg);
bool get_log_domain_severity(const std::string& name, int &severity);
std::string list_logdomains(const std::string& filter);
void set_strict_severity(int severity);

View file

@ -706,7 +706,7 @@ double shortest_path_calculator::cost(const map_location& loc, const double so_f
return getNoPathValue();
const t_translation::t_terrain terrain = map_[loc];
int const terrain_cost = unit_.movement_cost(terrain);
const int terrain_cost = unit_.movement_cost(terrain);
// Pathfinding heuristic: the cost must be at least 1
VALIDATE(terrain_cost >= 1, _("Terrain with a movement cost less than 1 encountered."));
@ -789,7 +789,7 @@ double move_type_path_calculator::cost(const map_location& loc, const double so_
return getNoPathValue();
const t_translation::t_terrain terrain = map_[loc];
int const terrain_cost = movement_type_.movement_cost(terrain);
const int terrain_cost = movement_type_.movement_cost(terrain);
if (total_movement_ < terrain_cost)
return getNoPathValue();

View file

@ -214,8 +214,8 @@ private:
team const &viewing_team_;
std::vector<team> const &teams_;
gamemap const &map_;
int const movement_left_;
int const total_movement_;
const int movement_left_;
const int total_movement_;
bool const ignore_unit_;
bool const ignore_defense_;
bool see_all_;

View file

@ -193,7 +193,7 @@ void game_lua_kernel::log_error(char const * msg, char const * context)
lua_chat(context, msg);
}
void game_lua_kernel::lua_chat(std::string const &caption, std::string const &msg)
void game_lua_kernel::lua_chat(const std::string& caption, const std::string& msg)
{
if (game_display_) {
game_display_->get_chat_manager().add_chat_message(time(nullptr), caption, 0, msg,
@ -4514,7 +4514,7 @@ int game_lua_kernel::cfun_wml_action(lua_State *L)
/**
* Registers a function for use as an action handler.
*/
void game_lua_kernel::set_wml_action(std::string const &cmd, game_events::wml_action::handler h)
void game_lua_kernel::set_wml_action(const std::string& cmd, game_events::wml_action::handler h)
{
lua_State *L = mState;
@ -4546,7 +4546,7 @@ static int cfun_wml_condition(lua_State *L)
/**
* Registers a function for use as a conditional handler.
*/
void game_lua_kernel::set_wml_condition(std::string const &cmd, wml_conditional_handler h)
void game_lua_kernel::set_wml_condition(const std::string& cmd, wml_conditional_handler h)
{
lua_State *L = mState;
@ -4566,7 +4566,7 @@ void game_lua_kernel::set_wml_condition(std::string const &cmd, wml_conditional_
* @note @a cfg should be either volatile or long-lived since the Lua
* code may grab it for an arbitrary long time.
*/
bool game_lua_kernel::run_wml_action(std::string const &cmd, vconfig const &cfg,
bool game_lua_kernel::run_wml_action(const std::string& cmd, vconfig const &cfg,
game_events::queued_event const &ev)
{
lua_State *L = mState;
@ -4588,7 +4588,7 @@ bool game_lua_kernel::run_wml_action(std::string const &cmd, vconfig const &cfg,
* @note @a cfg should be either volatile or long-lived since the Lua
* code may grab it for an arbitrary long time.
*/
bool game_lua_kernel::run_wml_conditional(std::string const &cmd, vconfig const &cfg)
bool game_lua_kernel::run_wml_conditional(const std::string& cmd, vconfig const &cfg)
{
lua_State *L = mState;

View file

@ -173,7 +173,7 @@ class game_lua_kernel : public lua_kernel_base
//private helpers
std::string synced_state();
void lua_chat(std::string const &caption, std::string const &msg);
void lua_chat(const std::string& caption, const std::string& msg);
std::vector<int> get_sides_vector(const vconfig& cfg);
public:
@ -200,14 +200,14 @@ public:
void load_game(const config& level);
bool run_event(game_events::queued_event const &);
void push_builtin_effect();
void set_wml_action(std::string const &, game_events::wml_action::handler);
void set_wml_condition(std::string const &, bool(*)(const vconfig&));
bool run_wml_action(std::string const &, vconfig const &,
void set_wml_action(const std::string&, game_events::wml_action::handler);
void set_wml_condition(const std::string&, bool(*)(const vconfig&));
bool run_wml_action(const std::string&, vconfig const &,
game_events::queued_event const &);
bool run_filter(char const *name, unit const &u);
bool run_filter(char const *name, map_location const &l);
bool run_filter(char const *name, int nArgs);
bool run_wml_conditional(std::string const &, vconfig const &);
bool run_wml_conditional(const std::string&, vconfig const &);
virtual void log_error(char const* msg, char const* context = "Lua error");

View file

@ -518,7 +518,7 @@ namespace {
{ lua_pushnumber(L, ull); }
void operator()(double d) const
{ lua_pushnumber(L, d); }
void operator()(std::string const &s) const
void operator()(const std::string& s) const
{ lua_pushstring(L, s.c_str()); }
void operator()(t_string const &s) const
{ luaW_pushtstring(L, s); }
@ -915,7 +915,7 @@ bool luaW_checkvariable(lua_State *L, variable_access_create& v, int n)
}
}
void chat_message(std::string const &caption, std::string const &msg)
void chat_message(const std::string& caption, const std::string& msg)
{
if (!resources::screen) return;
resources::screen->get_chat_manager().add_chat_message(time(nullptr), caption, 0, msg,

View file

@ -170,7 +170,7 @@ bool luaW_checkvariable(lua_State *L, variable_access_create& v, int n);
/**
* Displays a message in the chat window.
*/
void chat_message(std::string const &caption, std::string const &msg);
void chat_message(const std::string& caption, const std::string& msg);
/**
* Calls a Lua function stored below its @a nArgs arguments at the top of the stack.

View file

@ -84,7 +84,7 @@ static int impl_side_get(lua_State *L)
std::set<std::string> const &recruits = t.recruits();
lua_createtable(L, recruits.size(), 0);
int i = 1;
for (std::string const &r : t.recruits()) {
for (const std::string& r : t.recruits()) {
lua_pushstring(L, r.c_str());
lua_rawseti(L, -2, i++);
}

View file

@ -97,7 +97,7 @@ SDL_Color create_color(const unsigned char red
return result;
}
SDL_Keycode sdl_keysym_from_name(std::string const &keyname)
SDL_Keycode sdl_keysym_from_name(const std::string& keyname)
{
return SDL_GetKeyFromName(keyname.c_str());
}

View file

@ -45,7 +45,7 @@
#define SDL_BUTTON_WHEELRIGHT 7
#endif
SDL_Keycode sdl_keysym_from_name(std::string const &keyname);
SDL_Keycode sdl_keysym_from_name(const std::string& keyname);
class surface
{

View file

@ -61,7 +61,7 @@ public:
private:
void parse_element();
void parse_variable();
std::string lineno_string(utils::string_map &map, std::string const &lineno,
std::string lineno_string(utils::string_map &map, const std::string& lineno,
const std::string &error_string,
const std::string &hint_string = "",
const std::string &debug_string = "");
@ -72,7 +72,7 @@ private:
abstract_validator *validator_;
struct element {
element(config *cfg, std::string const &name,
element(config *cfg, const std::string& name,
int start_line = 0, const std::string &file = "") :
cfg(cfg), name(name), start_line(start_line), file(file)
{}
@ -343,11 +343,11 @@ void parser::parse_variable()
/**
* This function is crap. Don't use it on a string_map with prefixes.
*/
std::string parser::lineno_string(utils::string_map &i18n_symbols,
std::string const &lineno,
std::string const &error_string,
std::string const &hint_string,
std::string const &debug_string)
std::string parser::lineno_string(utils::string_map& i18n_symbols,
const std::string& lineno,
const std::string& error_string,
const std::string& hint_string,
const std::string& debug_string)
{
i18n_symbols["pos"] = ::lineno_string(lineno);
std::string result = error_string;
@ -508,7 +508,7 @@ namespace { // helpers for write_key_val().
// Specialized visitors for things that go in quotes:
void operator()(boost::blank const &) const
{ /* treat blank values as nonexistent which fits better than treating them as empty strings.*/ }
void operator()(std::string const &s) const
void operator()(const std::string& s) const
{ indent(); out_ << key_ << '=' << '"' << escaped_string(s) << '"' << '\n'; }
void operator()(t_string const &s) const;

View file

@ -358,7 +358,7 @@ std::string lineno_string(const std::string &lineno)
preprocessor_error_detail_prefix + "included from ";
std::string res;
while (i != end) {
std::string const &line = *(i++);
const std::string& line = *(i++);
if (!res.empty())
res += included_from;
if (i != end)
@ -442,7 +442,7 @@ class preprocessor_file: preprocessor
std::vector< std::string > files_;
std::vector< std::string >::const_iterator pos_, end_;
public:
preprocessor_file(preprocessor_streambuf &, std::string const &, size_t);
preprocessor_file(preprocessor_streambuf &, const std::string&, size_t);
virtual bool get_chunk();
};
@ -521,15 +521,15 @@ class preprocessor_data: preprocessor
void push_token(token_desc::TOKEN_TYPE);
void pop_token();
void put(char);
void put(std::string const & /*, int change_line
void put(const std::string& /*, int change_line
= 0 */);
void conditional_skip(bool skip);
public:
preprocessor_data(preprocessor_streambuf &,
std::istream *,
std::string const &history,
std::string const &name, int line,
std::string const &dir, std::string const &domain,
const std::string& history,
const std::string& name, int line,
const std::string& dir, const std::string& domain,
std::map<std::string, std::string> *defines, bool is_define = false);
~preprocessor_data();
virtual bool get_chunk();
@ -548,7 +548,7 @@ bool operator==(char lhs, preprocessor_data::token_desc::TOKEN_TYPE rhs){ return
bool operator!=(preprocessor_data::token_desc::TOKEN_TYPE rhs, char lhs){ return !(lhs == rhs); }
bool operator!=(char lhs, preprocessor_data::token_desc::TOKEN_TYPE rhs){ return rhs != lhs; }
preprocessor_file::preprocessor_file(preprocessor_streambuf &t, std::string const &name, size_t symbol_index=-1) :
preprocessor_file::preprocessor_file(preprocessor_streambuf &t, const std::string& name, size_t symbol_index=-1) :
preprocessor(t),
files_(),
pos_(),
@ -604,8 +604,8 @@ bool preprocessor_file::get_chunk()
}
preprocessor_data::preprocessor_data(preprocessor_streambuf &t,
std::istream *i, std::string const &history, std::string const &name, int linenum,
std::string const &directory, std::string const &domain,
std::istream *i, const std::string& history, const std::string& name, int linenum,
const std::string& directory, const std::string& domain,
std::map<std::string, std::string> *defines, bool is_define) :
preprocessor(t),
in_scope_(i),
@ -796,7 +796,7 @@ void preprocessor_data::put(char c)
target_.buffer_ << c;
}
void preprocessor_data::put(std::string const &s /*, int line_change*/)
void preprocessor_data::put(const std::string& s /*, int line_change*/)
{
if (skipping_)
return;
@ -939,39 +939,39 @@ bool preprocessor_data::get_chunk()
}
} else if (command == "ifdef") {
skip_spaces();
std::string const &symbol = read_word();
const std::string& symbol = read_word();
bool found = target_.defines_->count(symbol) != 0;
DBG_PREPROC << "testing for macro " << symbol << ": "
<< (found ? "defined" : "not defined") << '\n';
conditional_skip(!found);
} else if (command == "ifndef") {
skip_spaces();
std::string const &symbol = read_word();
const std::string& symbol = read_word();
bool found = target_.defines_->count(symbol) != 0;
DBG_PREPROC << "testing for macro " << symbol << ": "
<< (found ? "defined" : "not defined") << '\n';
conditional_skip(found);
} else if (command == "ifhave") {
skip_spaces();
std::string const &symbol = read_word();
const std::string& symbol = read_word();
bool found = !filesystem::get_wml_location(symbol, directory_).empty();
DBG_PREPROC << "testing for file or directory " << symbol << ": "
<< (found ? "found" : "not found") << '\n';
conditional_skip(!found);
} else if (command == "ifnhave") {
skip_spaces();
std::string const &symbol = read_word();
const std::string& symbol = read_word();
bool found = !filesystem::get_wml_location(symbol, directory_).empty();
DBG_PREPROC << "testing for file or directory " << symbol << ": "
<< (found ? "found" : "not found") << '\n';
conditional_skip(found);
} else if (command == "ifver" || command == "ifnver") {
skip_spaces();
std::string const& vsymstr = read_word();
const std::string& vsymstr = read_word();
skip_spaces();
std::string const& vopstr = read_word();
const std::string& vopstr = read_word();
skip_spaces();
std::string const& vverstr = read_word();
const std::string& vverstr = read_word();
const VERSION_COMP_OP vop = parse_version_op(vopstr);
@ -1022,7 +1022,7 @@ bool preprocessor_data::get_chunk()
pop_token();
} else if (command == "textdomain") {
skip_spaces();
std::string const &s = read_word();
const std::string& s = read_word();
if (s != target_.textdomain_) {
put("#textdomain ");
put(s);
@ -1033,7 +1033,7 @@ bool preprocessor_data::get_chunk()
target_.error("Unexpected #enddef", linenum_);
} else if (command == "undef") {
skip_spaces();
std::string const &symbol = read_word();
const std::string& symbol = read_word();
if (!skipping_) {
target_.defines_->erase(symbol);
LOG_PREPROC << "undefine macro " << symbol << " (location " << get_location(target_.location_) << ")\n";
@ -1144,7 +1144,7 @@ bool preprocessor_data::get_chunk()
(*defines)[val.arguments[i]] = strings_[token.stack_pos + i + 1];
}
pop_token();
std::string const &dir = filesystem::directory_name(val.location.substr(0, val.location.find(' ')));
const std::string& dir = filesystem::directory_name(val.location.substr(0, val.location.find(' ')));
if (!slowpath_) {
DBG_PREPROC << "substituting macro " << symbol << '\n';
new preprocessor_data(target_, buffer, val.location, "",
@ -1235,7 +1235,7 @@ preprocessor_deleter::~preprocessor_deleter()
delete defines_;
}
std::istream *preprocess_file(std::string const &fname, preproc_map *defines)
std::istream *preprocess_file(const std::string& fname, preproc_map *defines)
{
log_scope("preprocessing file " + fname + " ...");
preproc_map *owned_defines = nullptr;

View file

@ -33,9 +33,9 @@ typedef std::map< std::string, preproc_define > preproc_map;
struct preproc_define
{
preproc_define() : value(), arguments(), textdomain(), linenum(0), location() {}
explicit preproc_define(std::string const &val) : value(val), arguments(), textdomain(), linenum(0), location() {}
preproc_define(std::string const &val, std::vector< std::string > const &args,
std::string const &domain, int line, std::string const &loc)
explicit preproc_define(const std::string& val) : value(val), arguments(), textdomain(), linenum(0), location() {}
preproc_define(const std::string& val, std::vector< std::string > const &args,
const std::string& domain, int line, const std::string& loc)
: value(val), arguments(args), textdomain(domain), linenum(line), location(loc) {}
std::string value;
std::vector< std::string > arguments;
@ -71,7 +71,7 @@ std::ostream& operator<<(std::ostream& stream, const preproc_map::value_type& de
*
* @returns The resulting preprocessed file data.
*/
std::istream *preprocess_file(std::string const &fname, preproc_map *defines = nullptr);
std::istream *preprocess_file(const std::string& fname, preproc_map *defines = nullptr);
void preprocess_resource(const std::string& res_name, preproc_map *defines_map,
bool write_cfg=false, bool write_plain_cfg=false, std::string target_directory="");

View file

@ -770,7 +770,7 @@ std::vector<std::string> quoted_split(const std::string& val, char c, int flags,
return res;
}
std::pair<int, int> parse_range(std::string const &str)
std::pair<int, int> parse_range(const std::string& str)
{
const std::string::const_iterator dash = std::find(str.begin(), str.end(), '-');
const std::string a(str.begin(), dash);
@ -786,7 +786,7 @@ std::pair<int, int> parse_range(std::string const &str)
return res;
}
std::vector<std::pair<int, int>> parse_ranges(std::string const &str)
std::vector<std::pair<int, int>> parse_ranges(const std::string& str)
{
std::vector< std::pair< int, int > > to_return;
std::vector<std::string> strs = utils::split(str);

View file

@ -57,7 +57,7 @@ std::vector<std::string> quoted_split(const std::string& val, char c= ',', int f
* Splits a (comma-)separated string into a set of pieces.
* See split() for the meanings of the parameters.
*/
inline std::set<std::string> set_split(std::string const &val, const char c = ',', const int flags = REMOVE_EMPTY | STRIP_SPACES)
inline std::set<std::string> set_split(const std::string& val, const char c = ',', const int flags = REMOVE_EMPTY | STRIP_SPACES)
{
std::vector<std::string> vec_split = split(val, c, flags);
return std::set< std::string >(vec_split.begin(), vec_split.end());
@ -222,9 +222,9 @@ std::string bullet_list(const T& v, size_t indent = 4, const std::string& bullet
*/
std::string indent(const std::string& string, size_t indent_size = 4);
std::pair<int, int> parse_range(std::string const &str);
std::pair<int, int> parse_range(const std::string& str);
std::vector<std::pair<int, int>> parse_ranges(std::string const &str);
std::vector<std::pair<int, int>> parse_ranges(const std::string& str);
int apply_modifier(const int number, const std::string &amount, const int minimum = 0);

View file

@ -59,7 +59,7 @@ public:
};
class style {
public:
style(std::string const& p, int br) : panel(p), blur_radius(br) {}
style(const std::string& p, int br) : panel(p), blur_radius(br) {}
std::string panel;
int blur_radius;
};

View file

@ -762,7 +762,7 @@ static Mix_Chunk* load_chunk(const std::string& file, channel_group group)
throw chunk_load_exception();
}
temp_chunk.group = group;
std::string const &filename = filesystem::get_binary_file_location("sounds", file);
const std::string& filename = filesystem::get_binary_file_location("sounds", file);
if (!filename.empty()) {
SDL_RWops *rwops = filesystem::load_RWops(filename);

View file

@ -41,29 +41,29 @@ static lg::log_domain log_engine("engine");
namespace {
int const storybox_padding = 10; // px
double const storyshadow_opacity = 0.5;
int const storyshadow_r = 0;
int const storyshadow_g = 0;
int const storyshadow_b = 0;
const int storybox_padding = 10; // px
const double storyshadow_opacity = 0.5;
const int storyshadow_r = 0;
const int storyshadow_g = 0;
const int storyshadow_b = 0;
int const titlebox_padding = 20; // px
int const titleshadow_padding = 5; // px
double const titleshadow_opacity = 0.5;
int const titleshadow_r = 0;
int const titleshadow_g = 0;
int const titleshadow_b = 0;
const int titlebox_padding = 20; // px
const int titleshadow_padding = 5; // px
const double titleshadow_opacity = 0.5;
const int titleshadow_r = 0;
const int titleshadow_g = 0;
const int titleshadow_b = 0;
int const titlebox_font_size = 20; // pt?
int const storybox_font_size = 17; // pt?
const int titlebox_font_size = 20; // pt?
const int storybox_font_size = 17; // pt?
Uint32 const titlebox_font_color = 0xFFFFFFFF;
Uint32 const storybox_font_color = 0xDDDDDDFF;
const Uint32 titlebox_font_color = 0xFFFFFFFF;
const Uint32 storybox_font_color = 0xDDDDDDFF;
#ifndef LOW_MEM
// Hard-coded path to a suitable (tileable) pic for the storytxt box border.
std::string const storybox_top_border_path = "dialogs/translucent54-border-top.png";
std::string const storybox_bottom_border_path = "dialogs/translucent54-border-bottom.png";
const std::string storybox_top_border_path = "dialogs/translucent54-border-top.png";
const std::string storybox_bottom_border_path = "dialogs/translucent54-border-bottom.png";
void blur_area(CVideo& video, int y, int h)
{
SDL_Rect blur_rect = sdl::create_rect(0, y, screen_area().w, h);

View file

@ -211,19 +211,19 @@ public:
void set_max(int o){
max_ = o;
}
void set_min( std::string const& s){
void set_min(const std::string& s){
std::istringstream i(s);
if (!(i >> min_)){
min_ = 0;
}
}
void set_max( std::string const & s){
void set_max(const std::string& s){
std::istringstream i(s);
if (!(i >> max_)){
max_ = 0;
}
}
void set_super(std::string const & s){
void set_super(const std::string& s){
super_= s;
}
void add_key(const class_key& new_key){

View file

@ -654,7 +654,7 @@ std::string attack_type::weapon_specials(bool only_active, bool is_backstab) con
if ( only_active && !special_active(sp.cfg, AFFECT_EITHER, is_backstab) )
continue;
std::string const &name = sp.cfg["name"].str();
const std::string& name = sp.cfg["name"].str();
if (!name.empty()) {
if (!res.empty()) res += ", ";
res += name;
@ -757,7 +757,7 @@ namespace { // Helpers for attack_type::special_active()
bool special_affects_opponent(const config& special, bool is_attacker)
{
//log_scope("special_affects_opponent");
std::string const &apply_to = special["apply_to"];
const std::string& apply_to = special["apply_to"];
if ( apply_to.empty() )
return false;
if ( apply_to == "both" )
@ -779,7 +779,7 @@ namespace { // Helpers for attack_type::special_active()
bool special_affects_self(const config& special, bool is_attacker)
{
//log_scope("special_affects_self");
std::string const &apply_to = special["apply_to"];
const std::string& apply_to = special["apply_to"];
if ( apply_to.empty() )
return true;
if ( apply_to == "both" )
@ -1022,7 +1022,7 @@ effect::effect(const unit_ability_list& list, int def, bool backstab) :
for (const unit_ability & ability : list) {
const config& cfg = *ability.first;
std::string const &effect_id = cfg[cfg["id"].empty() ? "name" : "id"];
const std::string& effect_id = cfg[cfg["id"].empty() ? "name" : "id"];
if (!cfg["backstab"].blank()) {
lg::wml_error() << "The backstab= key in weapon specials is deprecated; use [filter_adjacent] instead\n";

View file

@ -128,7 +128,7 @@ const config::const_child_itors &unit_race::additional_topics() const
unsigned int unit_race::num_traits() const { return ntraits_; }
std::string const& gender_string(unit_race::GENDER gender) {
const std::string& gender_string(unit_race::GENDER gender) {
switch(gender) {
case unit_race::FEMALE:
return unit_race::s_female;

View file

@ -68,7 +68,7 @@ private:
};
unit_race::GENDER string_gender(const std::string& str,unit_race::GENDER def=unit_race::MALE);
std::string const& gender_string(unit_race::GENDER gender);
const std::string& gender_string(unit_race::GENDER gender);
typedef std::map<std::string,unit_race> race_map;

View file

@ -162,8 +162,8 @@ namespace {
return false;
}
unsigned int const& lvalue = l[k];
unsigned int const& rvalue = r[k];
const unsigned int& lvalue = l[k];
const unsigned int& rvalue = r[k];
_Toperator o;
_Tfallback_operator fallback_o;
@ -201,8 +201,8 @@ namespace {
{
case EQUAL: case NOT_EQUAL: {
for(size_t i = 0; i < csize; ++i) {
unsigned int const& lvalue = lc[i];
unsigned int const& rvalue = rc[i];
const unsigned int& lvalue = lc[i];
const unsigned int& rvalue = rc[i];
if(o == NOT_EQUAL) {
if((result = (lvalue != rvalue))) {
#ifdef _MSC_VER

View file

@ -107,7 +107,7 @@ void recruit::execute(bool& success, bool& complete)
{
assert(valid());
temporary_unit_hider const raii(*fake_unit_);
int const side_num = team_index() + 1;
const int side_num = team_index() + 1;
//Give back the spent gold so we don't get "not enough gold" message
resources::gameboard->teams().at(team_index()).get_side_actions()->change_gold_spent_by(-cost_);
bool const result = resources::controller->get_menu_handler().do_recruit(unit_name_, side_num, recruit_hex_);