summaryrefslogtreecommitdiff
path: root/src/mongo/util/mongoutils
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/util/mongoutils')
-rw-r--r--src/mongo/util/mongoutils/html.h70
-rw-r--r--src/mongo/util/mongoutils/str.h16
2 files changed, 42 insertions, 44 deletions
diff --git a/src/mongo/util/mongoutils/html.h b/src/mongo/util/mongoutils/html.h
index 563440ffd1b..78bcc49ec55 100644
--- a/src/mongo/util/mongoutils/html.h
+++ b/src/mongo/util/mongoutils/html.h
@@ -43,42 +43,40 @@ namespace mongoutils {
namespace html {
- using namespace std;
+ inline std::string _end() { return "</body></html>"; }
+ inline std::string _table() { return "</table>\n\n"; }
+ inline std::string _tr() { return "</tr>\n"; }
- inline string _end() { return "</body></html>"; }
- inline string _table() { return "</table>\n\n"; }
- inline string _tr() { return "</tr>\n"; }
-
- inline string tr() { return "<tr>"; }
- inline string tr(const std::string& a, const std::string& b) {
- stringstream ss;
+ inline std::string tr() { return "<tr>"; }
+ inline std::string tr(const std::string& a, const std::string& b) {
+ std::stringstream ss;
ss << "<tr><td>" << a << "</td><td>" << b << "</td></tr>\n";
return ss.str();
}
template <class T>
- inline string td(T x) {
- stringstream ss;
+ inline std::string td(T x) {
+ std::stringstream ss;
ss << "<td>" << x << "</td>";
return ss.str();
}
- inline string td(const std::string& x) {
+ inline std::string td(const std::string& x) {
return "<td>" + x + "</td>";
}
- inline string th(const std::string& x) {
+ inline std::string th(const std::string& x) {
return "<th>" + x + "</th>";
}
- inline void tablecell( stringstream& ss , bool b ) {
+ inline void tablecell( std::stringstream& ss , bool b ) {
ss << "<td>" << (b ? "<b>X</b>" : "") << "</td>";
}
template< typename T>
- inline void tablecell( stringstream& ss , const T& t ) {
+ inline void tablecell( std::stringstream& ss , const T& t ) {
ss << "<td>" << t << "</td>";
}
- inline string table(const char *headers[] = 0, bool border = true) {
- stringstream ss;
+ inline std::string table(const char *headers[] = 0, bool border = true) {
+ std::stringstream ss;
ss << "\n<table "
<< (border?"border=1 ":"")
<< "cellpadding=2 cellspacing=0>\n";
@@ -93,8 +91,8 @@ namespace mongoutils {
return ss.str();
}
- inline string start(const std::string& title) {
- stringstream ss;
+ inline std::string start(const std::string& title) {
+ std::stringstream ss;
ss << "<html><head>\n<title>";
ss << title;
ss << "</title>\n";
@@ -110,54 +108,54 @@ namespace mongoutils {
return ss.str();
}
- inline string red(const std::string& contentHtml, bool color=true) {
+ inline std::string red(const std::string& contentHtml, bool color=true) {
if( !color ) return contentHtml;
- stringstream ss;
+ std::stringstream ss;
ss << "<span style=\"color:#A00;\">" << contentHtml << "</span>";
return ss.str();
}
- inline string grey(const std::string& contentHtml, bool color=true) {
+ inline std::string grey(const std::string& contentHtml, bool color=true) {
if( !color ) return contentHtml;
- stringstream ss;
+ std::stringstream ss;
ss << "<span style=\"color:#888;\">" << contentHtml << "</span>";
return ss.str();
}
- inline string blue(const std::string& contentHtml, bool color=true) {
+ inline std::string blue(const std::string& contentHtml, bool color=true) {
if( !color ) return contentHtml;
- stringstream ss;
+ std::stringstream ss;
ss << "<span style=\"color:#00A;\">" << contentHtml << "</span>";
return ss.str();
}
- inline string yellow(const std::string& contentHtml, bool color=true) {
+ inline std::string yellow(const std::string& contentHtml, bool color=true) {
if( !color ) return contentHtml;
- stringstream ss;
+ std::stringstream ss;
ss << "<span style=\"color:#A80;\">" << contentHtml << "</span>";
return ss.str();
}
- inline string green(const std::string& contentHtml, bool color=true) {
+ inline std::string green(const std::string& contentHtml, bool color=true) {
if( !color ) return contentHtml;
- stringstream ss;
+ std::stringstream ss;
ss << "<span style=\"color:#0A0;\">" << contentHtml << "</span>";
return ss.str();
}
- inline string p(const std::string& contentHtml) {
- stringstream ss;
+ inline std::string p(const std::string& contentHtml) {
+ std::stringstream ss;
ss << "<p>" << contentHtml << "</p>\n";
return ss.str();
}
- inline string h2(const std::string& contentHtml) {
- stringstream ss;
+ inline std::string h2(const std::string& contentHtml) {
+ std::stringstream ss;
ss << "<h2>" << contentHtml << "</h2>\n";
return ss.str();
}
/* does NOT escape the strings. */
- inline string a(const std::string& href,
+ inline std::string a(const std::string& href,
const std::string& title="",
const std::string& contentHtml = "") {
- stringstream ss;
+ std::stringstream ss;
ss << "<a";
if( !href.empty() ) ss << " href=\"" << href << '"';
if( !title.empty() ) ss << " title=\"" << title << '"';
@@ -169,8 +167,8 @@ namespace mongoutils {
}
/* escape for HTML display */
- inline string escape(const string& data) {
- string buffer;
+ inline std::string escape(const std::string& data) {
+ std::string buffer;
buffer.reserve( data.size() );
for( size_t pos = 0; pos != data.size(); ++pos ) {
switch( data[pos] ) {
diff --git a/src/mongo/util/mongoutils/str.h b/src/mongo/util/mongoutils/str.h
index 816327928e3..1fbb69fe23b 100644
--- a/src/mongo/util/mongoutils/str.h
+++ b/src/mongo/util/mongoutils/str.h
@@ -55,7 +55,7 @@ namespace mongoutils {
since the following doesn't work:
- (stringstream() << 1).str();
+ (std::stringstream() << 1).str();
*/
class stream {
public:
@@ -98,7 +98,7 @@ namespace mongoutils {
inline bool equals( const char * a , const char * b ) { return strcmp( a , b ) == 0; }
- /** find char x, and return rest of string thereafter, or "" if not found */
+ /** find char x, and return rest of std::string thereafter, or "" if not found */
inline const char * after(const char *s, char x) {
const char *p = strchr(s, x);
return (p != 0) ? p+1 : "";
@@ -108,7 +108,7 @@ namespace mongoutils {
return (p != 0) ? std::string(p+1) : "";
}
- /** find string x, and return rest of string thereafter, or "" if not found */
+ /** find std::string x, and return rest of std::string thereafter, or "" if not found */
inline const char * after(const char *s, const char *x) {
const char *p = strstr(s, x);
return (p != 0) ? p+strlen(x) : "";
@@ -129,13 +129,13 @@ namespace mongoutils {
return strchr(s.c_str(), x) != 0;
}
- /** @return everything before the character x, else entire string */
+ /** @return everything before the character x, else entire std::string */
inline std::string before(const std::string& s, char x) {
const char *p = strchr(s.c_str(), x);
return (p != 0) ? s.substr(0, p-s.c_str()) : s;
}
- /** @return everything before the string x, else entire string */
+ /** @return everything before the std::string x, else entire std::string */
inline std::string before(const std::string& s, const std::string& x) {
const char *p = strstr(s.c_str(), x.c_str());
return (p != 0) ? s.substr(0, p-s.c_str()) : s;
@@ -157,7 +157,7 @@ namespace mongoutils {
inline int shareCommonPrefix(const std::string &a, const std::string &b)
{ return shareCommonPrefix(a.c_str(), b.c_str()); }
- /** string to unsigned. zero if not a number. can end with non-num chars */
+ /** std::string to unsigned. zero if not a number. can end with non-num chars */
inline unsigned toUnsigned(const std::string& a) {
unsigned x = 0;
const char *p = a.c_str();
@@ -170,8 +170,8 @@ namespace mongoutils {
return x;
}
- /** split a string on a specific char. We don't split N times, just once
- on the first occurrence. If char not present entire string is in L
+ /** split a std::string on a specific char. We don't split N times, just once
+ on the first occurrence. If char not present entire std::string is in L
and R is empty.
@return true if char found
*/