~evarlast/ubuntu/utopic/mongodb/upstart-workaround-debian-bug-718702

« back to all changes in this revision

Viewing changes to src/mongo/util/mongoutils/html.h

  • Committer: Package Import Robot
  • Author(s): James Page, James Page, Robie Basak
  • Date: 2013-05-29 17:44:42 UTC
  • mfrom: (44.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20130529174442-z0a4qmoww4y0t458
Tags: 1:2.4.3-1ubuntu1
[ James Page ]
* Merge from Debian unstable, remaining changes:
  - Enable SSL support:
    + d/control: Add libssl-dev to BD's.
    + d/rules: Enabled --ssl option.
    + d/mongodb.conf: Add example SSL configuration options.
  - d/mongodb-server.mongodb.upstart: Add upstart configuration.
  - d/rules: Don't strip binaries during scons build for Ubuntu.
  - d/control: Add armhf to target archs.
  - d/p/SConscript.client.patch: fixup install of client libraries.
  - d/p/0010-install-libs-to-usr-lib-not-usr-lib64-Closes-588557.patch:
    Install libraries to lib not lib64.
* Dropped changes:
  - d/p/arm-support.patch: Included in Debian.
  - d/p/double-alignment.patch: Included in Debian.
  - d/rules,control: Debian also builds with avaliable system libraries
    now.
* Fix FTBFS due to gcc and boost upgrades in saucy:
  - d/p/0008-ignore-unused-local-typedefs.patch: Add -Wno-unused-typedefs
    to unbreak building with g++-4.8.
  - d/p/0009-boost-1.53.patch: Fixup signed/unsigned casting issue.

[ Robie Basak ]
* d/p/0011-Use-a-signed-char-to-store-BSONType-enumerations.patch: Fixup
  build failure on ARM due to missing signed'ness of char cast.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// @file html.h
2
2
 
 
3
/**
 
4
*    Copyright (C) 2012 10gen Inc.
 
5
*
 
6
*    This program is free software: you can redistribute it and/or  modify
 
7
*    it under the terms of the GNU Affero General Public License, version 3,
 
8
*    as published by the Free Software Foundation.
 
9
*
 
10
*    This program is distributed in the hope that it will be useful,
 
11
*    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
*    GNU Affero General Public License for more details.
 
14
*
 
15
*    You should have received a copy of the GNU Affero General Public License
 
16
*    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
17
*/
 
18
 
3
19
#pragma once
4
20
 
5
21
/* Things in the mongoutils namespace
9
25
   (4) are clean and easy to use in any c++ project without pulling in lots of other stuff
10
26
*/
11
27
 
12
 
/*    Copyright 2010 10gen Inc.
13
 
 *
14
 
 *    Licensed under the Apache License, Version 2.0 (the "License");
15
 
 *    you may not use this file except in compliance with the License.
16
 
 *    You may obtain a copy of the License at
17
 
 *
18
 
 *    http://www.apache.org/licenses/LICENSE-2.0
19
 
 *
20
 
 *    Unless required by applicable law or agreed to in writing, software
21
 
 *    distributed under the License is distributed on an "AS IS" BASIS,
22
 
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23
 
 *    See the License for the specific language governing permissions and
24
 
 *    limitations under the License.
25
 
 */
26
 
 
27
28
#include <sstream>
28
29
 
29
30
namespace mongoutils {
37
38
        inline string _tr() { return "</tr>\n"; }
38
39
 
39
40
        inline string tr() { return "<tr>"; }
40
 
        inline string tr(string a, string b) {
 
41
        inline string tr(const std::string& a, const std::string& b) {
41
42
            stringstream ss;
42
43
            ss << "<tr><td>" << a << "</td><td>" << b << "</td></tr>\n";
43
44
            return ss.str();
48
49
            ss << "<td>" << x << "</td>";
49
50
            return ss.str();
50
51
        }
51
 
        inline string td(string x) {
 
52
        inline string td(const std::string& x) {
52
53
            return "<td>" + x + "</td>";
53
54
        }
54
 
        inline string th(string x) {
 
55
        inline string th(const std::string& x) {
55
56
            return "<th>" + x + "</th>";
56
57
        }
57
58
 
80
81
            return ss.str();
81
82
        }
82
83
 
83
 
        inline string start(string title) {
 
84
        inline string start(const std::string& title) {
84
85
            stringstream ss;
85
86
            ss << "<html><head>\n<title>";
86
87
            ss << title;
97
98
            return ss.str();
98
99
        }
99
100
 
100
 
        inline string red(string contentHtml, bool color=true) {
 
101
        inline string red(const std::string& contentHtml, bool color=true) {
101
102
            if( !color ) return contentHtml;
102
103
            stringstream ss;
103
104
            ss << "<span style=\"color:#A00;\">" << contentHtml << "</span>";
104
105
            return ss.str();
105
106
        }
106
 
        inline string grey(string contentHtml, bool color=true) {
 
107
        inline string grey(const std::string& contentHtml, bool color=true) {
107
108
            if( !color ) return contentHtml;
108
109
            stringstream ss;
109
110
            ss << "<span style=\"color:#888;\">" << contentHtml << "</span>";
110
111
            return ss.str();
111
112
        }
112
 
        inline string blue(string contentHtml, bool color=true) {
 
113
        inline string blue(const std::string& contentHtml, bool color=true) {
113
114
            if( !color ) return contentHtml;
114
115
            stringstream ss;
115
116
            ss << "<span style=\"color:#00A;\">" << contentHtml << "</span>";
116
117
            return ss.str();
117
118
        }
118
 
        inline string yellow(string contentHtml, bool color=true) {
 
119
        inline string yellow(const std::string& contentHtml, bool color=true) {
119
120
            if( !color ) return contentHtml;
120
121
            stringstream ss;
121
122
            ss << "<span style=\"color:#A80;\">" << contentHtml << "</span>";
122
123
            return ss.str();
123
124
        }
124
 
        inline string green(string contentHtml, bool color=true) {
 
125
        inline string green(const std::string& contentHtml, bool color=true) {
125
126
            if( !color ) return contentHtml;
126
127
            stringstream ss;
127
128
            ss << "<span style=\"color:#0A0;\">" << contentHtml << "</span>";
128
129
            return ss.str();
129
130
        }
130
131
 
131
 
        inline string p(string contentHtml) {
 
132
        inline string p(const std::string& contentHtml) {
132
133
            stringstream ss;
133
134
            ss << "<p>" << contentHtml << "</p>\n";
134
135
            return ss.str();
135
136
        }
136
137
 
137
 
        inline string h2(string contentHtml) {
 
138
        inline string h2(const std::string& contentHtml) {
138
139
            stringstream ss;
139
140
            ss << "<h2>" << contentHtml << "</h2>\n";
140
141
            return ss.str();
141
142
        }
142
143
 
143
144
        /* does NOT escape the strings. */
144
 
        inline string a(string href, string title="", string contentHtml = "") {
 
145
        inline string a(const std::string& href,
 
146
                        const std::string& title="",
 
147
                        const std::string& contentHtml = "") {
145
148
            stringstream ss;
146
149
            ss << "<a";
147
150
            if( !href.empty() ) ss << " href=\"" << href << '"';