CgiUtils.h
Go to the documentation of this file.
1/* -*-mode:c++; c-file-style: "gnu";-*- */
2/*
3 * $Id: CgiUtils.h,v 1.17 2014/04/23 20:55:03 sebdiaz Exp $
4 *
5 * Copyright (C) 1996 - 2004 Stephen F. Booth <sbooth@gnu.org>
6 * 2007 Sebastien DIAZ <sebastien.diaz@gmail.com>
7 * Part of the GNU cgicc library, http://www.gnu.org/software/cgicc
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 3 of the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
22 */
23
24#ifndef _CGIUTILS_H_
25#define _CGIUTILS_H_ 1
26
27#ifdef __GNUG__
28# pragma interface
29#endif
30
38#include <new>
39#include <string>
40#include <fstream>
41
42#include "CgiDefs.h"
43
44
45 namespace cgicc {
46
55 CGICC_API bool
56 stringsAreEqual(const std::string& s1,
57 const std::string& s2);
58
68 CGICC_API bool
69 stringsAreEqual(const std::string& ss1,
70 const std::string& ss2,
71 size_t n);
72
83 CGICC_API std::string
84 form_urldecode(const std::string& src);
85
93 CGICC_API std::string
94 form_urlencode(const std::string& src);
95
96
110 CGICC_API std::string
111 charToHex(char c);
112
127 CGICC_API char
128 hexToChar(char first,
129 char second);
130
146 std::string
147 extractBetween(const std::string& data,
148 const std::string& separator1,
149 const std::string& separator2);
150
159 inline std::string
160 extractBetween(const std::string& datas,
161 const std::string& separators)
162 { return extractBetween(datas, separators, separators); }
163
171 void
172 writeString(std::ostream& out,
173 const std::string& s);
174
182 void
183 writeLong(std::ostream& out,
184 unsigned long l);
185
193 std::string
194 readString(std::istream& in);
195
203 unsigned long
204 readLong(std::istream& in);
205
206} // namespace cgicc
207
208#endif /* ! _CGIUTILS_H_ */
CgiDefs.h
Platform and operating system specific macro definitions.
cgicc
The namespace containing the cgicc library.
Definition: Cgicc.h:52
cgicc::stringsAreEqual
bool stringsAreEqual(const std::string &s1, const std::string &s2)
Compare two strings for equality, ignoring case.
cgicc::readLong
unsigned long readLong(std::istream &in)
Read a long from an istream.
cgicc::form_urldecode
std::string form_urldecode(const std::string &src)
Convert encoded characters in form data to normal ASCII.
cgicc::extractBetween
std::string extractBetween(const std::string &data, const std::string &separator1, const std::string &separator2)
Extract a substring contained within two separators.
cgicc::form_urlencode
std::string form_urlencode(const std::string &src)
Convert an ASCII string to a URL-safe string.
cgicc::charToHex
std::string charToHex(char c)
Convert an ASCII character to its hexadecimal equivalent.
cgicc::hexToChar
char hexToChar(char first, char second)
Convert a hex-encoded character to its ASCII equivalent.
cgicc::writeLong
void writeLong(std::ostream &out, unsigned long l)
Write a long to an ostream.
cgicc::writeString
void writeString(std::ostream &out, const std::string &s)
Write a string to an ostream.
cgicc::readString
std::string readString(std::istream &in)
Read a string from an istream.