Savarese Software Research Corporation
WebStrings.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2006-2009 Savarese Software Research Corporation
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     https://www.savarese.com/software/ApacheLicense-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef __SSRC_WSPR_UTILITY_WEB_STRINGS_H
00018 #define __SSRC_WSPR_UTILITY_WEB_STRINGS_H
00019 
00020 #include <ssrc/wispers-packages.h>
00021 
00022 #include <string>
00023 #include <tuple>
00024 
00025 __BEGIN_NS_SSRC_WSPR_UTILITY
00026 
00027 using std::string;
00028 
00029 void escape_javascript(string & result, const char *text,
00030                        const unsigned int text_size);
00031 
00032 inline void escape_javascript(string & result, const string & text) {
00033   escape_javascript(result, text.c_str(), text.size());
00034 }
00035 
00036 inline string escape_javascript(const string & text) {
00037   string result;
00038   escape_javascript(result, text);
00039   return result;
00040 }
00041 
00042 void escape_html(string & result, const char *text,
00043                  const unsigned int text_size);
00044 
00045 inline void escape_html(string & result, const string & text) {
00046   escape_html(result, text.c_str(), text.size());
00047 }
00048 
00049 inline string escape_html(const string & text) {
00050   string result;
00051   escape_html(result, text);
00052   return result;
00053 }
00054 
00055 void escape_url(string & result, const char *text,
00056                 const unsigned int text_size);
00057 
00058 inline void escape_url(string & result, const string & text) {
00059   escape_url(result, text.c_str(), text.size());
00060 }
00061 
00062 inline string escape_url(const string & text) {
00063   string result;
00064   escape_url(result, text);
00065   return result;
00066 }
00067 
00068 void unescape_url(string & url);
00069 
00070 void strip_html(string & result, const char *text,
00071                 const unsigned int text_size);
00072 
00073 inline void strip_html(string & result, const string & text) {
00074   strip_html(result, text.c_str(), text.size());
00075 }
00076 
00077 inline string strip_html(const string & text) {
00078   string result;
00079   strip_html(result, text);
00080   return result;
00081 }
00082 
00083 void strip_html_and_unescape(string & result, const char *text,
00084                              const unsigned int text_size);
00085 
00086 inline string strip_html_and_unescape(const char *text,
00087                                       const unsigned int text_size)
00088 {
00089   string result;
00090   strip_html_and_unescape(result, text, text_size);
00091   return result;
00092 }
00093 
00094 inline void strip_html_and_unescape(string & result, const string & text) {
00095   strip_html_and_unescape(result, text.c_str(), text.size());
00096 }
00097 
00098 inline string strip_html_and_unescape(const string & text) {
00099   string result;
00100   strip_html_and_unescape(result, text);
00101   return result;
00102 }
00103 
00104 void wrap_lines(char *text, const unsigned int text_size,
00105                 const unsigned int max_length = 79);
00106 
00107 typedef
00108 std::tuple<const char *, std::ptrdiff_t, const char *, std::ptrdiff_t>
00109 title_body_type;
00110 
00111 title_body_type html_title_and_body(const char *begin, const char *end);
00112 
00113 __END_NS_SSRC_WSPR_UTILITY
00114 
00115 #endif

Savarese Software Research Corporation
Copyright © 2006-2011 Savarese Software Research Corporation. All rights reserved.