widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #10329
[Merge] lp:~widelands-dev/widelands/remove_namespace_std into lp:widelands
SirVer has proposed merging lp:~widelands-dev/widelands/remove_namespace_std into lp:widelands.
Commit message:
Wanted to remove 'using namespace std;' in all places where it was only for convenience. Turns out there were no non-lazy uses.
A tiny cleanup to make clearer in places what is actually used (for example min -> std::min improves readability).
Requested reviews:
Widelands Developers (widelands-dev)
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/remove_namespace_std/+merge/324890
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/remove_namespace_std into lp:widelands.
=== modified file 'src/base/md5.cc'
--- src/base/md5.cc 2017-01-25 18:55:59 +0000
+++ src/base/md5.cc 2017-05-31 21:30:58 +0000
@@ -27,13 +27,11 @@
#include "base/macros.h"
-using namespace std;
-
/**
* Create a hex string out of the MD5 checksum.
*/
-string Md5Checksum::str() const {
- string s;
+std::string Md5Checksum::str() const {
+ std::string s;
for (uint32_t i = 0; i < sizeof(data); ++i) {
char buf[3];
=== modified file 'src/graphic/animation.cc'
--- src/graphic/animation.cc 2017-05-21 18:15:17 +0000
+++ src/graphic/animation.cc 2017-05-31 21:30:58 +0000
@@ -41,9 +41,8 @@
#include "sound/note_sound.h"
#include "sound/sound_handler.h"
-using namespace std;
-
namespace {
+
// Parses an array { 12, 23 } into a point.
void get_point(const LuaTable& table, Vector2i* p) {
std::vector<int> pts = table.array_entries<int>();
@@ -97,13 +96,13 @@
std::vector<std::string> pc_mask_image_files_;
float scale_;
- vector<const Image*> frames_;
- vector<const Image*> pcmasks_;
+ std::vector<const Image*> frames_;
+ std::vector<const Image*> pcmasks_;
// name of sound effect that will be played at frame 0.
// TODO(sirver): this should be done using play_sound in a program instead of
// binding it to the animation.
- string sound_effect_;
+ std::string sound_effect_;
bool play_once_;
};
=== modified file 'src/graphic/graphic.cc'
--- src/graphic/graphic.cc 2017-02-28 20:07:07 +0000
+++ src/graphic/graphic.cc 2017-05-31 21:30:58 +0000
@@ -41,8 +41,6 @@
#include "io/streamwrite.h"
#include "notifications/notifications.h"
-using namespace std;
-
Graphic* g_gr;
namespace {
@@ -232,6 +230,6 @@
/**
* Save a screenshot to the given file.
*/
-void Graphic::screenshot(const string& fname) {
+void Graphic::screenshot(const std::string& fname) {
screenshot_filename_ = fname;
}
=== modified file 'src/graphic/text/rt_render.cc'
--- src/graphic/text/rt_render.cc 2017-05-23 21:07:47 +0000
+++ src/graphic/text/rt_render.cc 2017-05-31 21:30:58 +0000
@@ -52,7 +52,6 @@
#include "io/filesystem/filesystem_exceptions.h"
#include "io/filesystem/layered_filesystem.h"
-using namespace std;
// TODO(GunChleoc): text line can start with space text node when it's within a div.
namespace RT {
@@ -86,7 +85,7 @@
struct NodeStyle {
UI::FontSet const* fontset;
- string font_face;
+ std::string font_face;
uint16_t font_size;
RGBColor font_color;
int font_style;
@@ -94,7 +93,7 @@
uint8_t spacing;
UI::Align halign;
UI::Align valign;
- string reference;
+ std::string reference;
};
/*
@@ -109,15 +108,15 @@
private:
struct FontDescr {
- string face;
+ std::string face;
uint16_t size;
bool operator<(const FontDescr& o) const {
return size < o.size || (size == o.size && face < o.face);
}
};
- using FontMap = map<FontDescr, IFont*>;
- using FontMapPair = pair<const FontDescr, std::unique_ptr<IFont>>;
+ using FontMap = std::map<FontDescr, IFont*>;
+ using FontMapPair = std::pair<const FontDescr, std::unique_ptr<IFont>>;
FontMap fontmap_;
@@ -195,14 +194,14 @@
struct Reference {
Recti dim;
- string ref;
+ std::string ref;
};
class RefMap : public IRefMap {
public:
- RefMap(const vector<Reference>& refs) : refs_(refs) {
+ RefMap(const std::vector<Reference>& refs) : refs_(refs) {
}
- string query(int16_t x, int16_t y) override {
+ std::string query(int16_t x, int16_t y) override {
// Should this linear algorithm proof to be too slow (doubtful), the
// RefMap could also be efficiently implemented using an R-Tree
for (const Reference& c : refs_)
@@ -212,7 +211,7 @@
}
private:
- vector<Reference> refs_;
+ std::vector<Reference> refs_;
};
class RenderNode {
@@ -247,8 +246,8 @@
virtual void set_w(uint16_t) {
} // Only, when is_expanding
- virtual const vector<Reference> get_references() {
- return vector<Reference>();
+ virtual const std::vector<Reference> get_references() {
+ return std::vector<Reference>();
}
Floating get_floating() const {
@@ -316,7 +315,7 @@
class Layout {
public:
- Layout(vector<RenderNode*>& all) : h_(0), idx_(0), all_nodes_(all) {
+ Layout(std::vector<RenderNode*>& all) : h_(0), idx_(0), all_nodes_(all) {
}
virtual ~Layout() {
}
@@ -324,7 +323,7 @@
uint16_t height() {
return h_;
}
- uint16_t fit_nodes(vector<RenderNode*>& rv, uint16_t w, Borders p, bool shrink_to_fit);
+ uint16_t fit_nodes(std::vector<RenderNode*>& rv, uint16_t w, Borders p, bool shrink_to_fit);
private:
// Represents a change in the rendering constraints. For example when an
@@ -340,16 +339,16 @@
}
};
- uint16_t fit_line(uint16_t w, const Borders&, vector<RenderNode*>* rv, bool shrink_to_fit);
+ uint16_t fit_line(uint16_t w, const Borders&, std::vector<RenderNode*>* rv, bool shrink_to_fit);
uint16_t h_;
size_t idx_;
- vector<RenderNode*>& all_nodes_;
- priority_queue<ConstraintChange> constraint_changes_;
+ std::vector<RenderNode*>& all_nodes_;
+ std::priority_queue<ConstraintChange> constraint_changes_;
};
uint16_t
-Layout::fit_line(uint16_t w, const Borders& p, vector<RenderNode*>* rv, bool shrink_to_fit) {
+Layout::fit_line(uint16_t w, const Borders& p, std::vector<RenderNode*>* rv, bool shrink_to_fit) {
assert(rv->empty());
// Remove leading spaces
@@ -390,7 +389,7 @@
}
// Find expanding nodes
- vector<size_t> expanding_nodes;
+ std::vector<size_t> expanding_nodes;
for (size_t idx = 0; idx < rv->size(); ++idx)
if (rv->at(idx)->is_expanding())
expanding_nodes.push_back(idx);
@@ -417,7 +416,7 @@
// Find the biggest hotspot of the truly remaining items.
uint16_t cur_line_hotspot = 0;
for (RenderNode* node : *rv) {
- cur_line_hotspot = max(cur_line_hotspot, node->hotspot_y());
+ cur_line_hotspot = std::max(cur_line_hotspot, node->hotspot_y());
}
return cur_line_hotspot;
}
@@ -426,13 +425,13 @@
* Take ownership of all nodes, delete those that we do not render anyways (for
* example unneeded spaces), append the rest to the vector we got.
*/
-uint16_t Layout::fit_nodes(vector<RenderNode*>& rv, uint16_t w, Borders p, bool shrink_to_fit) {
+uint16_t Layout::fit_nodes(std::vector<RenderNode*>& rv, uint16_t w, Borders p, bool shrink_to_fit) {
assert(rv.empty());
h_ = p.top;
uint16_t max_line_width = 0;
while (idx_ < all_nodes_.size()) {
- vector<RenderNode*> nodes_in_line;
+ std::vector<RenderNode*> nodes_in_line;
size_t idx_before_iteration_ = idx_;
uint16_t biggest_hotspot = fit_line(w, p, &nodes_in_line, shrink_to_fit);
@@ -440,7 +439,7 @@
int line_start = INFINITE_WIDTH;
// Compute real line height and width, taking into account alignement
for (RenderNode* n : nodes_in_line) {
- line_height = max(line_height, biggest_hotspot - n->hotspot_y() + n->height());
+ line_height = std::max(line_height, biggest_hotspot - n->hotspot_y() + n->height());
n->set_y(h_ + biggest_hotspot - n->hotspot_y());
if (line_start >= INFINITE_WIDTH || n->x() < line_start) {
line_start = n->x() - p.left;
@@ -480,12 +479,12 @@
n->set_x(p.left);
p.left += n->width();
cc.delta_offset_x = -n->width();
- max_line_width = max<int>(max_line_width, n->x() + n->width() + p.right);
+ max_line_width = std::max<int>(max_line_width, n->x() + n->width() + p.right);
} else {
n->set_x(w - n->width() - p.right);
w -= n->width();
cc.delta_w = n->width();
- max_line_width = max(max_line_width, w);
+ max_line_width = std::max(max_line_width, w);
}
constraint_changes_.push(cc);
rv.push_back(n);
@@ -506,7 +505,7 @@
*/
class TextNode : public RenderNode {
public:
- TextNode(FontCache& font, NodeStyle&, const string& txt);
+ TextNode(FontCache& font, NodeStyle&, const std::string& txt);
virtual ~TextNode() {
}
@@ -521,8 +520,8 @@
return h_ + nodestyle_.spacing;
}
uint16_t hotspot_y() const override;
- const vector<Reference> get_references() override {
- vector<Reference> rv;
+ const std::vector<Reference> get_references() override {
+ std::vector<Reference> rv;
if (!nodestyle_.reference.empty()) {
Reference r = {Recti(0, 0, w_, h_), nodestyle_.reference};
rv.push_back(r);
@@ -534,13 +533,13 @@
protected:
uint16_t w_, h_;
- const string txt_;
+ const std::string txt_;
NodeStyle nodestyle_;
FontCache& fontcache_;
SdlTtfFont& font_;
};
-TextNode::TextNode(FontCache& font, NodeStyle& ns, const string& txt)
+TextNode::TextNode(FontCache& font, NodeStyle& ns, const std::string& txt)
: RenderNode(ns),
txt_(txt),
nodestyle_(ns),
@@ -570,7 +569,7 @@
class FillingTextNode : public TextNode {
public:
FillingTextNode(
- FontCache& font, NodeStyle& ns, uint16_t w, const string& txt, bool expanding = false)
+ FontCache& font, NodeStyle& ns, uint16_t w, const std::string& txt, bool expanding = false)
: TextNode(font, ns, txt), is_expanding_(expanding) {
w_ = w;
check_size();
@@ -607,7 +606,7 @@
font_.render(txt_, nodestyle_.font_color, nodestyle_.font_style, texture_cache);
auto texture = std::make_shared<Texture>(width(), height());
for (uint16_t curx = 0; curx < w_; curx += ttf->width()) {
- Rectf srcrect(0.f, 0.f, min<int>(ttf->width(), w_ - curx), h_);
+ Rectf srcrect(0.f, 0.f, std::min<int>(ttf->width(), w_ - curx), h_);
texture->blit(
Rectf(curx, 0, srcrect.w, srcrect.h), *ttf.get(), srcrect, 1., BlendMode::Copy);
}
@@ -736,7 +735,7 @@
for (uint16_t curx = 0; curx < w_; curx += background_image_->width()) {
dst.x = curx;
dst.y = 0;
- srcrect.w = dst.w = min<int>(background_image_->width(), w_ - curx);
+ srcrect.w = dst.w = std::min<int>(background_image_->width(), w_ - curx);
srcrect.h = dst.h = h_;
texture->blit(dst, *background_image_, srcrect, 1., BlendMode::Copy);
}
@@ -851,7 +850,7 @@
return rendered_text;
}
- const vector<Reference> get_references() override {
+ const std::vector<Reference> get_references() override {
return refs_;
}
void set_dimensions(uint16_t inner_w, uint16_t inner_h, Borders margin) {
@@ -869,10 +868,10 @@
void set_background(const Image* img) {
background_image_ = img;
}
- void set_nodes_to_render(vector<RenderNode*>& n) {
+ void set_nodes_to_render(std::vector<RenderNode*>& n) {
nodes_to_render_ = n;
}
- void add_reference(int16_t gx, int16_t gy, uint16_t w, uint16_t h, const string& s) {
+ void add_reference(int16_t gx, int16_t gy, uint16_t w, uint16_t h, const std::string& s) {
Reference r = {Recti(gx, gy, w, h), s};
refs_.push_back(r);
}
@@ -880,12 +879,12 @@
private:
DesiredWidth desired_width_;
uint16_t w_, h_;
- vector<RenderNode*> nodes_to_render_;
+ std::vector<RenderNode*> nodes_to_render_;
Borders margin_;
RGBColor background_color_;
bool is_background_color_set_;
const Image* background_image_; // Not owned.
- vector<Reference> refs_;
+ std::vector<Reference> refs_;
};
class ImgRenderNode : public RenderNode {
@@ -985,10 +984,10 @@
virtual void enter() {
}
- virtual void emit_nodes(vector<RenderNode*>&);
+ virtual void emit_nodes(std::vector<RenderNode*>&);
private:
- void make_text_nodes(const string& txt, vector<RenderNode*>& nodes, NodeStyle& ns);
+ void make_text_nodes(const std::string& txt, std::vector<RenderNode*>& nodes, NodeStyle& ns);
protected:
Tag& tag_;
@@ -999,7 +998,7 @@
const UI::FontSets& fontsets_;
};
-void TagHandler::make_text_nodes(const string& txt, vector<RenderNode*>& nodes, NodeStyle& ns) {
+void TagHandler::make_text_nodes(const std::string& txt, std::vector<RenderNode*>& nodes, NodeStyle& ns) {
TextStream ts(txt);
std::string word;
std::vector<RenderNode*> text_nodes;
@@ -1082,7 +1081,7 @@
}
}
-void TagHandler::emit_nodes(vector<RenderNode*>& nodes) {
+void TagHandler::emit_nodes(std::vector<RenderNode*>& nodes) {
for (Child* c : tag_.children()) {
if (c->tag) {
std::unique_ptr<TagHandler> th(create_taghandler(
@@ -1153,7 +1152,7 @@
}
nodestyle_.halign = mirror_alignment(nodestyle_.halign);
if (a.has("valign")) {
- const string align = a["valign"].get_string();
+ const std::string align = a["valign"].get_string();
if (align == "bottom") {
nodestyle_.valign = UI::Align::kBottom;
} else if (align == "center" || align == "middle") {
@@ -1165,7 +1164,7 @@
if (a.has("spacing"))
nodestyle_.spacing = a["spacing"].get_int();
}
- void emit_nodes(vector<RenderNode*>& nodes) override {
+ void emit_nodes(std::vector<RenderNode*>& nodes) override {
// Put a newline if this is not the first paragraph
if (!nodes.empty()) {
nodes.push_back(new NewlineNode(nodestyle_));
@@ -1217,7 +1216,7 @@
}
render_node_ = new ImgRenderNode(nodestyle_, image_filename, scale, color, use_playercolor);
}
- void emit_nodes(vector<RenderNode*>& nodes) override {
+ void emit_nodes(std::vector<RenderNode*>& nodes) override {
nodes.push_back(render_node_);
}
@@ -1241,7 +1240,7 @@
space_ = a["gap"].get_int();
}
- void emit_nodes(vector<RenderNode*>& nodes) override {
+ void emit_nodes(std::vector<RenderNode*>& nodes) override {
nodes.push_back(new SpaceNode(nodestyle_, 0, space_));
nodes.push_back(new NewlineNode(nodestyle_));
}
@@ -1283,7 +1282,7 @@
}
}
- void emit_nodes(vector<RenderNode*>& nodes) override {
+ void emit_nodes(std::vector<RenderNode*>& nodes) override {
RenderNode* rn = nullptr;
if (!fill_text_.empty()) {
if (space_ < INFINITE_WIDTH)
@@ -1305,7 +1304,7 @@
}
private:
- string fill_text_;
+ std::string fill_text_;
const Image* background_image_;
std::string image_filename_;
uint16_t space_;
@@ -1322,7 +1321,7 @@
: TagHandler(tag, fc, ns, image_cache, init_renderer_style, fontsets) {
}
- void emit_nodes(vector<RenderNode*>& nodes) override {
+ void emit_nodes(std::vector<RenderNode*>& nodes) override {
nodes.push_back(new NewlineNode(nodestyle_));
}
};
@@ -1374,14 +1373,14 @@
margin.left = margin.top = margin.right = margin.bottom = p;
}
- vector<RenderNode*> subnodes;
+ std::vector<RenderNode*> subnodes;
TagHandler::emit_nodes(subnodes);
if (!w_) { // Determine the width by the width of the widest subnode
for (RenderNode* n : subnodes) {
if (n->width() >= INFINITE_WIDTH)
continue;
- w_ = max<int>(w_, n->width() + padding.left + padding.right);
+ w_ = std::max<int>(w_, n->width() + padding.left + padding.right);
}
}
@@ -1399,7 +1398,7 @@
// Layout takes ownership of subnodes
Layout layout(subnodes);
- vector<RenderNode*> nodes_to_render;
+ std::vector<RenderNode*> nodes_to_render;
uint16_t max_line_width = layout.fit_nodes(nodes_to_render, w_, padding, shrink_to_fit_);
uint16_t extra_width = 0;
if (w_ < INFINITE_WIDTH && w_ > max_line_width) {
@@ -1439,7 +1438,7 @@
render_node_->set_dimensions(w_, layout.height(), margin);
render_node_->set_nodes_to_render(nodes_to_render);
}
- void emit_nodes(vector<RenderNode*>& nodes) override {
+ void emit_nodes(std::vector<RenderNode*>& nodes) override {
nodes.push_back(render_node_);
}
@@ -1472,14 +1471,14 @@
}
}
if (a.has("float")) {
- const string s = a["float"].get_string();
+ const std::string s = a["float"].get_string();
if (s == "right")
render_node_->set_floating(RenderNode::FLOAT_RIGHT);
else if (s == "left")
render_node_->set_floating(RenderNode::FLOAT_LEFT);
}
if (a.has("valign")) {
- const string align = a["valign"].get_string();
+ const std::string align = a["valign"].get_string();
if (align == "top")
render_node_->set_valign(UI::Align::kTop);
else if (align == "bottom")
@@ -1527,7 +1526,7 @@
const UI::FontSets& fontsets) {
return new T(tag, fc, ns, image_cache, renderer_style, fontsets);
}
-using TagHandlerMap = map<const string,
+using TagHandlerMap = std::map<const std::string,
TagHandler* (*)(Tag& tag,
FontCache& fc,
NodeStyle& ns,
@@ -1575,7 +1574,7 @@
Renderer::~Renderer() {
}
-RenderNode* Renderer::layout_(const string& text, uint16_t width, const TagSet& allowed_tags) {
+RenderNode* Renderer::layout_(const std::string& text, uint16_t width, const TagSet& allowed_tags) {
std::unique_ptr<Tag> rt(parser_->parse(text, allowed_tags));
if (!width) {
@@ -1599,7 +1598,7 @@
RTTagHandler rtrn(
*rt, *font_cache_, default_style, image_cache_, renderer_style_, fontsets_, width);
- vector<RenderNode*> nodes;
+ std::vector<RenderNode*> nodes;
rtrn.enter();
rtrn.emit_nodes(nodes);
@@ -1609,14 +1608,14 @@
}
std::shared_ptr<const UI::RenderedText>
-Renderer::render(const string& text, uint16_t width, const TagSet& allowed_tags) {
+Renderer::render(const std::string& text, uint16_t width, const TagSet& allowed_tags) {
std::unique_ptr<RenderNode> node(layout_(text, width, allowed_tags));
return std::shared_ptr<const UI::RenderedText>(std::move(node->render(texture_cache_)));
}
IRefMap*
-Renderer::make_reference_map(const string& text, uint16_t width, const TagSet& allowed_tags) {
+Renderer::make_reference_map(const std::string& text, uint16_t width, const TagSet& allowed_tags) {
std::unique_ptr<RenderNode> node(layout_(text, width, allowed_tags));
return new RefMap(node->get_references());
}
=== modified file 'src/graphic/text/textstream.cc'
--- src/graphic/text/textstream.cc 2017-01-25 18:55:59 +0000
+++ src/graphic/text/textstream.cc 2017-05-31 21:30:58 +0000
@@ -24,13 +24,12 @@
#include "graphic/text/rt_errors_impl.h"
-using namespace std;
using namespace boost;
namespace RT {
struct EndOfTextImpl : public EndOfText {
- EndOfTextImpl(size_t pos, string text)
+ EndOfTextImpl(size_t pos, std::string text)
: EndOfText(
(format("Unexpected End of Text, starting at %1%. Text is: '%2%'") % pos % text).str()) {
}
@@ -66,7 +65,7 @@
/*
* Return the next few characters without advancing the stream
*/
-string TextStream::peek(size_t n, size_t at) const {
+std::string TextStream::peek(size_t n, size_t at) const {
return text_.substr(at > text_.size() ? pos_ : at, n);
}
@@ -74,7 +73,7 @@
* Throw a synatx error if not the thing shows up, we expected to.
* Also advances the stream.
*/
-void TextStream::expect(string n, bool skip_whitespace) {
+void TextStream::expect(std::string n, bool skip_whitespace) {
if (skip_whitespace)
skip_ws();
@@ -87,10 +86,10 @@
* Parse forward till the next char is any of of the given chars.
* Return the substring we went over
*/
-string TextStream::till_any(string chars) {
+std::string TextStream::till_any(std::string chars) {
// Boost should provide a function here, but I was unable to figure it out
// Sticking with a double loop because chars will likely be short
- string rv;
+ std::string rv;
size_t j = pos_;
size_t started_at = pos_;
@@ -134,8 +133,8 @@
/*
* Parse till any of the chars is found or the end of the string has been hit.
*/
-string TextStream::till_any_or_end(string chars) {
- string rv;
+std::string TextStream::till_any_or_end(std::string chars) {
+ std::string rv;
try {
rv = till_any(chars);
} catch (EndOfTextImpl&) {
@@ -148,11 +147,11 @@
/*
* Return the next (potentially quoted) string
*/
-string TextStream::parse_string() {
- string delim = peek(1);
+std::string TextStream::parse_string() {
+ std::string delim = peek(1);
if (delim == "'" || delim == "\"") {
consume(1);
- string rv = till_any(delim);
+ std::string rv = till_any(delim);
consume(1);
return rv;
} else
@@ -162,7 +161,7 @@
/*
* Return the text that is yet to be parsed
*/
-string TextStream::remaining_text() {
+std::string TextStream::remaining_text() {
return text_.substr(pos_, end_ - pos_);
}
}
=== modified file 'src/helper.cc'
--- src/helper.cc 2017-01-25 18:55:59 +0000
+++ src/helper.cc 2017-05-31 21:30:58 +0000
@@ -27,12 +27,10 @@
#include <boost/format.hpp>
#include <boost/lexical_cast.hpp>
-using namespace std;
-
-vector<string> split_string(const string& s, const char* const separators) {
- vector<string> result;
- for (string::size_type pos = 0, endpos;
- (pos = s.find_first_not_of(separators, pos)) != string::npos; pos = endpos) {
+std::vector<std::string> split_string(const std::string& s, const char* const separators) {
+ std::vector<std::string> result;
+ for (std::string::size_type pos = 0, endpos;
+ (pos = s.find_first_not_of(separators, pos)) != std::string::npos; pos = endpos) {
endpos = s.find_first_of(separators, pos);
result.push_back(s.substr(pos, endpos - pos));
}
=== modified file 'src/ui_basic/panel.cc'
--- src/ui_basic/panel.cc 2017-05-25 12:30:40 +0000
+++ src/ui_basic/panel.cc 2017-05-31 21:30:58 +0000
@@ -30,8 +30,6 @@
#include "sound/sound_handler.h"
#include "wlapplication.h"
-using namespace std;
-
namespace UI {
Panel* Panel::modal_ = nullptr;
=== modified file 'src/ui_basic/window.cc'
--- src/ui_basic/window.cc 2017-05-21 18:15:17 +0000
+++ src/ui_basic/window.cc 2017-05-31 21:30:58 +0000
@@ -27,9 +27,8 @@
#include "graphic/rendertarget.h"
#include "graphic/text_layout.h"
-using namespace std;
-
namespace UI {
+
/// Width the horizontal border graphics must have.
#define HZ_B_TOTAL_PIXMAP_LEN 100
@@ -66,12 +65,12 @@
* \param title string to display in the window title
*/
Window::Window(Panel* const parent,
- const string& name,
+ const std::string& name,
int32_t const x,
int32_t const y,
uint32_t const w,
uint32_t const h,
- const string& title)
+ const std::string& title)
: NamedPanel(parent,
name,
x,
@@ -105,7 +104,7 @@
/**
* Replace the current title with a new one
*/
-void Window::set_title(const string& text) {
+void Window::set_title(const std::string& text) {
assert(!is_richtext(text));
title_ = text;
}
@@ -454,10 +453,10 @@
const int32_t max_x = parent->get_inner_w();
const int32_t max_y = parent->get_inner_h();
- left = min<int32_t>(max_x - get_lborder(), left);
- top = min<int32_t>(max_y - get_tborder(), top);
- left = max<int32_t>(get_rborder() - w, left);
- top = max(-static_cast<int32_t>(h - ((is_minimal_) ? get_tborder() : get_bborder())), top);
+ left = std::min<int32_t>(max_x - get_lborder(), left);
+ top = std::min<int32_t>(max_y - get_tborder(), top);
+ left = std::max<int32_t>(get_rborder() - w, left);
+ top = std::max(-static_cast<int32_t>(h - ((is_minimal_) ? get_tborder() : get_bborder())), top);
new_left = left;
new_top = top;
@@ -500,13 +499,13 @@
nearest_snap_distance_x = psnap;
else {
assert(nearest_snap_distance_x < bsnap);
- nearest_snap_distance_x = min(nearest_snap_distance_x, psnap);
+ nearest_snap_distance_x = std::min(nearest_snap_distance_x, psnap);
}
if (nearest_snap_distance_y == bsnap)
nearest_snap_distance_y = psnap;
else {
assert(nearest_snap_distance_y < bsnap);
- nearest_snap_distance_y = min(nearest_snap_distance_y, psnap);
+ nearest_snap_distance_y = std::min(nearest_snap_distance_y, psnap);
}
{ // Snap to other Panels.
=== modified file 'src/wui/plot_area.cc'
--- src/wui/plot_area.cc 2017-05-25 12:30:40 +0000
+++ src/wui/plot_area.cc 2017-05-31 21:30:58 +0000
@@ -32,8 +32,6 @@
#include "graphic/text_layout.h"
#include "ui_basic/panel.h"
-using namespace std;
-
namespace {
constexpr int32_t kUpdateTimeInGametimeMs = 1000; // 1 second, gametime
@@ -66,7 +64,7 @@
kDayGeneric
};
-string ytick_text_style(const string& text, const RGBColor& clr) {
+std::string ytick_text_style(const std::string& text, const RGBColor& clr) {
static boost::format f(
"<rt keep_spaces=1><p><font face=condensed size=13 color=%02x%02x%02x>%s</font></p></rt>");
f % int(clr.r) % int(clr.g) % int(clr.b);
@@ -74,7 +72,7 @@
return f.str();
}
-string xtick_text_style(const string& text) {
+std::string xtick_text_style(const std::string& text) {
return ytick_text_style(text, RGBColor(255, 0, 0));
}
@@ -174,7 +172,7 @@
/**
* print the string into the RenderTarget.
*/
-void draw_value(const string& value,
+void draw_value(const std::string& value,
const RGBColor& color,
const Vector2i& pos,
RenderTarget& dst) {
Follow ups