Library of Assembled Shared Sources
extended_string.h
Go to the documentation of this file.
1/** @file
2 * @author Bram de Greve (bram@cocamware.com)
3 * @author Tom De Muer (tom@cocamware.com)
4 *
5 * *** BEGIN LICENSE INFORMATION ***
6 *
7 * The contents of this file are subject to the Common Public Attribution License
8 * Version 1.0 (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
10 * http://lass.sourceforge.net/cpal-license. The License is based on the
11 * Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover
12 * use of software over a computer network and provide for limited attribution for
13 * the Original Developer. In addition, Exhibit A has been modified to be consistent
14 * with Exhibit B.
15 *
16 * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
17 * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
18 * language governing rights and limitations under the License.
19 *
20 * The Original Code is LASS - Library of Assembled Shared Sources.
21 *
22 * The Initial Developer of the Original Code is Bram de Greve and Tom De Muer.
23 * The Original Developer is the Initial Developer.
24 *
25 * All portions of the code written by the Initial Developer are:
26 * Copyright (C) 2004-2011 the Initial Developer.
27 * All Rights Reserved.
28 *
29 * Contributor(s):
30 *
31 * Alternatively, the contents of this file may be used under the terms of the
32 * GNU General Public License Version 2 or later (the GPL), in which case the
33 * provisions of GPL are applicable instead of those above. If you wish to allow use
34 * of your version of this file only under the terms of the GPL and not to allow
35 * others to use your version of this file under the CPAL, indicate your decision by
36 * deleting the provisions above and replace them with the notice and other
37 * provisions required by the GPL License. If you do not delete the provisions above,
38 * a recipient may use your version of this file under either the CPAL or the GPL.
39 *
40 * *** END LICENSE INFORMATION ***
41 */
42
43
44
45/** @defgroup extended_string
46 * @brief extra std::string functionality
47 * @author Bram de Greve [BdG]
48 *
49 * ExtendedString is not an extended std::string implementation as the name might suggest, but
50 * a set of functions that provide extra functionality on very standard std::string strings.
51 * Most of them are inspired by the string module of Python, as you will notice.
52 * Others are std::string implementations of C functions operating on char arrays
53 */
54
55#ifndef LASS_GUARDIAN_OF_INCLUSION_STDE_EXTENDED_STRING_H
56#define LASS_GUARDIAN_OF_INCLUSION_STDE_EXTENDED_STRING_H
57
58#include "stde_common.h"
59
60#if LASS_PLATFORM_TYPE == LASS_PLATFORM_TYPE_BSD
61# ifdef toupper
62# undef toupper
63# endif
64# ifdef tolower
65# undef tolower
66# endif
67#endif
68
69namespace lass
70{
71namespace stde
72{
73
74template <typename Char, typename Traits, typename Alloc>
75std::basic_string<Char, Traits, Alloc>
76tolower(const std::basic_string<Char, Traits, Alloc>& input,
77 const std::locale& locale = std::locale());
78
79template <typename Char, typename Traits, typename Alloc>
80std::basic_string<Char, Traits, Alloc>
81toupper(const std::basic_string<Char, Traits, Alloc>& input,
82 const std::locale& locale = std::locale());
83
84template <typename Char, typename Traits, typename Alloc>
85std::basic_string<Char, Traits, Alloc>
86replace_all(const std::basic_string<Char, Traits, Alloc>& input,
87 const std::basic_string<Char, Traits, Alloc>& to_be_replaced,
88 const std::basic_string<Char, Traits, Alloc>& replacement);
89template <typename Char, typename Traits, typename Alloc>
90std::basic_string<Char, Traits, Alloc>
91replace_all(const std::basic_string<Char, Traits, Alloc>& input,
92 const Char* to_be_replaced,
93 const Char* replacement);
94
95template <typename Char, typename Traits, typename Alloc>
96bool begins_with(const std::basic_string<Char, Traits, Alloc>& input,
97 const std::basic_string<Char, Traits, Alloc>& prefix);
98template <typename Char, typename Traits, typename Alloc>
99bool begins_with(const std::basic_string<Char, Traits, Alloc>& input,
100 const Char* prefix);
101template <typename Char, typename Traits, typename Alloc>
102bool begins_with(const std::basic_string<Char, Traits, Alloc>& input,
103 Char prefix);
104
105template <typename Char, typename Traits, typename Alloc>
106bool ends_with(const std::basic_string<Char, Traits, Alloc>& input,
107 const std::basic_string<Char, Traits, Alloc>& suffix);
108template <typename Char, typename Traits, typename Alloc>
109bool ends_with(const std::basic_string<Char, Traits, Alloc>& input,
110 const Char* suffix);
111template <typename Char, typename Traits, typename Alloc>
112bool ends_with(const std::basic_string<Char, Traits, Alloc>& input,
113 Char suffix);
114
115template <typename Char, typename Traits, typename Alloc>
116std::vector< std::basic_string<Char, Traits, Alloc> >
117split(const std::basic_string<Char, Traits, Alloc>& to_be_split);
118
119template <typename Char, typename Traits, typename Alloc>
120std::vector< std::basic_string<Char, Traits, Alloc> >
121split(const std::basic_string<Char, Traits, Alloc>& to_be_split,
122 const std::basic_string<Char, Traits, Alloc>& seperator,
123 size_t max_split = 0);
124template <typename Char, typename Traits, typename Alloc>
125std::vector< std::basic_string<Char, Traits, Alloc> >
126split(const std::basic_string<Char, Traits, Alloc>& to_be_split,
127 const Char* seperator,
128 size_t max_split = 0);
129
130template <typename Char, typename Traits, typename Alloc, typename InputIterator>
131std::basic_string<Char, Traits, Alloc>
132join(const std::basic_string<Char, Traits, Alloc>& joiner, InputIterator first, InputIterator last);
133
134template <typename Char, typename Traits, typename Alloc, typename InputRange>
135std::basic_string<Char, Traits, Alloc>
136join_r(const std::basic_string<Char, Traits, Alloc>& joiner, const InputRange& range);
137
138template <typename Char, typename Traits, typename Alloc>
139std::basic_string<Char, Traits, Alloc>
140lstrip(const std::basic_string<Char, Traits, Alloc>& to_be_stripped,
141 const std::basic_string<Char, Traits, Alloc>& to_be_removed);
142
143template <typename Char, typename Traits, typename Alloc>
144std::basic_string<Char, Traits, Alloc>
145lstrip(const std::basic_string<Char, Traits, Alloc>& to_be_stripped);
146
147template <typename Char, typename Traits, typename Alloc>
148std::basic_string<Char, Traits, Alloc>
149rstrip(const std::basic_string<Char, Traits, Alloc>& to_be_stripped,
150 const std::basic_string<Char, Traits, Alloc>& to_be_removed);
151
152template <typename Char, typename Traits, typename Alloc>
153std::basic_string<Char, Traits, Alloc>
154rstrip(const std::basic_string<Char, Traits, Alloc>& to_be_stripped);
155
156template <typename Char, typename Traits, typename Alloc>
157std::basic_string<Char, Traits, Alloc>
158strip(const std::basic_string<Char, Traits, Alloc>& to_be_stripped,
159 const std::basic_string<Char, Traits, Alloc>& to_be_removed);
160
161template <typename Char, typename Traits, typename Alloc>
162std::basic_string<Char, Traits, Alloc>
163strip(const std::basic_string<Char, Traits, Alloc>& to_be_stripped);
164
165}
166
167}
168
169#include "extended_string.inl"
170
171#endif
172
173// EOF
std::basic_string< Char, Traits, Alloc > lstrip(const std::basic_string< Char, Traits, Alloc > &to_be_stripped, const std::basic_string< Char, Traits, Alloc > &to_be_removed)
Return a copy of the string to_be_stripped with leading characters removed.
bool begins_with(const std::basic_string< Char, Traits, Alloc > &input, const std::basic_string< Char, Traits, Alloc > &prefix)
returns true if input begins with the input prefix
std::basic_string< Char, Traits, Alloc > rstrip(const std::basic_string< Char, Traits, Alloc > &to_be_stripped, const std::basic_string< Char, Traits, Alloc > &to_be_removed)
Return a copy of the string to_be_stripped with trailing characters removed.
std::basic_string< Char, Traits, Alloc > replace_all(const std::basic_string< Char, Traits, Alloc > &input, const std::basic_string< Char, Traits, Alloc > &to_be_replaced, const std::basic_string< Char, Traits, Alloc > &replacement)
replace all instances of to_be_replaced in input by replacement.
std::basic_string< Char, Traits, Alloc > tolower(const std::basic_string< Char, Traits, Alloc > &input, const std::locale &locale=std::locale())
convert std::basic_string to lower case by using user locale
std::vector< std::basic_string< Char, Traits, Alloc > > split(const std::basic_string< Char, Traits, Alloc > &to_be_split)
Reflects the Python function split without seperator argument.
std::basic_string< Char, Traits, Alloc > toupper(const std::basic_string< Char, Traits, Alloc > &input, const std::locale &locale=std::locale())
convert std::basic_string to upper case by using user locale
bool ends_with(const std::basic_string< Char, Traits, Alloc > &input, const std::basic_string< Char, Traits, Alloc > &suffix)
returns true if input ends with the input suffix
std::basic_string< Char, Traits, Alloc > strip(const std::basic_string< Char, Traits, Alloc > &to_be_stripped, const std::basic_string< Char, Traits, Alloc > &to_be_removed)
Return a copy of the string to_be_stripped with both leading and trailing characters removed.
lass extensions to the standard library
Library for Assembled Shared Sources.
Definition config.h:53