Topic: string_view equivalent of python string strip and partition?


Author: Vincent Reverdy <vince.rev@gmail.com>
Date: Mon, 30 Dec 2013 05:48:52 -0800 (PST)
Raw View
------=_Part_249_12033671.1388411332252
Content-Type: text/plain; charset=ISO-8859-1



Hi,
I have not followed all the discussions about *string_view* so the subject
may have been already discussed. For those who are friendly with python<http://docs.python.org/2/library/stdtypes.html>,
strings have two very convenient functions: *strip *and *partition*, that
provide, among other things, a very practical way to parse texts as
illustrated below:


<https://lh5.googleusercontent.com/-Bjh6JxpZhz4/UsF2BVzW0YI/AAAAAAAAABc/6DwvkflxTfk/s1600/string_operations_v01.png>
Of course, we can do that using the *find *functions, but this can become
very verbose to parse strings.
That is why, I think that we should provide a convenient way to shorten
*string_view* on conditions like what is allowed by the python functions.
We could think of a set of members functions like (the name should be
bikesheded):








*striplstriprstripkeep_beforekeepkeep_afterrkeep_beforerkeeprkeep_after*
maybe returning a reference to the updated **this* to be able to chain
operations.

Have these functionalities already been discussed?
What is your opinion on that?

Thanks,
Vincent

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_249_12033671.1388411332252
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><p style=3D"text-align: left; clear: both;" class=3D"separ=
ator">Hi,<br>I have not followed all the discussions about <b><span style=
=3D"font-family: courier new,monospace;">string_view</span></b> so the subj=
ect may have been already discussed. For those who are friendly with <a hre=
f=3D"http://docs.python.org/2/library/stdtypes.html">python</a>, strings ha=
ve two very convenient functions: <b><span style=3D"font-family: courier ne=
w,monospace;">strip </span></b>and <b><span style=3D"font-family: courier n=
ew,monospace;">partition</span></b>, that provide, among other things, a ve=
ry practical way to parse texts as illustrated below:</p><p style=3D"text-a=
lign: left; clear: both;" class=3D"separator"><br><a style=3D"margin-left: =
1em; margin-right: 1em;" href=3D"https://lh5.googleusercontent.com/-Bjh6Jxp=
Zhz4/UsF2BVzW0YI/AAAAAAAAABc/6DwvkflxTfk/s1600/string_operations_v01.png" i=
mageanchor=3D"1"><img src=3D"https://lh5.googleusercontent.com/-Bjh6JxpZhz4=
/UsF2BVzW0YI/AAAAAAAAABc/6DwvkflxTfk/s1600/string_operations_v01.png" style=
=3D"" border=3D"0"></a></p>Of course, we can do that using the <b><span sty=
le=3D"font-family: courier new,monospace;">find </span></b>functions, but t=
his can become very verbose to parse strings.<br>That is why, I think that =
we should provide a convenient way to shorten <span style=3D"font-family: c=
ourier new,monospace;"><b>string_view</b></span> on conditions like what is=
 allowed by the python functions. <br>We could think of a set of members fu=
nctions like (the name should be bikesheded):<br><b><span style=3D"font-fam=
ily: courier new,monospace;">strip<br>lstrip<br>rstrip<br>keep_before<br>ke=
ep<br>keep_after<br>rkeep_before<br>rkeep<br>rkeep_after</span></b><br>mayb=
e returning a reference to the updated <b>*this</b> to be able to chain ope=
rations.<br><br>Have these functionalities already been discussed?<br>What =
is your opinion on that?<br><br>Thanks,<br>Vincent<br><br></div>

<p></p>

-- <br />
&nbsp;<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_249_12033671.1388411332252--

.


Author: "=?utf-8?B?YmlsbHkub25lYWxAZ21haWwuY29t?=" <billy.oneal@gmail.com>
Date: Mon, 30 Dec 2013 08:33:48 -0800
Raw View
------=_Part_0_1388421228625
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

These things should be nonmember algorithms in C++; e.g. as boost::string::=
algorithm does.

Sent from a touchscreen. Please excuse the brevity and tpyos.

