aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-04-30 15:10:09 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-04-30 15:10:09 +0200
commitb4d8b7c142a0753462165257ef1bc1345bbadd6d (patch)
treeb7c092a4f4c24be6dc45e8d2f582d58dcfee9cad
parent07780b06aa7b0fe049cc412309cf87e7fb10a0ef (diff)
Minor code cleanup
-rw-r--r--brep/module.cxx8
-rw-r--r--brep/search.cxx6
-rw-r--r--brep/view.cxx6
-rw-r--r--web/apache/request.cxx27
-rw-r--r--web/apache/request.ixx1
5 files changed, 21 insertions, 27 deletions
diff --git a/brep/module.cxx b/brep/module.cxx
index 44154d6..fc239ba 100644
--- a/brep/module.cxx
+++ b/brep/module.cxx
@@ -9,6 +9,8 @@
#include <memory> // unique_ptr
#include <string>
+#include <ostream>
+#include <sstream>
#include <cstring> // strncmp()
#include <stdexcept>
#include <functional> // bind()
@@ -39,7 +41,7 @@ namespace brep
try
{
static const char* sev_str[] = {"error", "warning", "info", "trace"};
- std::ostream& o = rs.content (500, "text/plain;charset=utf-8");
+ ostream& o = rs.content (500, "text/plain;charset=utf-8");
for (const auto& d: e.data)
{
@@ -81,7 +83,7 @@ namespace brep
log_ = &log;
int argc = 0;
- std::unique_ptr<const char*[]> argv (new const char*[options.size () * 2]);
+ unique_ptr<const char*[]> argv (new const char*[options.size () * 2]);
for (const auto& nv: options)
{
@@ -122,7 +124,7 @@ namespace brep
}
catch (const cli::exception& e)
{
- std::ostringstream o;
+ ostringstream o;
e.print (o);
throw runtime_error (o.str ());
}
diff --git a/brep/search.cxx b/brep/search.cxx
index 15811e3..5f9f507 100644
--- a/brep/search.cxx
+++ b/brep/search.cxx
@@ -19,9 +19,9 @@ namespace brep
{
MODULE_DIAG;
- options_ = std::make_shared<search_options> (s,
- ::cli::unknown_mode::fail,
- ::cli::unknown_mode::fail);
+ options_ = make_shared<search_options> (s,
+ ::cli::unknown_mode::fail,
+ ::cli::unknown_mode::fail);
if (options_->results_on_page () > 30)
fail << "too many search results on page: "
diff --git a/brep/view.cxx b/brep/view.cxx
index 7ccc159..a644aec 100644
--- a/brep/view.cxx
+++ b/brep/view.cxx
@@ -16,9 +16,9 @@ namespace brep
void view::
init (::cli::scanner& s)
{
- options_ = std::make_shared<view_options> (s,
- ::cli::unknown_mode::fail,
- ::cli::unknown_mode::fail);
+ options_ = make_shared<view_options> (s,
+ ::cli::unknown_mode::fail,
+ ::cli::unknown_mode::fail);
}
void view::
diff --git a/web/apache/request.cxx b/web/apache/request.cxx
index 1990fa2..3711437 100644
--- a/web/apache/request.cxx
+++ b/web/apache/request.cxx
@@ -76,7 +76,7 @@ namespace web
}
ostream& request::
- content (status_code status, const std::string& type, bool buffer)
+ content (status_code status, const string& type, bool buffer)
{
if (out_ && status == rec_->status && buffer == buffer_ &&
!::strcasecmp (rec_->content_type ? rec_->content_type : "",
@@ -97,17 +97,14 @@ namespace web
//
form_data ();
- std::unique_ptr<std::streambuf> out_buf (
+ unique_ptr<std::streambuf> out_buf (
buffer
? static_cast<std::streambuf*> (new std::stringbuf ())
: static_cast<std::streambuf*> (new ostreambuf (rec_, *this)));
out_.reset (new std::ostream (out_buf.get ()));
-
- out_buf_ = std::move (out_buf);
-
- out_->exceptions (
- std::ios::eofbit | std::ios::failbit | std::ios::badbit);
+ out_buf_ = move (out_buf);
+ out_->exceptions (ios::eofbit | ios::failbit | ios::badbit);
buffer_ = buffer;
rec_->status = status;
@@ -122,7 +119,7 @@ namespace web
void request::
cookie (const char* name,
const char* value,
- const std::chrono::seconds* max_age,
+ const chrono::seconds* max_age,
const char* path,
const char* domain,
bool secure)
@@ -132,26 +129,22 @@ namespace web
throw sequence_error ("::web::apache::request::cookie");
}
- std::ostringstream s;
+ ostringstream s;
mime_url_encode (name, s);
s << "=";
mime_url_encode (value, s);
if (max_age)
{
- std::chrono::system_clock::time_point tp =
- std::chrono::system_clock::now () + *max_age;
+ chrono::system_clock::time_point tp =
+ chrono::system_clock::now () + *max_age;
- std::time_t t = std::chrono::system_clock::to_time_t (tp);
+ time_t t = chrono::system_clock::to_time_t (tp);
// Assume global "C" locale is not changed.
//
char b[100];
- std::strftime (b,
- sizeof (b),
- "%a, %d-%b-%Y %H:%M:%S GMT",
- std::gmtime (&t));
-
+ strftime (b, sizeof (b), "%a, %d-%b-%Y %H:%M:%S GMT", gmtime (&t));
s << "; Expires=" << b;
}
diff --git a/web/apache/request.ixx b/web/apache/request.ixx
index b41de8d..06284fb 100644
--- a/web/apache/request.ixx
+++ b/web/apache/request.ixx
@@ -63,7 +63,6 @@ namespace web
// Make request data still be available.
//
-
std::unique_ptr<std::streambuf> in_buf (
new std::stringbuf (*form_data_));