summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/dlua.cc
diff options
context:
space:
mode:
authorRaphael Langella <raphael.langella@gmail.com>2012-08-26 22:50:06 +0200
committerRaphael Langella <raphael.langella@gmail.com>2012-08-26 23:06:30 +0200
commit770bcbd1844b97b671d0e47ea8313cdf2c74c5ea (patch)
treee030cf61afce9ca69b74bb38eb73734bf10f633e /crawl-ref/source/dlua.cc
parenta6c16c7f2066c854a01f25e9e6c3d8e44282a638 (diff)
downloadcrawl-ref-770bcbd1844b97b671d0e47ea8313cdf2c74c5ea.tar.gz
crawl-ref-770bcbd1844b97b671d0e47ea8313cdf2c74c5ea.zip
Use std namespace.
I had to rename distance() (in coord.h) to distance2() because it conflicts with the STL function to compare 2 iterators. Not a bad change given how it returns the square of the distance anyway. I also had to rename the message global variable (in message.cc) to buffer. I tried to fix and improve the coding style has much as I could, but I probably missed a few given how huge and tedious it is. I also didn't touch crawl-gdb.py, and the stuff in prebuilt, rltiles/tool and util/levcomp.*, because I have no clue about those.
Diffstat (limited to 'crawl-ref/source/dlua.cc')
-rw-r--r--crawl-ref/source/dlua.cc59
1 files changed, 29 insertions, 30 deletions
diff --git a/crawl-ref/source/dlua.cc b/crawl-ref/source/dlua.cc
index 643f75d94c..90425abe22 100644
--- a/crawl-ref/source/dlua.cc
+++ b/crawl-ref/source/dlua.cc
@@ -15,7 +15,7 @@
static int dlua_compiled_chunk_writer(lua_State *ls, const void *p,
size_t sz, void *ud)
{
- std::ostringstream &out = *static_cast<std::ostringstream*>(ud);
+ ostringstream &out = *static_cast<ostringstream*>(ud);
out.write(static_cast<const char *>(p), sz);
return 0;
}
@@ -23,7 +23,7 @@ static int dlua_compiled_chunk_writer(lua_State *ls, const void *p,
///////////////////////////////////////////////////////////////////////////
// dlua_chunk
-dlua_chunk::dlua_chunk(const std::string &_context)
+dlua_chunk::dlua_chunk(const string &_context)
: file(), chunk(), compiled(), context(_context), first(-1),
last(-1), error()
{
@@ -38,7 +38,7 @@ dlua_chunk::dlua_chunk(lua_State *ls)
clear();
lua_stack_cleaner cln(ls);
- std::ostringstream out;
+ ostringstream out;
const int err = lua_dump(ls, dlua_compiled_chunk_writer, &out);
if (err)
{
@@ -48,14 +48,14 @@ dlua_chunk::dlua_chunk(lua_State *ls)
compiled = out.str();
}
-dlua_chunk dlua_chunk::precompiled(const std::string &_chunk)
+dlua_chunk dlua_chunk::precompiled(const string &_chunk)
{
dlua_chunk dchunk;
dchunk.compiled = _chunk;
return dchunk;
}
-std::string dlua_chunk::describe(const std::string &name) const
+string dlua_chunk::describe(const string &name) const
{
if (chunk.empty())
return "";
@@ -114,12 +114,12 @@ void dlua_chunk::clear()
compiled.clear();
}
-void dlua_chunk::set_file(const std::string &s)
+void dlua_chunk::set_file(const string &s)
{
file = s;
}
-void dlua_chunk::add(int line, const std::string &s)
+void dlua_chunk::add(int line, const string &s)
{
if (first == -1)
first = line;
@@ -135,7 +135,7 @@ void dlua_chunk::add(int line, const std::string &s)
last = line;
}
-void dlua_chunk::set_chunk(const std::string &s)
+void dlua_chunk::set_chunk(const string &s)
{
chunk = s;
}
@@ -163,7 +163,7 @@ int dlua_chunk::load(CLua &interp)
interp.loadstring(chunk.c_str(), context.c_str()));
if (err)
return err;
- std::ostringstream out;
+ ostringstream out;
err = lua_dump(interp, dlua_compiled_chunk_writer, &out);
if (err)
{
@@ -195,7 +195,7 @@ int dlua_chunk::load_call(CLua &interp, const char *fn)
return check_op(interp, !interp.callfn(fn, fn? 1 : 0, 0));
}
-std::string dlua_chunk::orig_error() const
+string dlua_chunk::orig_error() const
{
rewrite_chunk_errors(error);
return error;
@@ -206,12 +206,12 @@ bool dlua_chunk::empty() const
return compiled.empty() && trimmed_string(chunk).empty();
}
-bool dlua_chunk::rewrite_chunk_errors(std::string &s) const
+bool dlua_chunk::rewrite_chunk_errors(string &s) const
{
- const std::string contextm = "[string \"" + context + "\"]:";
- std::string::size_type dlwhere = s.find(contextm);
+ const string contextm = "[string \"" + context + "\"]:";
+ string::size_type dlwhere = s.find(contextm);
- if (dlwhere == std::string::npos)
+ if (dlwhere == string::npos)
return false;
if (!dlwhere)
@@ -221,13 +221,13 @@ bool dlua_chunk::rewrite_chunk_errors(std::string &s) const
}
// Our chunk is mentioned, go back through and rewrite lines.
- std::vector<std::string> lines = split_string("\n", s);
- std::string newmsg = lines[0];
+ vector<string> lines = split_string("\n", s);
+ string newmsg = lines[0];
bool wrote_prefix = false;
for (int i = 2, size = lines.size() - 1; i < size; ++i)
{
- const std::string &st = lines[i];
- if (st.find(context) != std::string::npos)
+ const string &st = lines[i];
+ if (st.find(context) != string::npos)
{
if (!wrote_prefix)
{
@@ -242,22 +242,21 @@ bool dlua_chunk::rewrite_chunk_errors(std::string &s) const
return true;
}
-std::string dlua_chunk::rewrite_chunk_prefix(const std::string &line,
- bool skip_body) const
+string dlua_chunk::rewrite_chunk_prefix(const string &line, bool skip_body) const
{
- std::string s = line;
- const std::string contextm = "[string \"" + context + "\"]:";
- const std::string::size_type ps = s.find(contextm);
- if (ps == std::string::npos)
+ string s = line;
+ const string contextm = "[string \"" + context + "\"]:";
+ const string::size_type ps = s.find(contextm);
+ if (ps == string::npos)
return s;
- const std::string::size_type lns = ps + contextm.length();
- std::string::size_type pe = s.find(':', ps + contextm.length());
- if (pe != std::string::npos)
+ const string::size_type lns = ps + contextm.length();
+ string::size_type pe = s.find(':', ps + contextm.length());
+ if (pe != string::npos)
{
- const std::string line_num = s.substr(lns, pe - lns);
+ const string line_num = s.substr(lns, pe - lns);
const int lnum = atoi(line_num.c_str());
- const std::string newlnum = make_stringf("%d", lnum + first - 1);
+ const string newlnum = make_stringf("%d", lnum + first - 1);
s = s.substr(0, lns) + newlnum + s.substr(pe);
pe = lns + newlnum.length();
}
@@ -267,7 +266,7 @@ std::string dlua_chunk::rewrite_chunk_prefix(const std::string &line,
: s.substr(lns));
}
-std::string dlua_chunk::get_chunk_prefix(const std::string &sorig) const
+string dlua_chunk::get_chunk_prefix(const string &sorig) const
{
return rewrite_chunk_prefix(sorig, true);
}