----- Reply message -----
From: "Vincent Reverdy" <vince.rev@gmail.com>
To: <std-proposals@isocpp.org>
Subject: [std-proposals] string_view equivalent of python string strip and =
partition?
Date: Mon, Dec 30, 2013 5:48 AM

Hi,
I have not followed all the discussions about string_view so the subject ma=
y have been already discussed. For those who are friendly with python, stri=
ngs have two very convenient functions: strip and partition, that provide, =
among other things, a very practical way to parse texts as illustrated belo=
w:
Of course, we can do that using the find functions, but this can become ver=
y verbose to parse strings.
That is why, I think that we should provide a convenient way to shorten str=
ing_view on conditions like what is allowed by the python functions.=20
We could think of a set of members functions like (the name should be bikes=
heded):
strip
lstrip
rstrip
keep_before
keep
keep_after
rkeep_before
rkeep
rkeep_after
maybe returning a reference to the updated *this to be able to chain operat=
ions.

Have these functionalities already been discussed?
What is your opinion on that?

Thanks,
Vincent





--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

------=_Part_0_1388421228625
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

<div style=3D"font-size: 12pt; font-family: Calibri,sans-serif;"><div>These=
 things should be nonmember algorithms in C++; e.g. as boost::string::algor=
ithm does.</div><div><br></div><div>Sent from a touchscreen. Please excuse =
the brevity and tpyos.</div><br><div id=3D"htc_header">----- Reply message =
-----<br>From: &quot;Vincent Reverdy&quot; &lt;vince.rev@gmail.com&gt;<br>T=
o: &lt;std-proposals@isocpp.org&gt;<br>Subject: [std-proposals] string_view=
 equivalent of python string strip and partition?<br>Date: Mon, Dec 30, 201=
3 5:48 AM</div></div><br><div dir=3D"ltr"><p style=3D"text-align: left; cle=
ar: both;" class=3D"separator">Hi,<br>I have not followed all the discussio=
ns about <b><span style=3D"font-family: courier new,monospace;">string_view=
</span></b> so the subject may have been already discussed. For those who a=
re friendly with <a href=3D"http://docs.python.org/2/library/stdtypes.html"=
>python</a>, strings have two very convenient functions: <b><span style=3D"=
font-family: courier new,monospace;">strip </span></b>and <b><span style=3D=
"font-family: courier new,monospace;">partition</span></b>, that provide, a=
mong other things, a very practical way to parse texts as illustrated below=
:</p><p style=3D"text-align: left; clear: both;" class=3D"separator"><br><a=
 style=3D"margin-left: 1em; margin-right: 1em;" href=3D"https://lh5.googleu=
sercontent.com/-Bjh6JxpZhz4/UsF2BVzW0YI/AAAAAAAAABc/6DwvkflxTfk/s1600/strin=
g_operations_v01.png" imageanchor=3D"1"><img src=3D"https://lh5.googleuserc=
ontent.com/-Bjh6JxpZhz4/UsF2BVzW0YI/AAAAAAAAABc/6DwvkflxTfk/s1600/string_op=
erations_v01.png" style=3D"" border=3D"0"></a></p>Of course, we can do that=
 using the <b><span style=3D"font-family: courier new,monospace;">find </sp=
an></b>functions, but this can become very verbose to parse strings.<br>Tha=
t is why, I think that we should provide a convenient way to shorten <span =
style=3D"font-family: courier new,monospace;"><b>string_view</b></span> on =
conditions like what is allowed by the python functions. <br>We could think=
 of a set of members functions like (the name should be bikesheded):<br><b>=
<span style=3D"font-family: courier new,monospace;">strip<br>lstrip<br>rstr=
ip<br>keep_before<br>keep<br>keep_after<br>rkeep_before<br>rkeep<br>rkeep_a=
fter</span></b><br>maybe returning a reference to the updated <b>*this</b> =
to be able to chain operations.<br><br>Have these functionalities already b=
een discussed?<br>What is your opinion on that?<br><br>Thanks,<br>Vincent<b=
r><br></div>

<p></p>

-- <br />
&nbsp;<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

<p></p>

-- <br />
&nbsp;<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_0_1388421228625--


.